Skip to content

Commit

Permalink
Skip creating child lookup if parent is never created (sigp#5803)
Browse files Browse the repository at this point in the history
* Skip creating child lookup if parent is never created
  • Loading branch information
dapplion authored May 17, 2024
1 parent 0f49951 commit 319b4a2
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions beacon_node/network/src/sync/block_lookups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,12 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
};

let result = lookup.continue_requests(cx);
self.on_lookup_result(id, result, "new_current_lookup", cx);
self.update_metrics();
true
if self.on_lookup_result(id, result, "new_current_lookup", cx) {
self.update_metrics();
true
} else {
false
}
}

/* Lookup responses */
Expand Down Expand Up @@ -622,15 +625,16 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
}

/// Common handler a lookup request error, drop it and update metrics
/// Returns true if the lookup is created or already exists
fn on_lookup_result(
&mut self,
id: SingleLookupId,
result: Result<LookupResult, LookupRequestError>,
source: &str,
cx: &mut SyncNetworkContext<T>,
) {
) -> bool {
match result {
Ok(LookupResult::Pending) => {} // no action
Ok(LookupResult::Pending) => true, // no action
Ok(LookupResult::Completed) => {
if let Some(lookup) = self.single_block_lookups.remove(&id) {
debug!(self.log, "Dropping completed lookup"; "block" => ?lookup.block_root(), "id" => id);
Expand All @@ -641,12 +645,14 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
} else {
debug!(self.log, "Attempting to drop non-existent lookup"; "id" => id);
}
false
}
Err(error) => {
debug!(self.log, "Dropping lookup on request error"; "id" => id, "source" => source, "error" => ?error);
metrics::inc_counter_vec(&metrics::SYNC_LOOKUP_DROPPED, &[error.into()]);
self.drop_lookup_and_children(id);
self.update_metrics();
false
}
}
}
Expand Down

0 comments on commit 319b4a2

Please sign in to comment.