From 4d04ac1381dc4c0faa1a3cdfc9e70917bd9ba8e2 Mon Sep 17 00:00:00 2001 From: Eitan Seri- Levi Date: Wed, 18 Mar 2026 06:57:19 -0700 Subject: [PATCH] update --- beacon_node/beacon_chain/src/beacon_chain.rs | 17 ++----- .../beacon_chain/src/block_verification.rs | 12 ----- .../src/data_availability_checker_v2/mod.rs | 1 - .../payload_envelope_cache.rs | 1 - .../pending_components_cache.rs | 10 +---- .../payload_envelope_verification/import.rs | 44 +++++++++++++++---- 6 files changed, 40 insertions(+), 45 deletions(-) delete mode 100644 beacon_node/beacon_chain/src/data_availability_checker_v2/payload_envelope_cache.rs diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 2b380c0520..1250252434 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -3779,7 +3779,7 @@ impl BeaconChain { /// /// An error is returned if the block was unable to be imported. It may be partially imported /// (i.e., this function is not atomic). - pub(crate) async fn process_availability( + async fn process_availability( self: &Arc, slot: Slot, availability: AvailabilityOutcome, @@ -3798,19 +3798,8 @@ impl BeaconChain { ), } } - AvailabilityOutcome::Payload(availability) => match availability { - PayloadAvailability::Available(available_envelope) => { - // TODO(gloas) execution publish_fn - publish_fn()?; - - // Payload envelope is fully available - self.import_available_execution_payload_envelope(available_envelope) - .await - .map_err(BlockError::from) - } - PayloadAvailability::MissingComponents(block_root) => Ok( - AvailabilityProcessingStatus::MissingComponents(slot, block_root), - ), + AvailabilityOutcome::Payload(_) => { + return Err(BlockError::InternalError("Received a payload envelope availability outcome variant when a block variant was expected".to_string())) }, } } diff --git a/beacon_node/beacon_chain/src/block_verification.rs b/beacon_node/beacon_chain/src/block_verification.rs index dcc006ecd8..de817e35fb 100644 --- a/beacon_node/beacon_chain/src/block_verification.rs +++ b/beacon_node/beacon_chain/src/block_verification.rs @@ -322,12 +322,6 @@ pub enum BlockError { bid_parent_root: Hash256, block_parent_root: Hash256, }, - /// An error occurred while processing a payload envelope. - /// - /// ## Peer scoring - /// - /// Peer scoring depends on the inner `EnvelopeError`. - EnvelopeError(EnvelopeError), } /// Which specific signature(s) are invalid in a SignedBeaconBlock @@ -347,12 +341,6 @@ impl From for BlockError { } } -impl From for BlockError { - fn from(e: EnvelopeError) -> Self { - Self::EnvelopeError(e) - } -} - /// Returned when block validation failed due to some issue verifying /// the execution payload. #[derive(Debug)] 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 c45f54b467..39c235b51c 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 @@ -20,7 +20,6 @@ use types::{ Hash256, SignedExecutionPayloadBid, SignedExecutionPayloadEnvelope, Slot, }; -mod payload_envelope_cache; mod pending_components_cache; use crate::data_column_verification::{ diff --git a/beacon_node/beacon_chain/src/data_availability_checker_v2/payload_envelope_cache.rs b/beacon_node/beacon_chain/src/data_availability_checker_v2/payload_envelope_cache.rs deleted file mode 100644 index 8b13789179..0000000000 --- a/beacon_node/beacon_chain/src/data_availability_checker_v2/payload_envelope_cache.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/beacon_node/beacon_chain/src/data_availability_checker_v2/pending_components_cache.rs b/beacon_node/beacon_chain/src/data_availability_checker_v2/pending_components_cache.rs index 607c031694..3666024c79 100644 --- a/beacon_node/beacon_chain/src/data_availability_checker_v2/pending_components_cache.rs +++ b/beacon_node/beacon_chain/src/data_availability_checker_v2/pending_components_cache.rs @@ -81,7 +81,7 @@ impl PendingComponents { self.bid = Some(bid); } - pub fn insert_executed_paylaod_envelope( + pub fn insert_executed_payload_envelope( &mut self, envelope: AvailabilityPendingExecutedEnvelope, ) { @@ -96,14 +96,6 @@ impl PendingComponents { self.envelope = Some(CachedPayloadEnvelope::PreExecution(envelope, import_source)) } - /// Inserts an executed payload envelope into the cache. - pub fn insert_executed_payload_envelope( - &mut self, - envelope: AvailabilityPendingExecutedEnvelope, - ) { - self.envelope = Some(CachedPayloadEnvelope::Executed(Box::new(envelope))) - } - /// Returns the number of blobs expected by reading the bid's kzg commitments. /// Returns an error if the bid is not cached. This function should only be called /// after ensuring that the bid has been cached. diff --git a/beacon_node/beacon_chain/src/payload_envelope_verification/import.rs b/beacon_node/beacon_chain/src/payload_envelope_verification/import.rs index b9b9507a6f..4f660362c6 100644 --- a/beacon_node/beacon_chain/src/payload_envelope_verification/import.rs +++ b/beacon_node/beacon_chain/src/payload_envelope_verification/import.rs @@ -1,16 +1,11 @@ use std::sync::Arc; use std::time::Duration; -use fork_choice::PayloadVerificationStatus; -use slot_clock::SlotClock; -use store::StoreOp; -use tracing::{debug, error, info, info_span, instrument, warn}; -use types::{BeaconState, BlockImportSource, Hash256, Slot}; - use super::{ AvailableEnvelope, AvailableExecutedEnvelope, EnvelopeError, EnvelopeImportData, ExecutedEnvelope, gossip_verified_envelope::GossipVerifiedEnvelope, }; +use crate::data_availability_checker_v2::Availability as PayloadAvailability; use crate::{ AvailabilityProcessingStatus, BeaconChain, BeaconChainError, BeaconChainTypes, NotifyExecutionLayer, @@ -22,6 +17,11 @@ use crate::{ }, validator_monitor::get_slot_delay_ms, }; +use fork_choice::PayloadVerificationStatus; +use slot_clock::SlotClock; +use store::StoreOp; +use tracing::{debug, error, info, info_span, instrument, warn}; +use types::{BeaconState, BlockImportSource, Hash256, Slot}; const ENVELOPE_METRICS_CACHE_SLOT_LIMIT: u32 = 64; @@ -161,6 +161,35 @@ impl BeaconChain { } } + /// Imports a fully available payload envelope. Otherwise, returns `AvailabilityProcessingStatus::MissingComponents` + /// + /// An error is returned if the enveope was unable to be imported. It may be partially imported + /// (i.e., this function is not atomic). + async fn process_payload_envelope_availability( + self: &Arc, + slot: Slot, + availability: AvailabilityOutcome, + publish_fn: impl FnOnce() -> Result<(), EnvelopeError>, + ) -> Result { + match availability { + AvailabilityOutcome::Block(_) => { + return Err(EnvelopeError::InternalError("Received a block availability outcome variant when a payload envelope variant was expected".to_string())) + } + AvailabilityOutcome::Payload(availability) => match availability { + PayloadAvailability::Available(available_envelope) => { + publish_fn()?; + + // Payload envelope is fully available + self.import_available_execution_payload_envelope(available_envelope) + .await + } + PayloadAvailability::MissingComponents(block_root) => Ok( + AvailabilityProcessingStatus::MissingComponents(slot, block_root), + ), + }, + } + } + /// Checks if the payload envelope is available, and imports immediately if so, otherwise caches the envelope /// in the data availability checker. #[instrument(skip_all)] @@ -174,9 +203,8 @@ impl BeaconChain { .v2() .put_executed_payload_envelope(envelope)?, ); - self.process_availability(slot, availability, || Ok(())) + self.process_payload_envelope_availability(slot, availability, || Ok(())) .await - .map_err(EnvelopeError::BlockError) } /// Accepts a fully-verified payload envelope and awaits on its payload verification handle to