From c0678b06a5ab2145db4d5e450747092ed7d62b71 Mon Sep 17 00:00:00 2001 From: Povilas Liubauskas Date: Wed, 22 Jan 2025 14:57:30 +0200 Subject: [PATCH] Stricter sync status check for remote peers: use the same criteria as checking if beacon node is forward synced --- p2p/src/network.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/p2p/src/network.rs b/p2p/src/network.rs index 63e520fd..725f31d6 100644 --- a/p2p/src/network.rs +++ b/p2p/src/network.rs @@ -1619,7 +1619,17 @@ impl Network

{ let (local_finalized_root_at_remote_finalized_epoch, sync_status) = match local.finalized_epoch.cmp(&remote.finalized_epoch) { Ordering::Less => (None, SyncStatus::Advanced { info }), - Ordering::Equal => (Some(local.finalized_root), SyncStatus::Synced { info }), + Ordering::Equal => { + let max_empty_slots = self.controller.store_config().max_empty_slots; + + let status = if remote.head_slot + max_empty_slots < local.head_slot { + SyncStatus::Behind { info } + } else { + SyncStatus::Synced { info } + }; + + (Some(local.finalized_root), status) + } Ordering::Greater => { let remote_finalized_slot = Self::start_of_epoch(remote.finalized_epoch);