Skip to content

Commit

Permalink
Dedup parent blob requests (#5432)
Browse files Browse the repository at this point in the history
* de dup parent blob requests

* add new line
  • Loading branch information
realbigsean authored Mar 20, 2024
1 parent eab3672 commit 4449627
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion beacon_node/network/src/sync/block_lookups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ 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(&block_root) || parent_req.is_for_block(block_root)
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
Expand Down
38 changes: 38 additions & 0 deletions beacon_node/network/src/sync/block_lookups/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,16 @@ mod deneb_only {
self.rig.expect_block_process(ResponseType::Block);
self
}
fn search_parent_dup(mut self) -> Self {
self.bl.search_parent(
self.slot,
self.block_root,
self.block.parent_root(),
self.peer_id,
&mut self.cx,
);
self
}
}

fn get_fork_name() -> ForkName {
Expand Down Expand Up @@ -2088,4 +2098,32 @@ mod deneb_only {
.expect_no_penalty()
.expect_block_process();
}

#[test]
fn unknown_parent_block_dup() {
let Some(tester) =
DenebTester::new(RequestTrigger::GossipUnknownParentBlock { num_parents: 1 })
else {
return;
};

tester
.search_parent_dup()
.expect_no_blobs_request()
.expect_no_block_request();
}

#[test]
fn unknown_parent_blob_dup() {
let Some(tester) =
DenebTester::new(RequestTrigger::GossipUnknownParentBlob { num_parents: 1 })
else {
return;
};

tester
.search_parent_dup()
.expect_no_blobs_request()
.expect_no_block_request();
}
}

0 comments on commit 4449627

Please sign in to comment.