diff --git a/beacon_node/network/src/status.rs b/beacon_node/network/src/status.rs index 3f573b85ed7..fa52fddc36c 100644 --- a/beacon_node/network/src/status.rs +++ b/beacon_node/network/src/status.rs @@ -28,6 +28,6 @@ impl ToStatusMessage for BeaconChain { impl ToStatusMessage for Arc> { fn status_message(&self) -> Result { - as ToStatusMessage>::status_message(&self) + as ToStatusMessage>::status_message(self) } } 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 2f73fc1ecba..4dc9c1d01cc 100644 --- a/beacon_node/network/src/sync/range_sync/chain_collection.rs +++ b/beacon_node/network/src/sync/range_sync/chain_collection.rs @@ -72,7 +72,7 @@ impl ChainCollection { RangeSyncState::Finalized(ref syncing_id) => { if syncing_id == id { // the finalized chain that was syncing was removed - debug_assert!(was_syncing); + debug_assert!(was_syncing && sync_type == RangeSyncType::Finalized); let syncing_head_ids: SmallVec<[u64; PARALLEL_HEAD_CHAINS]> = self .head_chains .iter() @@ -85,7 +85,8 @@ impl ChainCollection { RangeSyncState::Head(syncing_head_ids) }; } else { - debug_assert!(!was_syncing); + // we removed a head chain, or an stoped finalized chain + debug_assert!(!was_syncing || sync_type != RangeSyncType::Finalized); } } RangeSyncState::Head(ref mut syncing_head_ids) => { diff --git a/beacon_node/network/src/sync/range_sync/mod.rs b/beacon_node/network/src/sync/range_sync/mod.rs index ef1eafa6258..b4a27c23c7a 100644 --- a/beacon_node/network/src/sync/range_sync/mod.rs +++ b/beacon_node/network/src/sync/range_sync/mod.rs @@ -2,11 +2,11 @@ //! peers. mod batch; +mod block_storage; mod chain; mod chain_collection; mod range; mod sync_type; -mod block_storage; pub use batch::{BatchConfig, BatchInfo, BatchState}; pub use chain::{BatchId, ChainId, EPOCHS_PER_BATCH}; diff --git a/beacon_node/network/src/sync/range_sync/range.rs b/beacon_node/network/src/sync/range_sync/range.rs index 7d6a65a1da9..2786ef410d5 100644 --- a/beacon_node/network/src/sync/range_sync/range.rs +++ b/beacon_node/network/src/sync/range_sync/range.rs @@ -430,6 +430,7 @@ mod tests { } } + #[allow(unused)] struct TestRig { log: slog::Logger, /// To check what does sync send to the beacon processor. @@ -589,7 +590,8 @@ mod tests { } #[test] - fn sync() { + fn head_chain_removed_while_finalized_syncing() { + // NOTE: this is a regression test. let (mut rig, mut range) = range(true); // Get a peer with an advanced head @@ -610,5 +612,6 @@ mod tests { // Fail the head chain by disconnecting the peer. range.remove_peer(&mut rig.cx, &head_peer); + range.assert_state(RangeSyncType::Finalized); } }