fix pivot block issue for write on chain

pull/4465/head
“GheisMohammadi” 1 year ago
parent 6348128c48
commit c808f2b733
No known key found for this signature in database
GPG Key ID: 15073AED3829FE90
  1. 2
      api/service/stagedstreamsync/stage_state.go
  2. 10
      api/service/stagedstreamsync/stage_statesync.go

@ -55,7 +55,7 @@ func NewStageStatesCfg(
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() {
if s.state.status.pivotBlock != nil && s.state.bc.CurrentBlock().NumberU64() < s.state.status.pivotBlock.NumberU64() {
return nil
}
}

@ -113,6 +113,16 @@ func (sss *StageStateSync) Exec(ctx context.Context, bool, invalidBlockRevert bo
}
wg.Wait()
// insert block
if err := sss.configs.bc.WriteHeadBlock(s.state.status.pivotBlock); err != nil {
sss.configs.logger.Warn().Err(err).
Uint64("pivot block number", s.state.status.pivotBlock.NumberU64()).
Msg(WrapStagedSyncMsg("insert pivot block failed"))
s.state.Debug("StateSync/pivot/insert/error", err)
// TODO: panic("pivot block is failed to insert in chain.")
return err
}
/*
gbm := s.state.gbm

Loading…
Cancel
Save