diff --git a/crates/consensus/beacon/src/engine/forkchoice.rs b/crates/consensus/beacon/src/engine/forkchoice.rs index 8332ea030841..f41200e39615 100644 --- a/crates/consensus/beacon/src/engine/forkchoice.rs +++ b/crates/consensus/beacon/src/engine/forkchoice.rs @@ -18,7 +18,8 @@ pub(crate) struct ForkchoiceStateTracker { impl ForkchoiceStateTracker { /// Sets the latest forkchoice state that we received. /// - /// If the status is valid, we also update the last valid forkchoice state. + /// If the status is `VALID`, we also update the last valid forkchoice state and set the + /// `sync_target` to `None`, since we're now fully synced. pub(crate) fn set_latest(&mut self, state: ForkchoiceState, status: ForkchoiceStatus) { if status.is_valid() { self.set_valid(state); diff --git a/crates/consensus/beacon/src/engine/mod.rs b/crates/consensus/beacon/src/engine/mod.rs index 70e9fc00722a..41e993ec95c6 100644 --- a/crates/consensus/beacon/src/engine/mod.rs +++ b/crates/consensus/beacon/src/engine/mod.rs @@ -824,6 +824,7 @@ where Err(status) => return Ok(status), }; let block_hash = block.hash(); + let block_num_hash = block.num_hash(); // now check the block itself if let Some(status) = self.check_invalid_ancestor_with_head(block.parent_hash, block.hash) { @@ -841,6 +842,13 @@ where let status = match res { Ok(status) => { if status.is_valid() { + if let Some(target) = self.forkchoice_state_tracker.sync_target_state() { + // if we're currently syncing and the inserted block is the targeted FCU + // head block, we can try to make it canonical. + if block_hash == target.head_block_hash { + self.try_make_sync_target_canonical(block_num_hash); + } + } // block was successfully inserted, so we can cancel the full block request, if // any exists self.sync.cancel_full_block_request(block_hash);