From 306d3eb0eb0005eb25e6f37acfb0d6616ebe9e1f Mon Sep 17 00:00:00 2001 From: Lion - dapplion <35266934+dapplion@users.noreply.github.com> Date: Sat, 23 Mar 2024 09:00:35 +0900 Subject: [PATCH] Delete unused incomplete_processing_components (#5418) * Delete unused incomplete_processing_components * lint --- beacon_node/beacon_chain/src/beacon_chain.rs | 4 +-- .../src/data_availability_checker.rs | 31 ++++--------------- .../processing_cache.rs | 23 +++----------- 3 files changed, 12 insertions(+), 46 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 534cffae1..1313cf7ec 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -2891,7 +2891,7 @@ impl BeaconChain { } self.data_availability_checker - .notify_gossip_blob(blob.slot(), block_root, &blob); + .notify_gossip_blob(block_root, &blob); let r = self.check_gossip_blob_availability_and_import(blob).await; self.remove_notified(&block_root, r) } @@ -2925,7 +2925,7 @@ impl BeaconChain { } self.data_availability_checker - .notify_rpc_blobs(slot, block_root, &blobs); + .notify_rpc_blobs(block_root, &blobs); let r = self .check_rpc_blob_availability_and_import(slot, block_root, blobs) .await; diff --git a/beacon_node/beacon_chain/src/data_availability_checker.rs b/beacon_node/beacon_chain/src/data_availability_checker.rs index f906032ec..a578c484e 100644 --- a/beacon_node/beacon_chain/src/data_availability_checker.rs +++ b/beacon_node/beacon_chain/src/data_availability_checker.rs @@ -22,7 +22,7 @@ use std::sync::Arc; use task_executor::TaskExecutor; use types::beacon_block_body::KzgCommitmentOpts; use types::blob_sidecar::{BlobIdentifier, BlobSidecar, FixedBlobSidecarList}; -use types::{BlobSidecarList, ChainSpec, Epoch, EthSpec, Hash256, SignedBeaconBlock, Slot}; +use types::{BlobSidecarList, ChainSpec, Epoch, EthSpec, Hash256, SignedBeaconBlock}; mod availability_view; mod child_components; @@ -356,41 +356,30 @@ impl DataAvailabilityChecker { /// them here is useful to avoid duplicate downloads of blocks, as well as understanding /// our blob download requirements. We will also serve this over RPC. pub fn notify_block(&self, block_root: Hash256, block: Arc>) { - let slot = block.slot(); self.processing_cache .write() .entry(block_root) - .or_insert_with(|| ProcessingComponents::new(slot)) + .or_default() .merge_block(block); } /// Add a single blob commitment to the processing cache. This commitment is unverified but caching /// them here is useful to avoid duplicate downloads of blobs, as well as understanding /// our block and blob download requirements. - pub fn notify_gossip_blob( - &self, - slot: Slot, - block_root: Hash256, - blob: &GossipVerifiedBlob, - ) { + pub fn notify_gossip_blob(&self, block_root: Hash256, blob: &GossipVerifiedBlob) { let index = blob.index(); let commitment = blob.kzg_commitment(); self.processing_cache .write() .entry(block_root) - .or_insert_with(|| ProcessingComponents::new(slot)) + .or_default() .merge_single_blob(index as usize, commitment); } /// Adds blob commitments to the processing cache. These commitments are unverified but caching /// them here is useful to avoid duplicate downloads of blobs, as well as understanding /// our block and blob download requirements. - pub fn notify_rpc_blobs( - &self, - slot: Slot, - block_root: Hash256, - blobs: &FixedBlobSidecarList, - ) { + pub fn notify_rpc_blobs(&self, block_root: Hash256, blobs: &FixedBlobSidecarList) { let mut commitments = KzgCommitmentOpts::::default(); for blob in blobs.iter().flatten() { if let Some(commitment) = commitments.get_mut(blob.index as usize) { @@ -400,7 +389,7 @@ impl DataAvailabilityChecker { self.processing_cache .write() .entry(block_root) - .or_insert_with(|| ProcessingComponents::new(slot)) + .or_default() .merge_blobs(commitments); } @@ -409,14 +398,6 @@ impl DataAvailabilityChecker { self.processing_cache.write().remove(block_root) } - /// Gather all block roots for which we are not currently processing all components for the - /// given slot. - pub fn incomplete_processing_components(&self, slot: Slot) -> Vec { - self.processing_cache - .read() - .incomplete_processing_components(slot) - } - /// The epoch at which we require a data availability check in block processing. /// `None` if the `Deneb` fork is disabled. pub fn data_availability_boundary(&self) -> Option { diff --git a/beacon_node/beacon_chain/src/data_availability_checker/processing_cache.rs b/beacon_node/beacon_chain/src/data_availability_checker/processing_cache.rs index af94803dc..e09b3083b 100644 --- a/beacon_node/beacon_chain/src/data_availability_checker/processing_cache.rs +++ b/beacon_node/beacon_chain/src/data_availability_checker/processing_cache.rs @@ -3,7 +3,7 @@ use std::collections::hash_map::Entry; use std::collections::HashMap; use std::sync::Arc; use types::beacon_block_body::KzgCommitmentOpts; -use types::{EthSpec, Hash256, SignedBeaconBlock, Slot}; +use types::{EthSpec, Hash256, SignedBeaconBlock}; /// This cache is used only for gossip blocks/blobs and single block/blob lookups, to give req/resp /// a view of what we have and what we require. This cache serves a slightly different purpose than @@ -29,23 +29,13 @@ impl ProcessingCache { .get(block_root) .map_or(false, |b| b.block_exists()) } - pub fn incomplete_processing_components(&self, slot: Slot) -> Vec { - let mut roots_missing_components = vec![]; - for (&block_root, info) in self.processing_cache.iter() { - if info.slot == slot && !info.is_available() { - roots_missing_components.push(block_root); - } - } - roots_missing_components - } pub fn len(&self) -> usize { self.processing_cache.len() } } -#[derive(Debug, Clone)] +#[derive(Default, Debug, Clone)] pub struct ProcessingComponents { - slot: Slot, /// Blobs required for a block can only be known if we have seen the block. So `Some` here /// means we've seen it, a `None` means we haven't. The `kzg_commitments` value helps us figure /// out whether incoming blobs actually match the block. @@ -56,12 +46,8 @@ pub struct ProcessingComponents { } impl ProcessingComponents { - pub fn new(slot: Slot) -> Self { - Self { - slot, - block: None, - blob_commitments: KzgCommitmentOpts::::default(), - } + pub fn new() -> Self { + Self::default() } } @@ -70,7 +56,6 @@ impl ProcessingComponents { impl ProcessingComponents { pub fn empty(_block_root: Hash256) -> Self { Self { - slot: Slot::new(0), block: None, blob_commitments: KzgCommitmentOpts::::default(), }