Skip an already finalized block in a segment (#1041)

This commit is contained in:
Paul Hauner 2020-04-22 23:06:16 +10:00 committed by GitHub
parent 2469bde6b1
commit aacec7a4a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1444,6 +1444,20 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
Err(BlockError::BlockIsAlreadyKnown) => continue,
// If the block is the genesis block, simply ignore this block.
Err(BlockError::GenesisBlock) => continue,
// If the block is is for a finalized slot, simply ignore this block.
//
// The block is either:
//
// 1. In the canonical finalized chain.
// 2. In some non-canonical chain at a slot that has been finalized already.
//
// In the case of (1), there's no need to re-import and later blocks in this
// segement might be useful.
//
// In the case of (2), skipping the block is valid since we should never import it.
// However, we will potentially get a `ParentUnknown` on a later block. The sync
// protocol will need to ensure this is handled gracefully.
Err(BlockError::WouldRevertFinalizedSlot { .. }) => continue,
// If there was an error whilst determining if the block was invalid, return that
// error.
Err(BlockError::BeaconChainError(e)) => {