From abf0c33e12e1698a7119f36d7a08e8d34f5d47b1 Mon Sep 17 00:00:00 2001 From: Eitan Seri- Levi Date: Tue, 10 Feb 2026 21:08:31 -0800 Subject: [PATCH] Refactor --- beacon_node/beacon_chain/src/beacon_chain.rs | 40 +-- .../beacon_chain/src/block_verification.rs | 2 - .../src/data_availability_checker.rs | 27 +- .../src/data_availability_checker_v2/mod.rs | 72 +++-- .../src/data_availability_router.rs | 246 ++++++++++-------- .../fetch_blobs/fetch_blobs_beacon_adapter.rs | 1 - .../tests/attestation_production.rs | 2 - .../beacon_chain/tests/block_verification.rs | 1 - beacon_node/beacon_chain/tests/store_tests.rs | 1 - .../gossip_methods.rs | 2 +- .../network_beacon_processor/rpc_methods.rs | 3 +- .../network_beacon_processor/sync_methods.rs | 1 - .../src/sync/block_sidecar_coupling.rs | 1 - .../network/src/sync/network_context.rs | 3 - beacon_node/network/src/sync/tests/lookups.rs | 4 - 15 files changed, 193 insertions(+), 213 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 1a0e1cb702..b41db18ccf 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -23,11 +23,9 @@ use crate::chain_config::ChainConfig; use crate::custody_context::CustodyContextSsz; use crate::data_availability_checker::{ Availability as BlockAvailability, AvailabilityCheckError, AvailableBlock, AvailableBlockData, - DataAvailabilityChecker, DataColumnReconstructionResult, -}; -use crate::data_availability_checker_v2::{ - Availability as PayloadAvailability, DataAvailabilityChecker as DataAvailabilityCheckerV2, + DataColumnReconstructionResult, }; +use crate::data_availability_checker_v2::Availability as PayloadAvailability; use crate::data_availability_router::{ AvailabilityOutcome, DataAvailabilityRouter, ReconstructionOutcome, }; @@ -484,8 +482,7 @@ pub struct BeaconChain { pub genesis_backfill_slot: Slot, /// Provides a KZG verification and temporary storage for blocks and blobs as /// they are collected and combined. - pub data_availability_checker: - Arc, DataAvailabilityCheckerV2>>, + pub data_availability_checker: Arc>, /// The KZG trusted setup used by this chain. pub kzg: Arc, /// RNG instance used by the chain. Currently used for shuffling column sidecars in block publishing. @@ -1315,11 +1312,7 @@ impl BeaconChain { /// chain. Used by sync to learn the status of a block and prevent repeated downloads / /// processing attempts. pub fn get_block_process_status(&self, block_root: &Hash256) -> BlockProcessStatus { - if let Some(cached_block) = self - .data_availability_checker - .v1() - .get_cached_block(block_root) - { + if let Some(cached_block) = self.data_availability_checker.get_cached_block(block_root) { return cached_block; } @@ -3190,7 +3183,6 @@ impl BeaconChain { { let imported_blobs = self .data_availability_checker - .v1() .cached_blob_indexes(block_root) .unwrap_or_default(); let new_blobs = blobs_iter.filter(|b| !imported_blobs.contains(&b.index)); @@ -3407,9 +3399,11 @@ impl BeaconChain { ); } - self.data_availability_checker - .v1() - .put_pre_execution_block(block_root, unverified_block.block_cloned(), block_source)?; + self.data_availability_checker.put_pre_execution_block( + block_root, + unverified_block.block_cloned(), + block_source, + )?; // Start the Prometheus timer. let _full_timer = metrics::start_timer(&metrics::BLOCK_PROCESSING_TIMES); @@ -3444,7 +3438,6 @@ impl BeaconChain { // chain to get stuck temporarily if the block is canonical. Therefore we remove // it from the cache if execution fails. self.data_availability_checker - .v1() .remove_block_on_execution_error(&block_root); })?; @@ -3572,11 +3565,8 @@ impl BeaconChain { block: AvailabilityPendingExecutedBlock, ) -> Result { let slot = block.block.slot(); - let availability = AvailabilityOutcome::Block( - self.data_availability_checker - .v1() - .put_executed_block(block)?, - ); + let availability = + AvailabilityOutcome::Block(self.data_availability_checker.put_executed_block(block)?); self.process_availability(slot, availability, || Ok(())) .await } @@ -3593,7 +3583,6 @@ impl BeaconChain { } let availability = AvailabilityOutcome::Block( self.data_availability_checker - .v1() .put_gossip_verified_blobs(blob.block_root(), std::iter::once(blob))?, ); @@ -3672,7 +3661,6 @@ impl BeaconChain { )?; let availability = AvailabilityOutcome::Block( self.data_availability_checker - .v1() .put_rpc_blobs(block_root, blobs)?, ); @@ -3694,7 +3682,6 @@ impl BeaconChain { )?; let availability = self .data_availability_checker - .v1() .put_kzg_verified_blobs(block_root, blobs)?; AvailabilityOutcome::Block(availability) @@ -7469,15 +7456,12 @@ impl BeaconChain { /// 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 { - self.data_availability_checker - .v1() - .data_availability_boundary() + self.data_availability_checker.data_availability_boundary() } /// Returns true if epoch is within the data availability boundary pub fn da_check_required_for_epoch(&self, epoch: Epoch) -> bool { self.data_availability_checker - .v1() .da_check_required_for_epoch(epoch) } diff --git a/beacon_node/beacon_chain/src/block_verification.rs b/beacon_node/beacon_chain/src/block_verification.rs index ae33c829be..6edb6e1ada 100644 --- a/beacon_node/beacon_chain/src/block_verification.rs +++ b/beacon_node/beacon_chain/src/block_verification.rs @@ -675,7 +675,6 @@ pub fn signature_verify_chain_segment( // we need a batch verify kzg function in the new da checker as well. chain .data_availability_checker - .v1() .batch_verify_kzg_for_available_blocks(&available_blocks)?; // verify signatures @@ -1316,7 +1315,6 @@ impl IntoExecutionPendingBlock for RpcBlock // added to the new da checker as well. chain .data_availability_checker - .v1() .verify_kzg_for_available_block(available_block) .map_err(|e| { BlockSlashInfo::SignatureNotChecked( diff --git a/beacon_node/beacon_chain/src/data_availability_checker.rs b/beacon_node/beacon_chain/src/data_availability_checker.rs index a7738b0a3e..75b0760b4e 100644 --- a/beacon_node/beacon_chain/src/data_availability_checker.rs +++ b/beacon_node/beacon_chain/src/data_availability_checker.rs @@ -5,7 +5,6 @@ use crate::block_verification_types::{AvailabilityPendingExecutedBlock, Availabl use crate::data_availability_checker::overflow_lru_cache::{ DataAvailabilityCheckerInner, ReconstructColumnsDecision, }; -use crate::data_availability_router::AvailabilityCache; use crate::{BeaconChain, BeaconChainTypes, BlockProcessStatus, CustodyContext, metrics}; use educe::Educe; use kzg::Kzg; @@ -359,22 +358,22 @@ impl DataAvailabilityChecker { } } -impl AvailabilityCache for DataAvailabilityChecker { - type Availability = Availability; - type ReconstructionResult = DataColumnReconstructionResult; - - fn custody_context(&self) -> &Arc> { +impl DataAvailabilityChecker { + pub fn custody_context(&self) -> &Arc> { &self.custody_context } /// Get data columns for a block from the availability cache. - fn get_data_columns(&self, block_root: Hash256) -> Option> { + pub fn get_data_columns( + &self, + block_root: Hash256, + ) -> Option> { self.availability_cache.peek_data_columns(block_root) } /// Return the set of cached custody column indices for `block_root`. Returns None if there is /// no block component for `block_root`. - fn cached_data_column_indexes(&self, block_root: &Hash256) -> Option> { + pub fn cached_data_column_indexes(&self, block_root: &Hash256) -> Option> { self.availability_cache .peek_pending_components(block_root, |components| { components.map(|components| components.get_cached_data_columns_indices()) @@ -382,7 +381,7 @@ impl AvailabilityCache for DataAvailabilityChecker { } /// Check if the exact data column is in the availability cache. - fn is_data_column_cached( + pub fn is_data_column_cached( &self, block_root: &Hash256, data_column: &DataColumnSidecar, @@ -400,7 +399,7 @@ impl AvailabilityCache for DataAvailabilityChecker { /// verification on the blobs in the list. #[allow(clippy::type_complexity)] #[instrument(skip_all, level = "trace")] - fn put_rpc_custody_columns( + pub fn put_rpc_custody_columns( &self, block_root: Hash256, slot: Slot, @@ -435,7 +434,7 @@ impl AvailabilityCache for DataAvailabilityChecker { /// /// This should only accept gossip verified data columns, so we should not have to worry about dupes. #[instrument(skip_all, level = "trace")] - fn put_gossip_verified_data_columns( + pub fn put_gossip_verified_data_columns( &self, block_root: Hash256, slot: Slot, @@ -456,7 +455,7 @@ impl AvailabilityCache for DataAvailabilityChecker { } #[instrument(skip_all, level = "trace")] - fn put_kzg_verified_custody_data_columns( + pub fn put_kzg_verified_custody_data_columns( &self, block_root: Hash256, custody_columns: Vec>, @@ -466,7 +465,7 @@ impl AvailabilityCache for DataAvailabilityChecker { } #[instrument(skip_all, level = "debug")] - fn reconstruct_data_columns( + pub fn reconstruct_data_columns( &self, block_root: &Hash256, ) -> Result, AvailabilityCheckError> { @@ -554,7 +553,7 @@ impl AvailabilityCache for DataAvailabilityChecker { } /// Verifies KZG commitments for data columns. - fn verify_kzg_for_data_columns( + pub fn verify_kzg_for_data_columns( &self, data_columns: &DataColumnSidecarList, ) -> Result<(), AvailabilityCheckError> { diff --git a/beacon_node/beacon_chain/src/data_availability_checker_v2/mod.rs b/beacon_node/beacon_chain/src/data_availability_checker_v2/mod.rs index 65e22d0a2f..cad8070a65 100644 --- a/beacon_node/beacon_chain/src/data_availability_checker_v2/mod.rs +++ b/beacon_node/beacon_chain/src/data_availability_checker_v2/mod.rs @@ -3,7 +3,6 @@ use crate::data_availability_checker_v2::pending_components_cache::{ }; use crate::data_availability_checker::AvailabilityCheckError; -use crate::data_availability_router::AvailabilityCache; use crate::{BeaconChain, BeaconChainTypes, CustodyContext, metrics}; use kzg::Kzg; use slot_clock::SlotClock; @@ -87,24 +86,43 @@ pub struct DataAvailabilityChecker { spec: Arc, } -impl AvailabilityCache for DataAvailabilityChecker { - type Availability = Availability; - type ReconstructionResult = DataColumnReconstructionResult; +impl DataAvailabilityChecker { + pub fn new( + slot_clock: T::SlotClock, + kzg: Arc, + custody_context: Arc>, + spec: Arc, + ) -> Result { + let inner = DataAvailabilityCheckerInner::new( + OVERFLOW_LRU_CAPACITY_NON_ZERO, + custody_context.clone(), + spec.clone(), + )?; + Ok(Self { + availability_cache: Arc::new(inner), + slot_clock, + kzg, + custody_context, + spec, + }) + } - /// Returns the custody context. - fn custody_context(&self) -> &Arc> { + pub fn custody_context(&self) -> &Arc> { &self.custody_context } /// Returns all cached data columns for the given block root, if any. #[instrument(skip_all, level = "trace")] - fn get_data_columns(&self, block_root: Hash256) -> Option> { + pub fn get_data_columns( + &self, + block_root: Hash256, + ) -> Option> { self.availability_cache.peek_data_columns(block_root) } /// Returns the indices of cached data columns for the given block root. #[instrument(skip_all, level = "trace")] - fn cached_data_column_indexes(&self, block_root: &Hash256) -> Option> { + pub fn cached_data_column_indexes(&self, block_root: &Hash256) -> Option> { self.availability_cache .peek_pending_components(block_root, |components| { components.map(|components| components.get_cached_data_columns_indices()) @@ -113,7 +131,7 @@ impl AvailabilityCache for DataAvailabilityChecker { /// Checks if a specific data column is cached for the given block root. #[instrument(skip_all, level = "trace")] - fn is_data_column_cached( + pub fn is_data_column_cached( &self, block_root: &Hash256, data_column: &DataColumnSidecar, @@ -129,7 +147,7 @@ impl AvailabilityCache for DataAvailabilityChecker { /// Insert RPC custody columns and check if the payload becomes available. #[instrument(skip_all, level = "trace")] - fn put_rpc_custody_columns( + pub fn put_rpc_custody_columns( &self, block_root: Hash256, slot: Slot, @@ -158,7 +176,7 @@ impl AvailabilityCache for DataAvailabilityChecker { /// Check if we've cached other data columns for this block root. If it satisfies the custody /// requirement, return the `Availability::Available` variant. Otherwise cache the data column sidecar. #[instrument(skip_all, level = "trace")] - fn put_gossip_verified_data_columns( + pub fn put_gossip_verified_data_columns( &self, block_root: Hash256, slot: Slot, @@ -179,7 +197,7 @@ impl AvailabilityCache for DataAvailabilityChecker { } #[instrument(skip_all, level = "trace")] - fn put_kzg_verified_custody_data_columns( + pub fn put_kzg_verified_custody_data_columns( &self, block_root: Hash256, custody_columns: Vec>, @@ -189,7 +207,7 @@ impl AvailabilityCache for DataAvailabilityChecker { } #[instrument(skip_all, level = "debug")] - fn reconstruct_data_columns( + pub fn reconstruct_data_columns( &self, block_root: &Hash256, ) -> Result, AvailabilityCheckError> { @@ -277,7 +295,7 @@ impl AvailabilityCache for DataAvailabilityChecker { } /// Verifies KZG commitments for data columns. - fn verify_kzg_for_data_columns( + pub fn verify_kzg_for_data_columns( &self, data_columns: &DataColumnSidecarList, ) -> Result<(), AvailabilityCheckError> { @@ -287,32 +305,6 @@ impl AvailabilityCache for DataAvailabilityChecker { } Ok(()) } -} - -impl DataAvailabilityChecker { - pub fn new( - slot_clock: T::SlotClock, - kzg: Arc, - custody_context: Arc>, - spec: Arc, - ) -> Result { - let inner = DataAvailabilityCheckerInner::new( - OVERFLOW_LRU_CAPACITY_NON_ZERO, - custody_context.clone(), - spec.clone(), - )?; - Ok(Self { - availability_cache: Arc::new(inner), - slot_clock, - kzg, - custody_context, - spec, - }) - } - - pub fn custody_context(&self) -> &Arc> { - &self.custody_context - } /// Insert an execution payload bid into the cache and check if data becomes available. pub fn put_bid( diff --git a/beacon_node/beacon_chain/src/data_availability_router.rs b/beacon_node/beacon_chain/src/data_availability_router.rs index c2ed0b1ddc..b480cce5b0 100644 --- a/beacon_node/beacon_chain/src/data_availability_router.rs +++ b/beacon_node/beacon_chain/src/data_availability_router.rs @@ -6,7 +6,7 @@ //! //! ## Design //! -//! - **Unified operations**: Via the `AvailabilityCache` trait (blocks, columns, availability checks) +//! - **Unified operations**: Shared column operations dispatched to v1 or v2 //! - **Fork-aware routing**: `DataAvailabilityRouter` dispatches to v1 or v2 based on slot //! - **Processing**: `BeaconChain::process_availability_outcome()` handles both result types //! @@ -14,21 +14,25 @@ //! use the Gloas DA checker directly. use crate::BeaconChainTypes; +use crate::BlockProcessStatus; +use crate::blob_verification::{GossipVerifiedBlob, KzgVerifiedBlob}; +use crate::block_verification_types::AvailabilityPendingExecutedBlock; use crate::custody_context::CustodyContext; use crate::data_availability_checker::{ - Availability as BlockAvailability, AvailabilityCheckError, - DataColumnReconstructionResult as BlockReconstructionResult, + Availability as BlockAvailability, AvailabilityCheckError, AvailableBlock, + DataAvailabilityChecker, DataColumnReconstructionResult as BlockReconstructionResult, }; use crate::data_availability_checker_v2::{ - Availability as PayloadAvailability, + Availability as PayloadAvailability, DataAvailabilityChecker as DataAvailabilityCheckerV2, DataColumnReconstructionResult as PayloadReconstructionResult, }; use crate::data_column_verification::{GossipVerifiedDataColumn, KzgVerifiedCustodyDataColumn}; use crate::observed_data_sidecars::ObservationStrategy; use std::sync::Arc; +use types::data::{BlobIdentifier, FixedBlobSidecarList}; use types::{ - ChainSpec, ColumnIndex, DataColumnSidecar, DataColumnSidecarList, EthSpec, ForkName, Hash256, - Slot, + BlobSidecar, BlockImportSource, ChainSpec, ColumnIndex, DataColumnSidecar, + DataColumnSidecarList, Epoch, EthSpec, ForkName, Hash256, SignedBeaconBlock, Slot, }; /// Unified result from operations that can come from either DA checker. @@ -122,74 +126,6 @@ impl ReconstructionOutcome { } } -/// Trait for data availability operations on availability checkers. -/// -/// Both `DataAvailabilityChecker` (v1) and `DataAvailabilityChecker` (v2) implement -/// this trait. The associated types differ: -/// - V1: Returns `Availability` containing `AvailableExecutedBlock` -/// - V2: Returns `Availability` containing `(Hash256, DataColumnSidecarList)` (block root + columns) -pub trait AvailabilityCache: Send + Sync { - /// The availability type returned by write operations. - /// V1 returns block availability, V2 returns payload availability. - type Availability; - - /// The reconstruction result type. - /// V1 returns `DataColumnReconstructionResult` with block availability. - /// V2 returns `DataColumnReconstructionResult` with payload availability. - type ReconstructionResult; - - /// Returns the custody context. - fn custody_context(&self) -> &Arc>; - - /// Returns all cached data columns for the given block root, if any. - fn get_data_columns(&self, block_root: Hash256) -> Option>; - - /// Returns the indices of cached data columns for the given block root. - fn cached_data_column_indexes(&self, block_root: &Hash256) -> Option>; - - /// Checks if a specific data column is cached for the given block root. - fn is_data_column_cached( - &self, - block_root: &Hash256, - data_column: &DataColumnSidecar, - ) -> bool; - - /// Insert RPC custody columns and check if the block/payload becomes available. - fn put_rpc_custody_columns( - &self, - block_root: Hash256, - slot: Slot, - custody_columns: DataColumnSidecarList, - ) -> Result; - - /// Insert gossip-verified data columns and check availability. - fn put_gossip_verified_data_columns( - &self, - block_root: Hash256, - slot: Slot, - data_columns: Vec>, - ) -> Result; - - /// Insert KZG-verified custody data columns and check availability. - fn put_kzg_verified_custody_data_columns( - &self, - block_root: Hash256, - custody_columns: Vec>, - ) -> Result; - - /// Attempt to reconstruct missing data columns from available ones. - fn reconstruct_data_columns( - &self, - block_root: &Hash256, - ) -> Result; - - /// Verifies KZG commitments for a list of data columns. - fn verify_kzg_for_data_columns( - &self, - data_columns: &DataColumnSidecarList, - ) -> Result<(), AvailabilityCheckError>; -} - /// Router that directs data availability checker operations to the appropriate version based on fork. /// /// This wraps both the legacy (v1) and Gloas (v2) DA checkers, providing unified operations @@ -197,47 +133,21 @@ pub trait AvailabilityCache: Send + Sync { /// /// After Gloas is fully activated and v1 is deprecated, this router can be deleted and /// we can use the V2 DA checker directly. -pub struct DataAvailabilityRouter -where - V1: AvailabilityCache< - T, - Availability = BlockAvailability, - ReconstructionResult = BlockReconstructionResult, - >, - V2: AvailabilityCache< - T, - Availability = PayloadAvailability, - ReconstructionResult = PayloadReconstructionResult, - >, -{ +pub struct DataAvailabilityRouter { /// Legacy DA checker for pre-Gloas blocks - v1: Arc, + v1: Arc>, /// Gloas DA checker for payload envelopes - v2: Arc, + v2: Arc>, spec: Arc, - _phantom: std::marker::PhantomData, } -impl DataAvailabilityRouter -where - V1: AvailabilityCache< - T, - Availability = BlockAvailability, - ReconstructionResult = BlockReconstructionResult, - >, - V2: AvailabilityCache< - T, - Availability = PayloadAvailability, - ReconstructionResult = PayloadReconstructionResult, - >, -{ - pub fn new(v1: Arc, v2: Arc, spec: Arc) -> Self { - Self { - v1, - v2, - spec, - _phantom: std::marker::PhantomData, - } +impl DataAvailabilityRouter { + pub fn new( + v1: Arc>, + v2: Arc>, + spec: Arc, + ) -> Self { + Self { v1, v2, spec } } /// Returns true if the given slot is in the Gloas fork or later. @@ -247,6 +157,8 @@ where .gloas_enabled() } + // ── Shared methods (dispatched to v1 or v2 based on fork) ── + /// Returns the custody context (same for both checkers). pub fn custody_context(&self) -> &Arc> { // Both checkers share the same custody context @@ -363,17 +275,127 @@ where } } + // ── V1-only methods (blobs, blocks, boundary queries) ── + + /// Returns the data availability boundary epoch (v1). + pub fn data_availability_boundary(&self) -> Option { + self.v1.data_availability_boundary() + } + + /// Returns whether a DA check is required for the given epoch (v1). + pub fn da_check_required_for_epoch(&self, epoch: Epoch) -> bool { + self.v1.da_check_required_for_epoch(epoch) + } + + /// Returns whether blobs are required for the given epoch (v1). + pub fn blobs_required_for_epoch(&self, epoch: Epoch) -> bool { + self.v1.blobs_required_for_epoch(epoch) + } + + /// Returns whether data columns are required for the given epoch (v1). + pub fn data_columns_required_for_epoch(&self, epoch: Epoch) -> bool { + self.v1.data_columns_required_for_epoch(epoch) + } + + /// Verifies KZG commitments for a single available block (v1). + pub fn verify_kzg_for_available_block( + &self, + available_block: &AvailableBlock, + ) -> Result<(), AvailabilityCheckError> { + self.v1.verify_kzg_for_available_block(available_block) + } + + /// Batch verifies KZG commitments for multiple available blocks (v1). + pub fn batch_verify_kzg_for_available_blocks( + &self, + available_blocks: &[AvailableBlock], + ) -> Result<(), AvailabilityCheckError> { + self.v1 + .batch_verify_kzg_for_available_blocks(available_blocks) + } + + /// Get a blob from the availability cache (v1). + pub fn get_blob( + &self, + blob_id: &BlobIdentifier, + ) -> Result>>, AvailabilityCheckError> { + self.v1.get_blob(blob_id) + } + + /// Returns the cached blob indexes for a given block root (v1). + pub fn cached_blob_indexes(&self, block_root: &Hash256) -> Option> { + self.v1.cached_blob_indexes(block_root) + } + + /// Returns the cached block for a given block root (v1). + pub fn get_cached_block(&self, block_root: &Hash256) -> Option> { + self.v1.get_cached_block(block_root) + } + + /// Inserts a pre-execution block into the cache (v1). + pub fn put_pre_execution_block( + &self, + block_root: Hash256, + block: Arc>, + source: BlockImportSource, + ) -> Result<(), AvailabilityCheckError> { + self.v1.put_pre_execution_block(block_root, block, source) + } + + /// Insert an executed block and check availability (v1). + pub fn put_executed_block( + &self, + executed_block: AvailabilityPendingExecutedBlock, + ) -> Result, AvailabilityCheckError> { + self.v1.put_executed_block(executed_block) + } + + /// Removes a pre-execution block from the cache on execution error (v1). + pub fn remove_block_on_execution_error(&self, block_root: &Hash256) { + self.v1.remove_block_on_execution_error(block_root) + } + + /// Insert blobs received via RPC and check availability (v1). + pub fn put_rpc_blobs( + &self, + block_root: Hash256, + blobs: FixedBlobSidecarList, + ) -> Result, AvailabilityCheckError> { + self.v1.put_rpc_blobs(block_root, blobs) + } + + /// Insert KZG-verified blobs and check availability (v1). + pub fn put_kzg_verified_blobs>>( + &self, + block_root: Hash256, + blobs: I, + ) -> Result, AvailabilityCheckError> { + self.v1.put_kzg_verified_blobs(block_root, blobs) + } + + /// Insert gossip-verified blobs into the v1 checker. + pub fn put_gossip_verified_blobs< + I: IntoIterator>, + O: ObservationStrategy, + >( + &self, + block_root: Hash256, + blobs: I, + ) -> Result, AvailabilityCheckError> { + self.v1.put_gossip_verified_blobs(block_root, blobs) + } + /// Direct access to v1 checker for block execution/availability checks. /// /// Use this for operations that are specific to the legacy DA checker, - pub fn v1(&self) -> Arc { + pub fn v1(&self) -> Arc> { self.v1.clone() } /// Direct access to v2 checker for payload availability checks. /// /// Use this for operations that are specific to the Gloas DA checker, - pub fn v2(&self) -> Arc { + pub fn v2(&self) -> Arc> { self.v2.clone() } } diff --git a/beacon_node/beacon_chain/src/fetch_blobs/fetch_blobs_beacon_adapter.rs b/beacon_node/beacon_chain/src/fetch_blobs/fetch_blobs_beacon_adapter.rs index 71d2b65bb5..8575e0d8de 100644 --- a/beacon_node/beacon_chain/src/fetch_blobs/fetch_blobs_beacon_adapter.rs +++ b/beacon_node/beacon_chain/src/fetch_blobs/fetch_blobs_beacon_adapter.rs @@ -92,7 +92,6 @@ impl FetchBlobsBeaconAdapter { pub(crate) fn cached_blob_indexes(&self, block_root: &Hash256) -> Option> { self.chain .data_availability_checker - .v1() .cached_blob_indexes(block_root) } diff --git a/beacon_node/beacon_chain/tests/attestation_production.rs b/beacon_node/beacon_chain/tests/attestation_production.rs index 5fb2d0897d..a1922f32a4 100644 --- a/beacon_node/beacon_chain/tests/attestation_production.rs +++ b/beacon_node/beacon_chain/tests/attestation_production.rs @@ -230,7 +230,6 @@ async fn produces_attestations() { RpcBlock::FullyAvailable(available_block) => { chain .data_availability_checker - .v1() .verify_kzg_for_available_block(&available_block) .unwrap(); available_block @@ -301,7 +300,6 @@ async fn early_attester_cache_old_request() { harness .chain .data_availability_checker - .v1() .verify_kzg_for_available_block(&available_block) .unwrap(); available_block diff --git a/beacon_node/beacon_chain/tests/block_verification.rs b/beacon_node/beacon_chain/tests/block_verification.rs index 74526261c8..952170b12a 100644 --- a/beacon_node/beacon_chain/tests/block_verification.rs +++ b/beacon_node/beacon_chain/tests/block_verification.rs @@ -2219,7 +2219,6 @@ async fn rpc_block_allows_construction_past_da_boundary() { let da_boundary = harness .chain .data_availability_checker - .v1() .data_availability_boundary() .expect("DA boundary should be set"); assert!( diff --git a/beacon_node/beacon_chain/tests/store_tests.rs b/beacon_node/beacon_chain/tests/store_tests.rs index 03ce894485..96c8b7748b 100644 --- a/beacon_node/beacon_chain/tests/store_tests.rs +++ b/beacon_node/beacon_chain/tests/store_tests.rs @@ -3182,7 +3182,6 @@ async fn weak_subjectivity_sync_test( harness .chain .data_availability_checker - .v1() .verify_kzg_for_available_block(&available_block) .expect("should verify kzg"); available_blocks.push(available_block); diff --git a/beacon_node/network/src/network_beacon_processor/gossip_methods.rs b/beacon_node/network/src/network_beacon_processor/gossip_methods.rs index ec15f2b639..d38089c6da 100644 --- a/beacon_node/network/src/network_beacon_processor/gossip_methods.rs +++ b/beacon_node/network/src/network_beacon_processor/gossip_methods.rs @@ -1055,7 +1055,7 @@ impl NetworkBeaconProcessor { ); // If a block is in the da_checker, sync maybe awaiting for an event when block is finally - // imported. A block can become imported both after processing a block or data column. If + // imported. A block can become imported both after processing a block or data column. If // importing a block results in `Imported`, notify. Do not notify of data column errors. self.send_sync_message(SyncMessage::GossipBlockProcessResult { block_root, diff --git a/beacon_node/network/src/network_beacon_processor/rpc_methods.rs b/beacon_node/network/src/network_beacon_processor/rpc_methods.rs index 7d09464f4d..4095ed847f 100644 --- a/beacon_node/network/src/network_beacon_processor/rpc_methods.rs +++ b/beacon_node/network/src/network_beacon_processor/rpc_methods.rs @@ -306,7 +306,6 @@ impl NetworkBeaconProcessor { let block_root = blob_id.block_root; self.chain .data_availability_checker - .v1() .get_cached_block(&block_root) .and_then(|status| match status { BlockProcessStatus::NotValidated(block, _source) => Some(block), @@ -334,7 +333,7 @@ impl NetworkBeaconProcessor { } // First attempt to get the blobs from the RPC cache. - if let Ok(Some(blob)) = self.chain.data_availability_checker.v1().get_blob(id) { + if let Ok(Some(blob)) = self.chain.data_availability_checker.get_blob(id) { self.send_response( peer_id, inbound_request_id, diff --git a/beacon_node/network/src/network_beacon_processor/sync_methods.rs b/beacon_node/network/src/network_beacon_processor/sync_methods.rs index 6f33344b94..8bc5b22be5 100644 --- a/beacon_node/network/src/network_beacon_processor/sync_methods.rs +++ b/beacon_node/network/src/network_beacon_processor/sync_methods.rs @@ -739,7 +739,6 @@ impl NetworkBeaconProcessor { match self .chain .data_availability_checker - .v1() .batch_verify_kzg_for_available_blocks(&available_blocks) { Ok(()) => {} diff --git a/beacon_node/network/src/sync/block_sidecar_coupling.rs b/beacon_node/network/src/sync/block_sidecar_coupling.rs index 88ac863482..a287771854 100644 --- a/beacon_node/network/src/sync/block_sidecar_coupling.rs +++ b/beacon_node/network/src/sync/block_sidecar_coupling.rs @@ -490,7 +490,6 @@ mod tests { use super::RangeBlockComponentsRequest; use beacon_chain::custody_context::NodeCustodyType; - use beacon_chain::data_availability_router::AvailabilityCache; use beacon_chain::test_utils::{ NumBlobs, generate_rand_block_and_blobs, generate_rand_block_and_data_columns, test_da_checker, test_spec, diff --git a/beacon_node/network/src/sync/network_context.rs b/beacon_node/network/src/sync/network_context.rs index bdeff68855..22730fcff3 100644 --- a/beacon_node/network/src/sync/network_context.rs +++ b/beacon_node/network/src/sync/network_context.rs @@ -967,7 +967,6 @@ impl SyncNetworkContext { let imported_blob_indexes = self .chain .data_availability_checker - .v1() .cached_blob_indexes(&block_root) .unwrap_or_default(); // Include only the blob indexes not yet imported (received through gossip) @@ -1371,14 +1370,12 @@ impl SyncNetworkContext { if self .chain .data_availability_checker - .v1() .data_columns_required_for_epoch(epoch) { ByRangeRequestType::BlocksAndColumns } else if self .chain .data_availability_checker - .v1() .blobs_required_for_epoch(epoch) { ByRangeRequestType::BlocksAndBlobs diff --git a/beacon_node/network/src/sync/tests/lookups.rs b/beacon_node/network/src/sync/tests/lookups.rs index 12fd2035da..63024bd2aa 100644 --- a/beacon_node/network/src/sync/tests/lookups.rs +++ b/beacon_node/network/src/sync/tests/lookups.rs @@ -1082,7 +1082,6 @@ impl TestRig { .harness .chain .data_availability_checker - .v1() .put_executed_block(executed_block) .unwrap() { @@ -1098,7 +1097,6 @@ impl TestRig { .harness .chain .data_availability_checker - .v1() .put_gossip_verified_blobs( blob.block_root(), std::iter::once(GossipVerifiedBlob::<_, Observe>::__assumed_valid( @@ -1118,7 +1116,6 @@ impl TestRig { self.harness .chain .data_availability_checker - .v1() .put_pre_execution_block(block.canonical_root(), block, BlockImportSource::Gossip) .unwrap(); } @@ -1127,7 +1124,6 @@ impl TestRig { self.harness .chain .data_availability_checker - .v1() .remove_block_on_execution_error(&block_root); self.send_sync_message(SyncMessage::GossipBlockProcessResult {