Dedup parent blob requests (#5432)

* de dup parent blob requests

* add new line
This commit is contained in:
realbigsean 2024-03-19 20:19:26 -04:00 committed by GitHub
parent eab3672c6d
commit 4449627c7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 1 deletions

View File

@ -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

View File

@ -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();
}
}