Skip to content
Closed
Show file tree
Hide file tree
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
19 changes: 16 additions & 3 deletions beacon_node/network/src/sync/block_lookups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
if let Some(components) = child_components {
lookup.add_child_components(components);
}
debug!(self.log, "Already searching for block"; "block_root" => ?block_root);
return;
}

Expand All @@ -162,6 +163,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {

// If the block was already downloaded, or is being downloaded in this moment, do not
// request it.
debug!(self.log, "Already searching for block in a parent lookup request"; "block_root" => ?block_root);
return;
}

Expand All @@ -171,6 +173,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
.any(|(hashes, _last_parent_request)| hashes.contains(&block_root))
{
// we are already processing this block, ignore it.
debug!(self.log, "Already processing block in a parent from request"; "block_root" => ?block_root);
return;
}

Expand Down Expand Up @@ -217,19 +220,29 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
// Make sure this block is not already downloaded, and that neither it or its parent is
// being searched for.
if let Some(parent_lookup) = self.parent_lookups.iter_mut().find(|parent_req| {
parent_req.contains_block(&parent_root) || parent_req.is_for_block(parent_root)
block_root == parent_req.chain_hash()
|| parent_req.contains_block(&parent_root)
|| parent_req.is_for_block(parent_root)
}) {
parent_lookup.add_peer(peer_id);
// we are already searching for this block, ignore it
debug!(self.log, "Already searching for parent block";
"block_root" => ?block_root, "parent_root" => ?parent_root);
return;
}

if self
.processing_parent_lookups
.values()
.any(|(hashes, _peers)| hashes.contains(&block_root) || hashes.contains(&parent_root))
.iter()
.any(|(chain_hash, (hashes, _peers))| {
chain_hash == &block_root
|| hashes.contains(&block_root)
|| hashes.contains(&parent_root)
})
{
// we are already processing this block, ignore it.
debug!(self.log, "Already processing parent block";
"block_root" => ?block_root, "parent_root" => ?parent_root);
return;
}
let parent_lookup = ParentLookup::new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ impl<L: Lookup, T: BeaconChainTypes> SingleBlockLookup<L, T> {
/// of which blobs still need to be requested. Returns `true` if there are no more blobs to
/// request.
pub(crate) fn blobs_already_downloaded(&mut self) -> bool {
self.update_blobs_request();
if matches!(self.blob_request_state.state.state, State::AwaitingDownload) {
self.update_blobs_request();
}
self.blob_request_state.requested_ids.is_empty()
}

Expand Down
46 changes: 28 additions & 18 deletions beacon_node/network/src/sync/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,27 +831,37 @@ impl<T: BeaconChainTypes> SyncManager<T> {
seen_timestamp: Duration,
) {
match request_id {
RequestId::SingleBlock { id } => self
.block_lookups
.single_lookup_response::<BlockRequestState<Current>>(
id,
peer_id,
block,
seen_timestamp,
&self.network,
),
RequestId::SingleBlock { id } => {
debug!(self.log,
"Peer returned block for single lookup";
"peer_id" => %peer_id ,
);
self.block_lookups
.single_lookup_response::<BlockRequestState<Current>>(
id,
peer_id,
block,
seen_timestamp,
&self.network,
)
}
RequestId::SingleBlob { .. } => {
crit!(self.log, "Block received during blob request"; "peer_id" => %peer_id );
}
RequestId::ParentLookup { id } => self
.block_lookups
.parent_lookup_response::<BlockRequestState<Parent>>(
id,
peer_id,
block,
seen_timestamp,
&self.network,
),
RequestId::ParentLookup { id } => {
debug!(self.log,
"Peer returned block for single lookup";
"peer_id" => %peer_id ,
);
self.block_lookups
.parent_lookup_response::<BlockRequestState<Parent>>(
id,
peer_id,
block,
seen_timestamp,
&self.network,
)
}
RequestId::ParentLookupBlob { id: _ } => {
crit!(self.log, "Block received during parent blob request"; "peer_id" => %peer_id );
}
Expand Down