Skip to content

Commit b9698cf

Browse files
authored
Merge of #5418
2 parents 02b35c8 + 7516afe commit b9698cf

File tree

3 files changed

+12
-46
lines changed

3 files changed

+12
-46
lines changed

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2892,7 +2892,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
28922892
}
28932893

28942894
self.data_availability_checker
2895-
.notify_gossip_blob(blob.slot(), block_root, &blob);
2895+
.notify_gossip_blob(block_root, &blob);
28962896
let r = self.check_gossip_blob_availability_and_import(blob).await;
28972897
self.remove_notified(&block_root, r)
28982898
}
@@ -2926,7 +2926,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
29262926
}
29272927

29282928
self.data_availability_checker
2929-
.notify_rpc_blobs(slot, block_root, &blobs);
2929+
.notify_rpc_blobs(block_root, &blobs);
29302930
let r = self
29312931
.check_rpc_blob_availability_and_import(slot, block_root, blobs)
29322932
.await;

beacon_node/beacon_chain/src/data_availability_checker.rs

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::sync::Arc;
2222
use task_executor::TaskExecutor;
2323
use types::beacon_block_body::KzgCommitmentOpts;
2424
use types::blob_sidecar::{BlobIdentifier, BlobSidecar, FixedBlobSidecarList};
25-
use types::{BlobSidecarList, ChainSpec, Epoch, EthSpec, Hash256, SignedBeaconBlock, Slot};
25+
use types::{BlobSidecarList, ChainSpec, Epoch, EthSpec, Hash256, SignedBeaconBlock};
2626

2727
mod availability_view;
2828
mod child_components;
@@ -356,41 +356,30 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
356356
/// them here is useful to avoid duplicate downloads of blocks, as well as understanding
357357
/// our blob download requirements. We will also serve this over RPC.
358358
pub fn notify_block(&self, block_root: Hash256, block: Arc<SignedBeaconBlock<T::EthSpec>>) {
359-
let slot = block.slot();
360359
self.processing_cache
361360
.write()
362361
.entry(block_root)
363-
.or_insert_with(|| ProcessingComponents::new(slot))
362+
.or_default()
364363
.merge_block(block);
365364
}
366365

367366
/// Add a single blob commitment to the processing cache. This commitment is unverified but caching
368367
/// them here is useful to avoid duplicate downloads of blobs, as well as understanding
369368
/// our block and blob download requirements.
370-
pub fn notify_gossip_blob(
371-
&self,
372-
slot: Slot,
373-
block_root: Hash256,
374-
blob: &GossipVerifiedBlob<T>,
375-
) {
369+
pub fn notify_gossip_blob(&self, block_root: Hash256, blob: &GossipVerifiedBlob<T>) {
376370
let index = blob.index();
377371
let commitment = blob.kzg_commitment();
378372
self.processing_cache
379373
.write()
380374
.entry(block_root)
381-
.or_insert_with(|| ProcessingComponents::new(slot))
375+
.or_default()
382376
.merge_single_blob(index as usize, commitment);
383377
}
384378

385379
/// Adds blob commitments to the processing cache. These commitments are unverified but caching
386380
/// them here is useful to avoid duplicate downloads of blobs, as well as understanding
387381
/// our block and blob download requirements.
388-
pub fn notify_rpc_blobs(
389-
&self,
390-
slot: Slot,
391-
block_root: Hash256,
392-
blobs: &FixedBlobSidecarList<T::EthSpec>,
393-
) {
382+
pub fn notify_rpc_blobs(&self, block_root: Hash256, blobs: &FixedBlobSidecarList<T::EthSpec>) {
394383
let mut commitments = KzgCommitmentOpts::<T::EthSpec>::default();
395384
for blob in blobs.iter().flatten() {
396385
if let Some(commitment) = commitments.get_mut(blob.index as usize) {
@@ -400,7 +389,7 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
400389
self.processing_cache
401390
.write()
402391
.entry(block_root)
403-
.or_insert_with(|| ProcessingComponents::new(slot))
392+
.or_default()
404393
.merge_blobs(commitments);
405394
}
406395

@@ -409,14 +398,6 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
409398
self.processing_cache.write().remove(block_root)
410399
}
411400

412-
/// Gather all block roots for which we are not currently processing all components for the
413-
/// given slot.
414-
pub fn incomplete_processing_components(&self, slot: Slot) -> Vec<Hash256> {
415-
self.processing_cache
416-
.read()
417-
.incomplete_processing_components(slot)
418-
}
419-
420401
/// The epoch at which we require a data availability check in block processing.
421402
/// `None` if the `Deneb` fork is disabled.
422403
pub fn data_availability_boundary(&self) -> Option<Epoch> {

beacon_node/beacon_chain/src/data_availability_checker/processing_cache.rs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::collections::hash_map::Entry;
33
use std::collections::HashMap;
44
use std::sync::Arc;
55
use types::beacon_block_body::KzgCommitmentOpts;
6-
use types::{EthSpec, Hash256, SignedBeaconBlock, Slot};
6+
use types::{EthSpec, Hash256, SignedBeaconBlock};
77

88
/// This cache is used only for gossip blocks/blobs and single block/blob lookups, to give req/resp
99
/// a view of what we have and what we require. This cache serves a slightly different purpose than
@@ -29,23 +29,13 @@ impl<E: EthSpec> ProcessingCache<E> {
2929
.get(block_root)
3030
.map_or(false, |b| b.block_exists())
3131
}
32-
pub fn incomplete_processing_components(&self, slot: Slot) -> Vec<Hash256> {
33-
let mut roots_missing_components = vec![];
34-
for (&block_root, info) in self.processing_cache.iter() {
35-
if info.slot == slot && !info.is_available() {
36-
roots_missing_components.push(block_root);
37-
}
38-
}
39-
roots_missing_components
40-
}
4132
pub fn len(&self) -> usize {
4233
self.processing_cache.len()
4334
}
4435
}
4536

46-
#[derive(Debug, Clone)]
37+
#[derive(Default, Debug, Clone)]
4738
pub struct ProcessingComponents<E: EthSpec> {
48-
slot: Slot,
4939
/// Blobs required for a block can only be known if we have seen the block. So `Some` here
5040
/// means we've seen it, a `None` means we haven't. The `kzg_commitments` value helps us figure
5141
/// out whether incoming blobs actually match the block.
@@ -56,12 +46,8 @@ pub struct ProcessingComponents<E: EthSpec> {
5646
}
5747

5848
impl<E: EthSpec> ProcessingComponents<E> {
59-
pub fn new(slot: Slot) -> Self {
60-
Self {
61-
slot,
62-
block: None,
63-
blob_commitments: KzgCommitmentOpts::<E>::default(),
64-
}
49+
pub fn new() -> Self {
50+
Self::default()
6551
}
6652
}
6753

@@ -70,7 +56,6 @@ impl<E: EthSpec> ProcessingComponents<E> {
7056
impl<E: EthSpec> ProcessingComponents<E> {
7157
pub fn empty(_block_root: Hash256) -> Self {
7258
Self {
73-
slot: Slot::new(0),
7459
block: None,
7560
blob_commitments: KzgCommitmentOpts::<E>::default(),
7661
}

0 commit comments

Comments
 (0)