Skip to content

Commit 0d0dc8b

Browse files
authored
Merge of #6317
2 parents e3d2d38 + bef51ed commit 0d0dc8b

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

beacon_node/network/src/sync/block_lookups/single_block_lookup.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,11 @@ impl<T: BeaconChainTypes> SingleBlockLookup<T> {
221221
// with this `req_id`.
222222
request.get_state_mut().on_download_start(req_id)?
223223
}
224-
LookupRequestResult::NoRequestNeeded => {
224+
LookupRequestResult::NoRequestNeeded(reason) => {
225225
// Lookup sync event safety: Advances this request to the terminal `Processed`
226226
// state. If all requests reach this state, the request is marked as completed
227227
// in `Self::continue_requests`.
228-
request.get_state_mut().on_completed_request()?
228+
request.get_state_mut().on_completed_request(reason)?
229229
}
230230
// Sync will receive a future event to make progress on the request, do nothing now
231231
LookupRequestResult::Pending(reason) => {
@@ -357,13 +357,13 @@ pub struct DownloadResult<T: Clone> {
357357

358358
#[derive(IntoStaticStr)]
359359
pub enum State<T: Clone> {
360-
AwaitingDownload(&'static str),
360+
AwaitingDownload(/* reason */ &'static str),
361361
Downloading(ReqId),
362362
AwaitingProcess(DownloadResult<T>),
363363
/// Request is processing, sent by lookup sync
364364
Processing(DownloadResult<T>),
365365
/// Request is processed
366-
Processed,
366+
Processed(/* reason */ &'static str),
367367
}
368368

369369
/// Object representing the state of a single block or blob lookup request.
@@ -554,7 +554,7 @@ impl<T: Clone> SingleLookupRequestState<T> {
554554
pub fn on_processing_success(&mut self) -> Result<(), LookupRequestError> {
555555
match &self.state {
556556
State::Processing(_) => {
557-
self.state = State::Processed;
557+
self.state = State::Processed("processing success");
558558
Ok(())
559559
}
560560
other => Err(LookupRequestError::BadState(format!(
@@ -564,10 +564,10 @@ impl<T: Clone> SingleLookupRequestState<T> {
564564
}
565565

566566
/// Mark a request as complete without any download or processing
567-
pub fn on_completed_request(&mut self) -> Result<(), LookupRequestError> {
567+
pub fn on_completed_request(&mut self, reason: &'static str) -> Result<(), LookupRequestError> {
568568
match &self.state {
569569
State::AwaitingDownload { .. } => {
570-
self.state = State::Processed;
570+
self.state = State::Processed(reason);
571571
Ok(())
572572
}
573573
other => Err(LookupRequestError::BadState(format!(
@@ -598,11 +598,11 @@ impl<T: Clone> std::fmt::Display for State<T> {
598598
impl<T: Clone> std::fmt::Debug for State<T> {
599599
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
600600
match self {
601-
Self::AwaitingDownload(status) => write!(f, "AwaitingDownload({:?})", status),
601+
Self::AwaitingDownload(reason) => write!(f, "AwaitingDownload({})", reason),
602602
Self::Downloading(req_id) => write!(f, "Downloading({:?})", req_id),
603603
Self::AwaitingProcess(d) => write!(f, "AwaitingProcess({:?})", d.peer_group),
604604
Self::Processing(d) => write!(f, "Processing({:?})", d.peer_group),
605-
Self::Processed { .. } => write!(f, "Processed"),
605+
Self::Processed(reason) => write!(f, "Processed({})", reason),
606606
}
607607
}
608608
}

beacon_node/network/src/sync/network_context.rs

+16-8
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,9 @@ pub enum LookupRequestResult<I = ReqId> {
145145
/// A request is sent. Sync MUST receive an event from the network in the future for either:
146146
/// completed response or failed request
147147
RequestSent(I),
148-
/// No request is sent, and no further action is necessary to consider this request completed
149-
NoRequestNeeded,
148+
/// No request is sent, and no further action is necessary to consider this request completed.
149+
/// Includes a reason why this request is not needed.
150+
NoRequestNeeded(&'static str),
150151
/// No request is sent, but the request is not completed. Sync MUST receive some future event
151152
/// that makes progress on the request. For example: request is processing from a different
152153
/// source (i.e. block received from gossip) and sync MUST receive an event with that processing
@@ -543,7 +544,9 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
543544
// Block is fully validated. If it's not yet imported it's waiting for missing block
544545
// components. Consider this request completed and do nothing.
545546
BlockProcessStatus::ExecutionValidated { .. } => {
546-
return Ok(LookupRequestResult::NoRequestNeeded)
547+
return Ok(LookupRequestResult::NoRequestNeeded(
548+
"block execution validated",
549+
))
547550
}
548551
}
549552

@@ -623,7 +626,12 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
623626

624627
// Check if we are in deneb, before peerdas and inside da window
625628
if !self.chain.should_fetch_blobs(block_epoch) {
626-
return Ok(LookupRequestResult::NoRequestNeeded);
629+
return Ok(LookupRequestResult::NoRequestNeeded("blobs not required"));
630+
}
631+
632+
// No data required for this block
633+
if expected_blobs == 0 {
634+
return Ok(LookupRequestResult::NoRequestNeeded("no data"));
627635
}
628636

629637
let imported_blob_indexes = self
@@ -638,7 +646,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
638646

639647
if indices.is_empty() {
640648
// No blobs required, do not issue any request
641-
return Ok(LookupRequestResult::NoRequestNeeded);
649+
return Ok(LookupRequestResult::NoRequestNeeded("no indices to fetch"));
642650
}
643651

644652
let req_id = self.next_id();
@@ -736,12 +744,12 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
736744

737745
// Check if we are into peerdas and inside da window
738746
if !self.chain.should_fetch_custody_columns(block_epoch) {
739-
return Ok(LookupRequestResult::NoRequestNeeded);
747+
return Ok(LookupRequestResult::NoRequestNeeded("columns not required"));
740748
}
741749

742750
// No data required for this block
743751
if expected_blobs == 0 {
744-
return Ok(LookupRequestResult::NoRequestNeeded);
752+
return Ok(LookupRequestResult::NoRequestNeeded("no data"));
745753
}
746754

747755
let custody_indexes_imported = self
@@ -760,7 +768,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
760768

761769
if custody_indexes_to_fetch.is_empty() {
762770
// No indexes required, do not issue any request
763-
return Ok(LookupRequestResult::NoRequestNeeded);
771+
return Ok(LookupRequestResult::NoRequestNeeded("no indices to fetch"));
764772
}
765773

766774
let req_id = self.next_id();

beacon_node/network/src/sync/network_context/custody.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ impl<T: BeaconChainTypes> ActiveCustodyRequest<T> {
296296
self.active_batch_columns_requests
297297
.insert(req_id, ActiveBatchColumnsRequest { indices, peer_id });
298298
}
299-
LookupRequestResult::NoRequestNeeded => unreachable!(),
299+
LookupRequestResult::NoRequestNeeded(_) => unreachable!(),
300300
LookupRequestResult::Pending(_) => unreachable!(),
301301
}
302302
}

0 commit comments

Comments
 (0)