From 82c8e82fe1a65eddcbb24734b2f1903e872fdc45 Mon Sep 17 00:00:00 2001 From: dapplion <35266934+dapplion@users.noreply.github.com> Date: Wed, 11 Jun 2025 16:46:18 +0200 Subject: [PATCH] Re-add NoPeers error --- .../network/src/sync/backfill_sync/mod.rs | 17 +++++++++++++++++ beacon_node/network/src/sync/network_context.rs | 1 + .../block_components_by_range.rs | 8 +++++--- .../network/src/sync/range_sync/chain.rs | 2 +- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/beacon_node/network/src/sync/backfill_sync/mod.rs b/beacon_node/network/src/sync/backfill_sync/mod.rs index 70d6573264..0aaea4d65f 100644 --- a/beacon_node/network/src/sync/backfill_sync/mod.rs +++ b/beacon_node/network/src/sync/backfill_sync/mod.rs @@ -301,6 +301,14 @@ impl BackFillSync { pub fn peer_disconnected(&mut self, peer_id: &PeerId) { self.peers.write().remove(peer_id); + + if self.peers.read().is_empty() { + info!( + "reason" = "insufficient_synced_peers", + "Backfill sync paused" + ); + self.set_state(BackFillState::Paused); + } } /// An RPC error has occurred. @@ -946,6 +954,15 @@ impl BackFillSync { return Ok(()); } Err(e) => match e { + RpcRequestSendError::NoPeers => { + // If we are here the chain has no more synced peers + info!( + "reason" = "insufficient_synced_peers", + "Backfill sync paused" + ); + self.set_state(BackFillState::Paused); + return Err(BackFillError::Paused); + } RpcRequestSendError::InternalError(e) => { // NOTE: under normal conditions this shouldn't happen but we handle it anyway warn!(%batch_id, error = ?e, %batch,"Could not send batch request"); diff --git a/beacon_node/network/src/sync/network_context.rs b/beacon_node/network/src/sync/network_context.rs index f66f666842..a81591e58f 100644 --- a/beacon_node/network/src/sync/network_context.rs +++ b/beacon_node/network/src/sync/network_context.rs @@ -98,6 +98,7 @@ pub enum RpcRequestSendError { // If RpcRequestSendError has a single variant `InternalError` it's to signal to downstream // consumers that sends are expected to be infallible. If this assumption changes in the future, // add a new variant. + NoPeers, } #[derive(Debug, PartialEq, Eq)] diff --git a/beacon_node/network/src/sync/network_context/block_components_by_range.rs b/beacon_node/network/src/sync/network_context/block_components_by_range.rs index 07132f5ac1..913b798d8e 100644 --- a/beacon_node/network/src/sync/network_context/block_components_by_range.rs +++ b/beacon_node/network/src/sync/network_context/block_components_by_range.rs @@ -138,9 +138,7 @@ impl BlockComponentsByRangeRequest { else { // When a peer disconnects and is removed from the SyncingChain peer set, if the set // reaches zero the SyncingChain is removed. - return Err(RpcRequestSendError::InternalError( - "A batch peer set should never be empty".to_string(), - )); + return Err(RpcRequestSendError::NoPeers); }; let blocks_req_id = cx.send_blocks_by_range_request(block_peer, request.clone(), id)?; @@ -269,6 +267,10 @@ impl BlockComponentsByRangeRequest { RpcRequestSendError::InternalError(e) => { Error::InternalError(e) } + RpcRequestSendError::NoPeers => Error::InternalError( + "send_custody_by_range_request does not error with NoPeers" + .to_owned(), + ), })?; *state = FuluEnabledState::CustodyRequest { diff --git a/beacon_node/network/src/sync/range_sync/chain.rs b/beacon_node/network/src/sync/range_sync/chain.rs index 921d134c68..83a9dc07b7 100644 --- a/beacon_node/network/src/sync/range_sync/chain.rs +++ b/beacon_node/network/src/sync/range_sync/chain.rs @@ -957,7 +957,7 @@ impl SyncingChain { return Ok(KeepChain); } Err(e) => match e { - RpcRequestSendError::InternalError(e) => { + e @ (RpcRequestSendError::NoPeers | RpcRequestSendError::InternalError(_)) => { // NOTE: under normal conditions this shouldn't happen but we handle it anyway warn!(%batch_id, error = ?e, "batch_id" = %batch_id, %batch, "Could not send batch request"); // register the failed download and check if the batch can be retried