diff --git a/beacon_node/network/src/sync/block_lookups/mod.rs b/beacon_node/network/src/sync/block_lookups/mod.rs index 4a0f26bba5..86f1694342 100644 --- a/beacon_node/network/src/sync/block_lookups/mod.rs +++ b/beacon_node/network/src/sync/block_lookups/mod.rs @@ -450,17 +450,6 @@ impl BlockLookups { debug!(?id, "Block returned for single block lookup not present"); return; }; - let block_root = lookup.block_root(); - // The downstream state machine only needs success / failure: details about RPC - // failures (peer info, error category) are logged here before being collapsed, so - // debugging still has the full context. - let response = match response { - Ok(ok) => Ok(ok), - Err(err) => { - debug!(?block_root, ?id, ?err, "Block download failed"); - Err(()) - } - }; let result = lookup.on_block_download_response(id.req_id, response, cx); self.on_lookup_result(id.lookup_id, result, "block_download_response", cx); } @@ -475,14 +464,6 @@ impl BlockLookups { debug!(?id, "Blob returned for single block lookup not present"); return; }; - let block_root = lookup.block_root(); - let response = match response { - Ok(ok) => Ok(ok), - Err(err) => { - debug!(?block_root, ?id, ?err, "Blob download failed"); - Err(()) - } - }; let result = lookup.on_blob_download_response(id.req_id, response, cx); self.on_lookup_result(id.lookup_id, result, "blob_download_response", cx); } @@ -497,14 +478,6 @@ impl BlockLookups { debug!(?id, "Custody returned for single block lookup not present"); return; }; - let block_root = lookup.block_root(); - let response = match response { - Ok(ok) => Ok(ok), - Err(err) => { - debug!(?block_root, ?id, ?err, "Custody download failed"); - Err(()) - } - }; let result = lookup.on_custody_download_response(id.req_id, response, cx); self.on_lookup_result(id.lookup_id, result, "custody_download_response", cx); } @@ -522,14 +495,6 @@ impl BlockLookups { ); return; }; - let block_root = lookup.block_root(); - let response = match response { - Ok(ok) => Ok(ok), - Err(err) => { - debug!(?block_root, ?id, ?err, "Payload envelope download failed"); - Err(()) - } - }; let result = lookup.on_payload_download_response(id.req_id, response, cx); self.on_lookup_result(id.lookup_id, result, "payload_download_response", cx); } @@ -539,7 +504,7 @@ impl BlockLookups { pub fn peer_disconnected(&mut self, peer_id: &PeerId) { for (id, lookup) in self.single_block_lookups.iter_mut() { lookup.remove_peer(peer_id); - if lookup.has_no_peers() { + if !lookup.has_peers() { debug!(%id, "Lookup has no peers"); } } @@ -901,7 +866,7 @@ impl BlockLookups { .filter(|lookup| { // Do not drop lookup that are awaiting events to prevent inconsinstencies. If a // lookup gets stuck, it will be eventually pruned by `drop_stuck_lookups` - lookup.has_no_peers() + !lookup.has_peers() && lookup.elapsed_since_created() > Duration::from_secs(LOOKUP_MAX_DURATION_NO_PEERS_SECS) && !lookup.is_awaiting_event() diff --git a/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs b/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs index cdcd470ac0..f20db7b23a 100644 --- a/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs +++ b/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs @@ -1,8 +1,11 @@ use super::{BlockComponent, PeerId, SINGLE_BLOCK_LOOKUP_MAX_ATTEMPTS}; +use crate::sync::block_lookups::{ + BlobDownloadResponse, BlockDownloadResponse, CustodyDownloadResponse, PayloadDownloadResponse, +}; use crate::sync::manager::BlockProcessType; use crate::sync::network_context::{ - LookupRequestResult, PeerGroup, ReqId, RpcRequestSendError, SendErrorProcessor, - SyncNetworkContext, + LookupRequestResult, PeerGroup, ReqId, RpcRequestSendError, RpcResponseError, + SendErrorProcessor, SyncNetworkContext, }; use beacon_chain::BeaconChainTypes; use beacon_chain::BlockProcessStatus; @@ -1018,11 +1021,10 @@ impl SingleBlockLookup { // -- Download response handlers -- /// Handle a block download response. Updates download state and advances the lookup. - #[allow(clippy::type_complexity)] pub fn on_block_download_response( &mut self, req_id: ReqId, - result: Result<(Arc>, PeerGroup, Duration), ()>, + result: BlockDownloadResponse, cx: &mut SyncNetworkContext, ) -> Result { let BlockRequest::Downloading { state, .. } = &mut self.block_request else { @@ -1038,7 +1040,7 @@ impl SingleBlockLookup { pub fn on_blob_download_response( &mut self, req_id: ReqId, - result: Result<(FixedBlobSidecarList, PeerGroup, Duration), ()>, + result: BlobDownloadResponse, cx: &mut SyncNetworkContext, ) -> Result { let Some(DataRequest { @@ -1058,7 +1060,7 @@ impl SingleBlockLookup { pub fn on_custody_download_response( &mut self, req_id: ReqId, - result: Result<(DataColumnSidecarList, PeerGroup, Duration), ()>, + result: CustodyDownloadResponse, cx: &mut SyncNetworkContext, ) -> Result { let Some(DataRequest { @@ -1075,18 +1077,10 @@ impl SingleBlockLookup { } /// Handle a payload envelope download response. Updates download state and advances the lookup. - #[allow(clippy::type_complexity)] pub fn on_payload_download_response( &mut self, req_id: ReqId, - result: Result< - ( - Arc>, - PeerGroup, - Duration, - ), - (), - >, + result: PayloadDownloadResponse, cx: &mut SyncNetworkContext, ) -> Result { let Some(PayloadRequest { @@ -1142,8 +1136,14 @@ impl SingleBlockLookup { } /// Returns true if this lookup has zero peers - pub fn has_no_peers(&self) -> bool { - self.peers.read().is_empty() + pub fn has_peers(&self) -> bool { + if !self.peers.read().is_empty() { + return true; + } + + let gloas_child_peers = self.gloas_child_peers.read(); + !gloas_child_peers.is_empty() + && gloas_child_peers.values().any(|set| !set.read().is_empty()) } } @@ -1273,7 +1273,7 @@ impl SingleLookupRequestState { &mut self, req_id: ReqId, block_root: Hash256, - result: Result<(T, PeerGroup, Duration), ()>, + result: Result<(T, PeerGroup, Duration), RpcResponseError>, ) -> Result<(), LookupRequestError> { match result { Ok((value, peer_group, seen_timestamp)) => self.on_download_success( @@ -1285,7 +1285,7 @@ impl SingleLookupRequestState { peer_group, }, ), - Err(()) => self.on_download_failure(req_id), + Err(_) => self.on_download_failure(req_id), } }