Skip epochchain errors. (#4573)

pull/4574/head
Konstantin 1 year ago committed by GitHub
parent 368fc9e07b
commit b7b7fbf2b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      api/service/legacysync/syncing.go
  2. 5
      api/service/stagedstreamsync/staged_stream_sync.go
  3. 6
      api/service/stagedsync/stagedsync.go
  4. 6
      consensus/downloader.go
  5. 1
      core/blockchain_impl.go
  6. 2
      core/epochchain.go

@ -1158,7 +1158,11 @@ func (ss *StateSync) addConsensusLastMile(bc core.BlockChain, consensus *consens
if block == nil {
break
}
if _, err := bc.InsertChain(types.Blocks{block}, true); err != nil {
_, err := bc.InsertChain(types.Blocks{block}, true)
switch {
case errors.Is(err, core.ErrKnownBlock):
case errors.Is(err, core.ErrNotLastBlockInEpoch):
case err != nil:
return errors.Wrap(err, "failed to InsertChain")
}
}

@ -637,7 +637,10 @@ func (ss *StagedStreamSync) addConsensusLastMile(bc core.BlockChain, cs *consens
break
}
_, err := bc.InsertChain(types.Blocks{block}, true)
if err != nil && !errors.Is(err, core.ErrKnownBlock) {
switch {
case errors.Is(err, core.ErrKnownBlock):
case errors.Is(err, core.ErrNotLastBlockInEpoch):
case err != nil:
return errors.Wrap(err, "failed to InsertChain")
}
hashes = append(hashes, block.Header().Hash())

@ -1221,7 +1221,11 @@ func (ss *StagedSync) addConsensusLastMile(bc core.BlockChain, cs *consensus.Con
if block == nil {
break
}
if _, err := bc.InsertChain(types.Blocks{block}, true); err != nil && !errors.Is(err, core.ErrKnownBlock) {
_, err := bc.InsertChain(types.Blocks{block}, true)
switch {
case errors.Is(err, core.ErrKnownBlock):
case errors.Is(err, core.ErrNotLastBlockInEpoch):
case err != nil:
return errors.Wrap(err, "failed to InsertChain")
}
}

@ -91,7 +91,11 @@ func (consensus *Consensus) AddConsensusLastMile() error {
if block == nil {
break
}
if _, err := consensus.Blockchain().InsertChain(types.Blocks{block}, true); err != nil && !errors.Is(err, core.ErrKnownBlock) {
_, err := consensus.Blockchain().InsertChain(types.Blocks{block}, true)
switch {
case errors.Is(err, core.ErrKnownBlock):
case errors.Is(err, core.ErrNotLastBlockInEpoch):
case err != nil:
return errors.Wrap(err, "failed to InsertChain")
}
}

@ -90,6 +90,7 @@ var (
// ErrNoGenesis is the error when there is no genesis.
ErrNoGenesis = errors.New("Genesis not found in chain")
ErrEmptyChain = errors.New("empty chain")
ErrNotLastBlockInEpoch = errors.New("not last block in epoch")
// errExceedMaxPendingSlashes ..
errExceedMaxPendingSlashes = errors.New("exceeed max pending slashes")
errNilEpoch = errors.New("nil epoch for voting power computation")

@ -124,7 +124,7 @@ func (bc *EpochChain) InsertChain(blocks types.Blocks, _ bool) (int, error) {
}()
for i, block := range blocks {
if !block.IsLastBlockInEpoch() {
return i, errors.New("block is not last block in epoch")
return i, ErrNotLastBlockInEpoch
}
sig, bitmap, err := chain.ParseCommitSigAndBitmap(block.GetCurrentCommitSig())
if err != nil {

Loading…
Cancel
Save