From 4449627c7c6dd20e3d923b4eaafee6e82f919968 Mon Sep 17 00:00:00 2001 From: realbigsean Date: Tue, 19 Mar 2024 20:19:26 -0400 Subject: [PATCH] Dedup parent blob requests (#5432) * de dup parent blob requests * add new line --- .../network/src/sync/block_lookups/mod.rs | 2 +- .../network/src/sync/block_lookups/tests.rs | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/beacon_node/network/src/sync/block_lookups/mod.rs b/beacon_node/network/src/sync/block_lookups/mod.rs index 62cdc4fa2..2327abc61 100644 --- a/beacon_node/network/src/sync/block_lookups/mod.rs +++ b/beacon_node/network/src/sync/block_lookups/mod.rs @@ -217,7 +217,7 @@ impl BlockLookups { // 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 diff --git a/beacon_node/network/src/sync/block_lookups/tests.rs b/beacon_node/network/src/sync/block_lookups/tests.rs index c506696b9..d327c5c90 100644 --- a/beacon_node/network/src/sync/block_lookups/tests.rs +++ b/beacon_node/network/src/sync/block_lookups/tests.rs @@ -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 { @@ -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(); + } }