diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 5e00dffbdd..9b08478dab 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -115,7 +115,6 @@ use state_processing::{ per_slot_processing, state_advance::{complete_state_advance, partial_state_advance}, }; -use types::consts::gloas::PAYLOAD_STATUS_FULL; use std::borrow::Cow; use std::cmp::Ordering; use std::collections::HashMap; @@ -133,6 +132,7 @@ use task_executor::{RayonPoolType, ShutdownReason, TaskExecutor}; use tokio_stream::Stream; use tracing::{Span, debug, debug_span, error, info, info_span, instrument, trace, warn}; use tree_hash::TreeHash; +use types::consts::gloas::PAYLOAD_STATUS_FULL; use types::data::{ColumnIndex, FixedBlobSidecarList}; use types::execution::BlockProductionVersion; use types::*; @@ -2089,7 +2089,8 @@ impl BeaconChain { }); } - if proto_block.slot < request_slot && proto_block.payload_status == PAYLOAD_STATUS_FULL { + if proto_block.slot < request_slot && proto_block.payload_status == PAYLOAD_STATUS_FULL + { 1 } else { 0 @@ -2148,7 +2149,11 @@ impl BeaconChain { &self.spec, )?; - if self.spec.fork_name_at_slot::(request_slot).gloas_enabled() { + if self + .spec + .fork_name_at_slot::(request_slot) + .gloas_enabled() + { attestation.data_mut().index = payload_status } diff --git a/beacon_node/beacon_chain/src/block_verification.rs b/beacon_node/beacon_chain/src/block_verification.rs index dea13f1eb3..2cc909f28b 100644 --- a/beacon_node/beacon_chain/src/block_verification.rs +++ b/beacon_node/beacon_chain/src/block_verification.rs @@ -98,8 +98,8 @@ use task_executor::JoinHandle; use tracing::{Instrument, Span, debug, debug_span, error, info_span, instrument, warn}; use types::{ BeaconBlockRef, BeaconState, BeaconStateError, BlobsList, ChainSpec, DataColumnSidecarList, - Epoch, EthSpec, FullPayload, Hash256, InconsistentFork, KzgProofs, - RelativeEpoch, SignedBeaconBlock, SignedBeaconBlockHeader, Slot, StatePayloadStatus, + Epoch, EthSpec, FullPayload, Hash256, InconsistentFork, KzgProofs, RelativeEpoch, + SignedBeaconBlock, SignedBeaconBlockHeader, Slot, StatePayloadStatus, data::DataColumnSidecarError, }; @@ -1948,23 +1948,13 @@ fn load_parent>( && let Ok(parent_bid_block_hash) = parent_block.payload_bid_block_hash() { if block.as_block().is_parent_block_full(parent_bid_block_hash) { - // TODO(gloas): loading the envelope here is not very efficient. - // The envelope may not have arrived yet, so we retry after a short delay. - let envelope = match chain.store.get_payload_envelope(&root)? { - Some(envelope) => envelope, - None => { - warn!( - parent_block_root = ?root, - "Parent block envelope not yet available, waiting 1s for arrival" - ); - std::thread::sleep(std::time::Duration::from_secs(1)); - chain.store.get_payload_envelope(&root)?.ok_or_else(|| { - BeaconChainError::DBInconsistent(format!( - "Missing envelope for parent block {root:?}", - )) - })? - } - }; + // The parent block's envelope must have been imported for us to load the + // full state. If it hasn't arrived yet, return an unknown parent error so + // the block gets sent to the reprocess queue. + let envelope = chain + .store + .get_payload_envelope(&root)? + .ok_or(BlockError::ParentUnknown { parent_root: root })?; (StatePayloadStatus::Full, envelope.message.state_root) } else { (StatePayloadStatus::Pending, parent_block.state_root()) 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 39dc1a4451..06818209a4 100644 --- a/beacon_node/beacon_chain/src/payload_envelope_verification/import.rs +++ b/beacon_node/beacon_chain/src/payload_envelope_verification/import.rs @@ -273,7 +273,6 @@ impl BeaconChain { return Err(EnvelopeError::BlockRootUnknown { block_root }); } - // TODO(gloas) no fork choice logic yet // Take an exclusive write-lock on fork choice. It's very important to prevent deadlocks by // avoiding taking other locks whilst holding this lock. diff --git a/beacon_node/beacon_chain/src/test_utils.rs b/beacon_node/beacon_chain/src/test_utils.rs index 85b51d442d..366d1dc831 100644 --- a/beacon_node/beacon_chain/src/test_utils.rs +++ b/beacon_node/beacon_chain/src/test_utils.rs @@ -49,10 +49,12 @@ use rayon::prelude::*; use sensitive_url::SensitiveUrl; use slot_clock::{SlotClock, TestingSlotClock}; use ssz_types::{RuntimeVariableList, VariableList}; -use state_processing::{BlockSignatureStrategy, ConsensusContext, VerifyBlockRoot, per_block_processing}; use state_processing::per_block_processing::compute_timestamp_at_slot; use state_processing::per_block_processing::deneb::kzg_commitment_to_versioned_hash; use state_processing::state_advance::complete_state_advance; +use state_processing::{ + BlockSignatureStrategy, ConsensusContext, VerifyBlockRoot, per_block_processing, +}; use std::borrow::Cow; use std::collections::{HashMap, HashSet}; use std::fmt; diff --git a/beacon_node/http_api/src/beacon/execution_payload_envelope.rs b/beacon_node/http_api/src/beacon/execution_payload_envelope.rs index e2a3c746b3..6a04274bac 100644 --- a/beacon_node/http_api/src/beacon/execution_payload_envelope.rs +++ b/beacon_node/http_api/src/beacon/execution_payload_envelope.rs @@ -134,7 +134,7 @@ pub async fn publish_execution_payload_envelope( warn!(%slot, %beacon_block_root, "Execution payload envelope rejected"); return Err(warp_utils::reject::custom_bad_request(format!( "execution payload envelope rejected, gossip verification" - ))) + ))); }; // Import the envelope locally (runs state transition and notifies the EL).