diff --git a/crates/blockchain-tree/src/blockchain_tree.rs b/crates/blockchain-tree/src/blockchain_tree.rs index 7f58c2a0b..bd1d72c97 100644 --- a/crates/blockchain-tree/src/blockchain_tree.rs +++ b/crates/blockchain-tree/src/blockchain_tree.rs @@ -298,7 +298,7 @@ impl BlockchainTree { let parent = block.parent_num_hash(); - // check if block parent can be found in Tree + // check if block parent can be found in any side chain. if let Some(chain_id) = self.block_indices().get_blocks_chain_id(&parent.hash) { // found parent in side tree, try to insert there return self.try_insert_block_into_side_chain(block, chain_id, block_validation_kind) @@ -917,6 +917,7 @@ impl BlockchainTree { // If block is already canonical don't return error. if let Some(header) = self.find_canonical_header(block_hash)? { info!(target: "blockchain_tree", ?block_hash, "Block is already canonical, ignoring."); + // TODO: this could be fetched from the chainspec first let td = self.externals.database().provider()?.header_td(block_hash)?.ok_or( CanonicalError::from(BlockValidationError::MissingTotalDifficulty { hash: *block_hash, diff --git a/crates/consensus/beacon/src/engine/mod.rs b/crates/consensus/beacon/src/engine/mod.rs index 641376824..54e98eb8a 100644 --- a/crates/consensus/beacon/src/engine/mod.rs +++ b/crates/consensus/beacon/src/engine/mod.rs @@ -632,8 +632,9 @@ where return Ok(OnForkChoiceUpdated::invalid_state()) } + // check if the new head hash is connected to any ancestor that we previously marked as + // invalid let lowest_buffered_ancestor_fcu = self.lowest_buffered_ancestor_or(state.head_block_hash); - if let Some(status) = self.check_invalid_ancestor(lowest_buffered_ancestor_fcu) { return Ok(OnForkChoiceUpdated::with_invalid(status)) } @@ -659,6 +660,7 @@ where let start = Instant::now(); let make_canonical_result = self.blockchain.make_canonical(&state.head_block_hash); let elapsed = self.record_make_canonical_latency(start, &make_canonical_result); + let status = match make_canonical_result { Ok(outcome) => { match outcome {