From 4b24c234d6709462ed2f0d08af21ce0ebd153a9a Mon Sep 17 00:00:00 2001 From: Age Manning Date: Thu, 30 Jan 2025 16:00:51 +1100 Subject: [PATCH 1/2] Potential underflow and typo --- beacon_node/network/src/sync/peer_sync_info.rs | 4 ++-- beacon_node/network/src/sync/range_sync/chain_collection.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/beacon_node/network/src/sync/peer_sync_info.rs b/beacon_node/network/src/sync/peer_sync_info.rs index c01366f1be9..5ea1533d350 100644 --- a/beacon_node/network/src/sync/peer_sync_info.rs +++ b/beacon_node/network/src/sync/peer_sync_info.rs @@ -30,8 +30,8 @@ pub fn remote_sync_type( ) -> PeerSyncType { // auxiliary variables for clarity: Inclusive boundaries of the range in which we consider a peer's // head "near" ours. - let near_range_start = local.head_slot - SLOT_IMPORT_TOLERANCE as u64; - let near_range_end = local.head_slot + SLOT_IMPORT_TOLERANCE as u64; + let near_range_start = local.head_slot.saturating_sub(SLOT_IMPORT_TOLERANCE); + let near_range_end = local.head_slot.saturating_add(SLOT_IMPORT_TOLERANCE); match remote.finalized_epoch.cmp(&local.finalized_epoch) { Ordering::Less => { diff --git a/beacon_node/network/src/sync/range_sync/chain_collection.rs b/beacon_node/network/src/sync/range_sync/chain_collection.rs index c030d0a19e8..120a7c96696 100644 --- a/beacon_node/network/src/sync/range_sync/chain_collection.rs +++ b/beacon_node/network/src/sync/range_sync/chain_collection.rs @@ -86,7 +86,7 @@ impl ChainCollection { RangeSyncState::Head(syncing_head_ids) }; } else { - // we removed a head chain, or an stoped finalized chain + // we removed a head chain, or an stopped finalized chain debug_assert!(!was_syncing || sync_type != RangeSyncType::Finalized); } } From 5b61b059220db6a477bca8909ad6310ac88d0f93 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Thu, 30 Jan 2025 16:24:49 +1100 Subject: [PATCH 2/2] Update beacon_node/network/src/sync/range_sync/chain_collection.rs --- beacon_node/network/src/sync/range_sync/chain_collection.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon_node/network/src/sync/range_sync/chain_collection.rs b/beacon_node/network/src/sync/range_sync/chain_collection.rs index 120a7c96696..16dadb36602 100644 --- a/beacon_node/network/src/sync/range_sync/chain_collection.rs +++ b/beacon_node/network/src/sync/range_sync/chain_collection.rs @@ -86,7 +86,7 @@ impl ChainCollection { RangeSyncState::Head(syncing_head_ids) }; } else { - // we removed a head chain, or an stopped finalized chain + // we removed a head chain, or a stopped finalized chain debug_assert!(!was_syncing || sync_type != RangeSyncType::Finalized); } }