Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/networking/p2p/sync_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ impl SyncManager {
}
}

/// Disables snapsync mode
pub fn disable_snap(&self) {
self.snap_enabled.store(false, Ordering::Relaxed);
}

/// Updates the last fcu head. This may be used on the next sync cycle if needed
fn set_head(&self, fcu_head: H256) {
if let Ok(mut latest_fcu_head) = self.last_fcu_head.try_lock() {
Expand Down
17 changes: 13 additions & 4 deletions crates/networking/rpc/engine/fork_choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,19 @@ async fn handle_forkchoice(
}

if context.syncer.sync_mode() == SyncMode::Snap {
context
.syncer
.sync_to_head(fork_choice_state.head_block_hash);
return Ok((None, PayloadStatus::syncing().into()));
// Don't trigger a sync if the block is already canonical
if context
.storage
.is_canonical_sync(fork_choice_state.head_block_hash)?
{
// Disable snapsync mode so we can process incoming payloads
context.syncer.disable_snap();
} else {
context
.syncer
.sync_to_head(fork_choice_state.head_block_hash);
return Ok((None, PayloadStatus::syncing().into()));
}
}

match apply_fork_choice(
Expand Down