remove blockExecution option from staged stream sync

pull/4465/head
“GheisMohammadi” 1 year ago
parent 36d2abd0a4
commit 9629d9ca56
No known key found for this signature in database
GPG Key ID: 15073AED3829FE90
  1. 2
      api/service/stagedstreamsync/adapter.go
  2. 8
      api/service/stagedstreamsync/sig_verify.go
  3. 2
      api/service/stagedstreamsync/stage_short_range.go
  4. 12
      api/service/stagedstreamsync/stage_state.go

@ -31,6 +31,6 @@ type blockChain interface {
engine.ChainReader
Engine() engine.Engine
InsertChain(chain types.Blocks, verifyHeaders bool, blockExecution bool) (int, error)
InsertChain(chain types.Blocks, verifyHeaders bool) (int, error)
WriteCommitSig(blockNum uint64, lastCommits []byte) error
}

@ -20,9 +20,9 @@ func (e *sigVerifyErr) Error() string {
return fmt.Sprintf("[VerifyHeaderSignature] %v", e.err.Error())
}
func verifyAndInsertBlocks(bc blockChain, blocks types.Blocks, blockExecution bool) (int, error) {
func verifyAndInsertBlocks(bc blockChain, blocks types.Blocks) (int, error) {
for i, block := range blocks {
if err := verifyAndInsertBlock(bc, block, blockExecution, blocks[i+1:]...); err != nil {
if err := verifyAndInsertBlock(bc, block, blocks[i+1:]...); err != nil {
return i, err
}
}
@ -65,13 +65,13 @@ func verifyBlock(bc blockChain, block *types.Block, nextBlocks ...*types.Block)
return nil
}
func verifyAndInsertBlock(bc blockChain, block *types.Block, blockExecution bool, nextBlocks ...*types.Block) error {
func verifyAndInsertBlock(bc blockChain, block *types.Block, nextBlocks ...*types.Block) error {
//verify block
if err := verifyBlock(bc, block, nextBlocks...); err != nil {
return err
}
// insert block
if _, err := bc.InsertChain(types.Blocks{block}, false, blockExecution); err != nil {
if _, err := bc.InsertChain(types.Blocks{block}, false); err != nil {
return errors.Wrap(err, "[InsertChain]")
}
return nil

@ -138,7 +138,7 @@ func (sr *StageShortRange) doShortRangeSync(ctx context.Context, s *StageState)
utils.Logger().Info().Int("num blocks", len(blocks)).Msg("getBlockByHashes result")
n, err := verifyAndInsertBlocks(sr.configs.bc, blocks, true)
n, err := verifyAndInsertBlocks(sr.configs.bc, blocks)
numBlocksInsertedShortRangeHistogramVec.With(s.state.promLabels()).Observe(float64(n))
if err != nil {
utils.Logger().Warn().Err(err).Int("blocks inserted", n).Msg("Insert block failed")

@ -23,7 +23,6 @@ type StageStatesCfg struct {
db kv.RwDB
blockDBs []kv.RwDB
concurrency int
blockExecution bool
logger zerolog.Logger
logProgress bool
}
@ -39,7 +38,6 @@ func NewStageStatesCfg(
db kv.RwDB,
blockDBs []kv.RwDB,
concurrency int,
blockExecution bool,
logger zerolog.Logger,
logProgress bool) StageStatesCfg {
@ -48,7 +46,6 @@ func NewStageStatesCfg(
db: db,
blockDBs: blockDBs,
concurrency: concurrency,
blockExecution: blockExecution,
logger: logger,
logProgress: logProgress,
}
@ -56,6 +53,13 @@ func NewStageStatesCfg(
// Exec progresses States stage in the forward direction
func (stg *StageStates) Exec(ctx context.Context, firstCycle bool, invalidBlockRevert bool, s *StageState, reverter Reverter, tx kv.RwTx) (err error) {
// only execute this stage in full sync mode
if s.state.config.SyncMode != FullSync {
if s.state.status.pivotBlock != nil && s.state.bc.CurrentBlock().NumberU64() <= s.state.status.pivotBlock.NumberU64() {
return nil
}
}
// for short range sync, skip this step
if !s.state.initSync {
return nil
@ -160,7 +164,7 @@ func (stg *StageStates) Exec(ctx context.Context, firstCycle bool, invalidBlockR
return ErrInvalidBlockNumber
}
if err := verifyAndInsertBlock(stg.configs.bc, block, stg.configs.blockExecution); err != nil {
if err := verifyAndInsertBlock(stg.configs.bc, block); err != nil {
stg.configs.logger.Warn().Err(err).Uint64("cycle target block", targetHeight).
Uint64("block number", block.NumberU64()).
Msg(WrapStagedSyncMsg("insert blocks failed in long range"))

Loading…
Cancel
Save