From dacc2f0e7e8745d3ce772606310a0add3ad92807 Mon Sep 17 00:00:00 2001 From: Eitan Seri- Levi Date: Thu, 19 Mar 2026 08:59:24 -0700 Subject: [PATCH] cleanup --- beacon_node/beacon_chain/src/beacon_chain.rs | 45 ++++++++++++++++--- .../src/data_availability_checker_v2/mod.rs | 4 ++ .../src/data_availability_router.rs | 10 ++--- beacon_node/beacon_chain/src/metrics.rs | 6 --- 4 files changed, 47 insertions(+), 18 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 8f2c7caaa7..7a93760366 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -20,8 +20,10 @@ use crate::chain_config::ChainConfig; use crate::custody_context::CustodyContextSsz; use crate::data_availability_checker::{ Availability as BlockAvailability, AvailabilityCheckError, AvailableBlock, AvailableBlockData, - DataColumnReconstructionResult, + DataColumnReconstructionResult as DataColumnReconstructionResultV1, }; + +use crate::data_availability_checker_v2::DataColumnReconstructionResult as DataColumnReconstructionResultV2; use crate::data_availability_router::{ AvailabilityOutcome, DataAvailabilityRouter, ReconstructionOutcome, }; @@ -3337,7 +3339,7 @@ impl BeaconChain { match result { ReconstructionOutcome::Block(data_column_reconstruction_result) => { match data_column_reconstruction_result { - DataColumnReconstructionResult::Success(( + DataColumnReconstructionResultV1::Success(( availability, data_columns_to_publish, )) => { @@ -3356,8 +3358,8 @@ impl BeaconChain { Some((availability_processing_status, data_columns_to_publish)) }) } - DataColumnReconstructionResult::NotStarted(reason) - | DataColumnReconstructionResult::RecoveredColumnsNotImported(reason) => { + DataColumnReconstructionResultV1::NotStarted(reason) + | DataColumnReconstructionResultV1::RecoveredColumnsNotImported(reason) => { // We use metric here because logging this would be *very* noisy. metrics::inc_counter_vec( &metrics::KZG_DATA_COLUMN_RECONSTRUCTION_INCOMPLETE_TOTAL, @@ -3368,9 +3370,38 @@ impl BeaconChain { } } // TODO(gloas) handle data column reconstruction for gloas. - ReconstructionOutcome::Payload(_data_column_reconstruction_result) => Err( - BlockError::InternalError("Not yet implemented for gloas".to_owned()), - ), + ReconstructionOutcome::Payload(data_column_reconstruction_result) => { + match data_column_reconstruction_result { + DataColumnReconstructionResultV2::Success(( + availability, + data_columns_to_publish, + )) => { + let Some(slot) = data_columns_to_publish.first().map(|d| d.slot()) else { + // This should be unreachable because empty result would return `RecoveredColumnsNotImported` instead of success. + return Ok(None); + }; + + self.process_availability( + slot, + AvailabilityOutcome::Payload(availability), + || Ok(()), + ) + .await + .map(|availability_processing_status| { + Some((availability_processing_status, data_columns_to_publish)) + }) + } + DataColumnReconstructionResultV2::NotStarted(reason) + | DataColumnReconstructionResultV2::RecoveredColumnsNotImported(reason) => { + // We use metric here because logging this would be *very* noisy. + metrics::inc_counter_vec( + &metrics::KZG_DATA_COLUMN_RECONSTRUCTION_INCOMPLETE_TOTAL, + &[reason], + ); + Ok(None) + } + } + } } } 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 87d0dfdd5e..cb97595c36 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 @@ -829,6 +829,10 @@ mod data_availability_checker_tests { assert_eq!(cache.block_cache_size(), 0); } + // TODO(gloas): Add tests for `put_rpc_custody_columns` and `put_gossip_verified_data_columns` + // once the Gloas harness can produce KZG-valid columns. These wrappers add KZG verification + // and custody column filtering on top of `put_kzg_verified_custody_data_columns`. + #[tokio::test] async fn test_put_columns_creates_pending_components() { if !is_gloas_enabled() { diff --git a/beacon_node/beacon_chain/src/data_availability_router.rs b/beacon_node/beacon_chain/src/data_availability_router.rs index 656fce22ff..cca5ff207d 100644 --- a/beacon_node/beacon_chain/src/data_availability_router.rs +++ b/beacon_node/beacon_chain/src/data_availability_router.rs @@ -169,7 +169,7 @@ impl DataAvailabilityRouter { self.v1.custody_context() } - /// Query data columns from the appropriate checker based on slot. + /// Query data columns from the appropriate checker based on fork. pub fn get_data_columns( &self, block_root: Hash256, @@ -208,7 +208,7 @@ impl DataAvailabilityRouter { } } - /// Insert RPC custody columns, routing to the correct checker based on fork. + /// Insert RPC custody columns, routing to the correct checker based on slot. pub fn put_rpc_custody_columns( &self, block_root: Hash256, @@ -226,7 +226,7 @@ impl DataAvailabilityRouter { } } - /// Insert gossip-verified data columns, routing to the correct checker based on fork. + /// Insert gossip-verified data columns, routing to the correct checker based on slot. pub fn put_gossip_verified_data_columns( &self, block_root: Hash256, @@ -244,7 +244,7 @@ impl DataAvailabilityRouter { } } - /// Insert KZG-verified custody data columns, routing to the correct checker based on fork. + /// Insert KZG-verified custody data columns, routing to the correct checker based on slot. pub fn put_kzg_verified_custody_data_columns( &self, block_root: Hash256, @@ -262,7 +262,7 @@ impl DataAvailabilityRouter { } } - /// Attempt to reconstruct missing data columns, routing to the correct checker based on fork. + /// Attempt to reconstruct missing data columns, routing to the correct checker based on slot. pub fn reconstruct_data_columns( &self, block_root: &Hash256, diff --git a/beacon_node/beacon_chain/src/metrics.rs b/beacon_node/beacon_chain/src/metrics.rs index a6d9fef59c..478a3e0e6d 100644 --- a/beacon_node/beacon_chain/src/metrics.rs +++ b/beacon_node/beacon_chain/src/metrics.rs @@ -1897,12 +1897,6 @@ pub static DATA_AVAILABILITY_OVERFLOW_MEMORY_BLOCK_CACHE_SIZE: LazyLock> = LazyLock::new(|| { - try_create_int_gauge( - "data_availability_payload_cache_size", - "Number of entries in the data availability payload envelope cache.", - ) -}); pub static DATA_AVAILABILITY_RECONSTRUCTION_TIME: LazyLock> = LazyLock::new(|| { try_create_histogram(