Gloas spec v1.7.0-alpha.5 and beacon_chain tests (#8998)

Fix database pruning post-Gloas


  - Fix DB pruning logic (and state summaries DAG)
- Get the `beacon_chain` tests running with `FORK_NAME=gloas` 🎉


Co-Authored-By: Michael Sproul <michael@sigmaprime.io>

Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com>

Co-Authored-By: Eitan Seri- Levi <eserilev@gmail.com>

Co-Authored-By: dapplion <35266934+dapplion@users.noreply.github.com>

Co-Authored-By: Eitan Seri-Levi <eserilev@ucsc.edu>
This commit is contained in:
Michael Sproul
2026-04-21 16:29:15 +10:00
committed by GitHub
parent c028bac28d
commit cf3d5e285e
82 changed files with 1513 additions and 1391 deletions

View File

@@ -1,10 +1,7 @@
use std::sync::Arc;
use slot_clock::SlotClock;
use state_processing::{
VerifySignatures,
envelope_processing::{VerifyStateRoot, process_execution_payload_envelope},
};
use state_processing::{VerifySignatures, envelope_processing::verify_execution_payload_envelope};
use types::EthSpec;
use crate::{
@@ -77,16 +74,15 @@ impl<T: BeaconChainTypes> GossipVerifiedEnvelope<T> {
} else {
load_snapshot_from_state_root::<T>(block_root, self.block.state_root(), &chain.store)?
};
let mut state = snapshot.pre_state;
let state = snapshot.pre_state;
// All the state modifications are done in envelope_processing
process_execution_payload_envelope(
&mut state,
Some(snapshot.state_root),
// Verify the envelope against the state (no state mutation).
verify_execution_payload_envelope(
&state,
&signed_envelope,
// verify signature already done for GossipVerifiedEnvelope
VerifySignatures::False,
VerifyStateRoot::True,
snapshot.state_root,
&chain.spec,
)?;
@@ -97,7 +93,7 @@ impl<T: BeaconChainTypes> GossipVerifiedEnvelope<T> {
},
import_data: EnvelopeImportData {
block_root,
post_state: Box::new(state),
_phantom: Default::default(),
},
payload_verification_handle,
})

View File

@@ -42,18 +42,18 @@ pub(crate) fn verify_envelope_consistency<E: EthSpec>(
) -> Result<(), EnvelopeError> {
// Check that the envelope's slot isn't from a slot prior
// to the latest finalized slot.
if envelope.slot < latest_finalized_slot {
if envelope.slot() < latest_finalized_slot {
return Err(EnvelopeError::PriorToFinalization {
payload_slot: envelope.slot,
payload_slot: envelope.slot(),
latest_finalized_slot,
});
}
// Check that the slot of the envelope matches the slot of the block.
if envelope.slot != block.slot() {
if envelope.slot() != block.slot() {
return Err(EnvelopeError::SlotMismatch {
block: block.slot(),
envelope: envelope.slot,
envelope: envelope.slot(),
});
}
@@ -144,7 +144,7 @@ impl<T: BeaconChainTypes> GossipVerifiedEnvelope<T> {
// validator pubkey cache for the proposer's pubkey, avoiding a state load from disk.
// For external builder envelopes, we must load the state to access the builder registry.
let builder_index = envelope.builder_index;
let block_slot = envelope.slot;
let block_slot = envelope.slot();
let envelope_epoch = block_slot.epoch(T::EthSpec::slots_per_epoch());
// Since the payload's block is already guaranteed to be imported, the associated `proto_block.current_epoch_shuffling_id`
// already carries the correct `shuffling_decision_block`.
@@ -224,7 +224,6 @@ impl<T: BeaconChainTypes> GossipVerifiedEnvelope<T> {
builder_index,
block_hash: signed_envelope.message.payload.block_hash,
block_root: beacon_block_root,
state_root: signed_envelope.message.state_root,
},
));
}
@@ -334,13 +333,12 @@ mod tests {
ExecutionPayloadEnvelope {
payload: ExecutionPayloadGloas {
block_hash,
slot_number: slot,
..ExecutionPayloadGloas::default()
},
execution_requests: ExecutionRequests::default(),
builder_index,
beacon_block_root: Hash256::ZERO,
slot,
state_root: Hash256::ZERO,
}
}
@@ -365,6 +363,7 @@ mod tests {
voluntary_exits: VariableList::empty(),
sync_aggregate: SyncAggregate::empty(),
bls_to_execution_changes: VariableList::empty(),
parent_execution_requests: ExecutionRequests::default(),
signed_execution_payload_bid: SignedExecutionPayloadBid::empty(),
payload_attestations: VariableList::empty(),
_phantom: PhantomData,

View File

@@ -6,7 +6,7 @@ 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, SignedExecutionPayloadEnvelope};
use types::{BlockImportSource, Hash256, SignedExecutionPayloadEnvelope};
use super::{
AvailableEnvelope, AvailableExecutedEnvelope, EnvelopeError, EnvelopeImportData,
@@ -198,7 +198,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
let EnvelopeImportData {
block_root,
post_state,
_phantom,
} = import_data;
let block_root = {
@@ -208,7 +208,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
chain.import_execution_payload_envelope(
envelope,
block_root,
*post_state,
payload_verification_outcome.payload_verification_status,
)
},
@@ -231,7 +230,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
&self,
signed_envelope: AvailableEnvelope<T::EthSpec>,
block_root: Hash256,
state: BeaconState<T::EthSpec>,
payload_verification_status: PayloadVerificationStatus,
) -> Result<Hash256, EnvelopeError> {
// Everything in this initial section is on the hot path for processing the envelope.
@@ -285,10 +283,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
block_root,
signed_envelope.clone(),
));
ops.push(StoreOp::PutState(
signed_envelope.message.state_root,
&state,
));
let db_span = info_span!("persist_payloads_and_blobs").entered();
@@ -365,7 +359,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
builder_index: signed_envelope.message.builder_index,
block_hash: signed_envelope.block_hash(),
block_root,
state_root: signed_envelope.message.state_root,
execution_optimistic: payload_verification_status.is_optimistic(),
}));
}

View File

@@ -18,11 +18,11 @@
//!
//! ```
use std::marker::PhantomData;
use std::sync::Arc;
use store::Error as DBError;
use state_processing::{BlockProcessingError, envelope_processing::EnvelopeProcessingError};
use store::Error as DBError;
use tracing::instrument;
use types::{
BeaconState, BeaconStateError, ChainSpec, DataColumnSidecarList, EthSpec, ExecutionBlockHash,
@@ -41,10 +41,11 @@ mod payload_notifier;
pub use execution_pending_envelope::ExecutionPendingEnvelope;
// TODO(gloas): could remove this type completely, or remove the generic
#[derive(PartialEq)]
pub struct EnvelopeImportData<E: EthSpec> {
pub block_root: Hash256,
pub post_state: Box<BeaconState<E>>,
_phantom: PhantomData<E>,
}
#[derive(Debug)]
@@ -249,9 +250,6 @@ impl From<EnvelopeProcessingError> for EnvelopeError {
committed_bid,
envelope,
},
EnvelopeProcessingError::BlockProcessingError(e) => {
EnvelopeError::BlockProcessingError(e)
}
e => EnvelopeError::EnvelopeProcessingError(e),
}
}