Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip creating child lookup if parent is never created #5803

Merged
merged 1 commit into from
May 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading