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

@@ -99,8 +99,7 @@ use tracing::{Instrument, Span, debug, debug_span, error, info_span, instrument}
use types::{
BeaconBlockRef, BeaconState, BeaconStateError, BlobsList, ChainSpec, DataColumnSidecarList,
Epoch, EthSpec, FullPayload, Hash256, InconsistentFork, KzgProofs, RelativeEpoch,
SignedBeaconBlock, SignedBeaconBlockHeader, Slot, StatePayloadStatus,
data::DataColumnSidecarError,
SignedBeaconBlock, SignedBeaconBlockHeader, Slot, data::DataColumnSidecarError,
};
/// Maximum block slot number. Block with slots bigger than this constant will NOT be processed.
@@ -1509,11 +1508,7 @@ impl<T: BeaconChainTypes> ExecutionPendingBlock<T> {
let distance = block.slot().as_u64().saturating_sub(state.slot().as_u64());
for _ in 0..distance {
// TODO(gloas): could do a similar optimisation here for Full blocks if we have access
// to the parent envelope and its `state_root`.
let state_root = if parent.beacon_block.slot() == state.slot()
&& state.payload_status() == StatePayloadStatus::Pending
{
let state_root = if parent.beacon_block.slot() == state.slot() {
// If it happens that `pre_state` has *not* already been advanced forward a single
// slot, then there is no need to compute the state root for this
// `per_slot_processing` call since that state root is already stored in the parent
@@ -1957,37 +1952,9 @@ fn load_parent<T: BeaconChainTypes, B: AsBlock<T::EthSpec>>(
// particularly important if `block` descends from the finalized/split block, but at a slot
// prior to the finalized slot (which is invalid and inaccessible in our DB schema).
//
// Post-Gloas we must also fetch a state with the correct payload status. If the current
// block builds upon the payload of its parent block, then we know the parent block is FULL
// and we need to load the full state.
let (payload_status, parent_state_root) = if parent_block.slot() == chain.spec.genesis_slot
{
// Genesis state is always pending, there is no such thing as a "genesis envelope".
// See: https://github.com/ethereum/consensus-specs/issues/5043
(StatePayloadStatus::Pending, parent_block.state_root())
} else if !block.as_block().fork_name_unchecked().gloas_enabled() {
// All pre-Gloas parent states are pending.
(StatePayloadStatus::Pending, parent_block.state_root())
} else if let Ok(parent_bid_block_hash) = parent_block.payload_bid_block_hash()
&& block.as_block().is_parent_block_full(parent_bid_block_hash)
{
// Post-Gloas Full block case.
// TODO(gloas): loading the envelope here is not very efficient
let Some(envelope) = chain.store.get_payload_envelope(&root)? else {
return Err(BeaconChainError::DBInconsistent(format!(
"Missing envelope for parent block {root:?}",
))
.into());
};
let state_root = envelope.message.state_root;
(StatePayloadStatus::Full, state_root)
} else {
// Post-Gloas empty block case (also covers the Gloas fork transition).
(StatePayloadStatus::Pending, parent_block.state_root())
};
let (parent_state_root, state) = chain
.store
.get_advanced_hot_state(root, payload_status, block.slot(), parent_state_root)?
.get_advanced_hot_state(root, block.slot(), parent_block.state_root())?
.ok_or_else(|| {
BeaconChainError::DBInconsistent(
format!("Missing state for parent block {root:?}",),
@@ -2010,9 +1977,7 @@ fn load_parent<T: BeaconChainTypes, B: AsBlock<T::EthSpec>>(
);
}
let beacon_state_root = if state.slot() == parent_block.slot()
&& let StatePayloadStatus::Pending = payload_status
{
let beacon_state_root = if state.slot() == parent_block.slot() {
// Sanity check.
if parent_state_root != parent_block.state_root() {
return Err(BeaconChainError::DBInconsistent(format!(