mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 05:14:35 +00:00
Notify lookup sync of gossip processing results (#5722)
* Notify lookup sync of gossip processing results * Add tests * Add GossipBlockProcessResult event * Re-add dropped comments * Update beacon_node/network/src/network_beacon_processor/sync_methods.rs * update test_lookup_disconnection_peer_left
This commit is contained in:
@@ -408,7 +408,10 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
||||
self.on_processing_result_inner::<BlobRequestState<T::EthSpec>>(id, result, cx)
|
||||
}
|
||||
};
|
||||
self.on_lookup_result(process_type.id(), lookup_result, "processing_result", cx);
|
||||
let id = match process_type {
|
||||
BlockProcessType::SingleBlock { id } | BlockProcessType::SingleBlob { id } => id,
|
||||
};
|
||||
self.on_lookup_result(id, lookup_result, "processing_result", cx);
|
||||
}
|
||||
|
||||
pub fn on_processing_result_inner<R: RequestState<T>>(
|
||||
@@ -521,6 +524,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
||||
}
|
||||
other => {
|
||||
debug!(self.log, "Invalid lookup component"; "block_root" => ?block_root, "component" => ?R::response_type(), "error" => ?other);
|
||||
|
||||
let peer_id = request_state.on_processing_failure()?;
|
||||
cx.report_peer(
|
||||
peer_id,
|
||||
@@ -561,6 +565,30 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn on_external_processing_result(
|
||||
&mut self,
|
||||
block_root: Hash256,
|
||||
imported: bool,
|
||||
cx: &mut SyncNetworkContext<T>,
|
||||
) {
|
||||
let Some((id, lookup)) = self
|
||||
.single_block_lookups
|
||||
.iter_mut()
|
||||
.find(|(_, lookup)| lookup.is_for_block(block_root))
|
||||
else {
|
||||
// Ok to ignore gossip process events
|
||||
return;
|
||||
};
|
||||
|
||||
let lookup_result = if imported {
|
||||
Ok(LookupResult::Completed)
|
||||
} else {
|
||||
lookup.continue_requests(cx)
|
||||
};
|
||||
let id = *id;
|
||||
self.on_lookup_result(id, lookup_result, "external_processing_result", cx);
|
||||
}
|
||||
|
||||
/// Makes progress on the immediate children of `block_root`
|
||||
pub fn continue_child_lookups(&mut self, block_root: Hash256, cx: &mut SyncNetworkContext<T>) {
|
||||
let mut lookup_results = vec![]; // < need to buffer lookup results to not re-borrow &mut self
|
||||
|
||||
Reference in New Issue
Block a user