diff --git a/beacon_node/beacon_chain/src/data_availability_checker.rs b/beacon_node/beacon_chain/src/data_availability_checker.rs index e9ee34bc8db..cff7f7a77d5 100644 --- a/beacon_node/beacon_chain/src/data_availability_checker.rs +++ b/beacon_node/beacon_chain/src/data_availability_checker.rs @@ -2,7 +2,9 @@ use crate::blob_verification::{verify_kzg_for_blob_list, GossipVerifiedBlob, Kzg use crate::block_verification_types::{ AvailabilityPendingExecutedBlock, AvailableExecutedBlock, RpcBlock, }; -use crate::data_availability_checker::overflow_lru_cache::OverflowLRUCache; +use crate::data_availability_checker::overflow_lru_cache::{ + AvailabilityAndReconstructedColumns, OverflowLRUCache, +}; use crate::{BeaconChain, BeaconChainTypes, BeaconStore}; use kzg::Kzg; use slog::{debug, error, o, Logger}; @@ -158,17 +160,10 @@ impl DataAvailabilityChecker { self.availability_cache.peek_data_column(data_column_id) } - #[allow(clippy::type_complexity)] pub fn reconstruct_data_columns( &self, block_root: Hash256, - ) -> Result< - Option<( - Availability<::EthSpec>, - DataColumnSidecarVec<::EthSpec>, - )>, - Error, - > { + ) -> Result>, Error> { let Some(kzg) = self.kzg.as_ref() else { return Err(AvailabilityCheckError::KzgNotInitialized); }; diff --git a/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs b/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs index 8e62da647ae..ca35240f814 100644 --- a/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs +++ b/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs @@ -72,6 +72,8 @@ pub enum BlockImportRequirement { CustodyColumns(usize), } +pub type AvailabilityAndReconstructedColumns = (Availability, DataColumnSidecarVec); + impl PendingComponents { /// Returns an immutable reference to the cached block. pub fn get_cached_block(&self) -> &Option> { @@ -852,15 +854,12 @@ impl OverflowLRUCache { } } - #[allow(clippy::type_complexity)] pub fn reconstruct_data_columns( &self, kzg: &Kzg, block_root: Hash256, - ) -> Result< - Option<(Availability, DataColumnSidecarVec)>, - AvailabilityCheckError, - > { + ) -> Result>, AvailabilityCheckError> + { // Clone the pending components, so we don't hold the read lock during reconstruction let Some(mut pending_components) = self .peek_pending_components(&block_root, |pending_components_opt| { diff --git a/beacon_node/network/src/network_beacon_processor/mod.rs b/beacon_node/network/src/network_beacon_processor/mod.rs index 99a96c3efdb..45bc58dd4a8 100644 --- a/beacon_node/network/src/network_beacon_processor/mod.rs +++ b/beacon_node/network/src/network_beacon_processor/mod.rs @@ -778,6 +778,9 @@ impl NetworkBeaconProcessor { }); } + /// Attempt to reconstruct all data columns if the following conditions satisfies: + /// - Our custody requirement is all columns + /// - We >= 50% of columns, but not all columns async fn attempt_data_column_reconstruction(&self, block_root: Hash256) { let result = self.chain.reconstruct_data_columns(block_root).await; match result { @@ -793,7 +796,6 @@ impl NetworkBeaconProcessor { self.chain.recompute_head_at_current_slot().await; } AvailabilityProcessingStatus::MissingComponents(_, _) => { - // TODO: confirm we only perform reconstruction after block is received debug!( self.log, "Block components still missing block after reconstruction";