From aacec7a4a793669673662e9e18ffda28b81a32e2 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Wed, 22 Apr 2020 23:06:16 +1000 Subject: [PATCH] Skip an already finalized block in a segment (#1041) --- beacon_node/beacon_chain/src/beacon_chain.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 0d8bbb824..e76bd8daf 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -1444,6 +1444,20 @@ impl BeaconChain { 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)) => {