Skip to content

Commit c0678b0

Browse files
committed
Stricter sync status check for remote peers: use the same criteria as checking if beacon node is forward synced
1 parent d556ebf commit c0678b0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

p2p/src/network.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,17 @@ impl<P: Preset> Network<P> {
16191619
let (local_finalized_root_at_remote_finalized_epoch, sync_status) =
16201620
match local.finalized_epoch.cmp(&remote.finalized_epoch) {
16211621
Ordering::Less => (None, SyncStatus::Advanced { info }),
1622-
Ordering::Equal => (Some(local.finalized_root), SyncStatus::Synced { info }),
1622+
Ordering::Equal => {
1623+
let max_empty_slots = self.controller.store_config().max_empty_slots;
1624+
1625+
let status = if remote.head_slot + max_empty_slots < local.head_slot {
1626+
SyncStatus::Behind { info }
1627+
} else {
1628+
SyncStatus::Synced { info }
1629+
};
1630+
1631+
(Some(local.finalized_root), status)
1632+
}
16231633
Ordering::Greater => {
16241634
let remote_finalized_slot = Self::start_of_epoch(remote.finalized_epoch);
16251635

0 commit comments

Comments
 (0)