Add Gloas boilerplate (#7728)

Adds the required boilerplate code for the Gloas (Glamsterdam) hard fork. This allows PRs testing Gloas-candidate features to test fork transition.

This also includes de-duplication of post-Bellatrix readiness notifiers from #6797 (credit to @dapplion)
This commit is contained in:
Mac L
2025-08-26 12:49:48 +10:00
committed by GitHub
parent daf1c7c3af
commit e438691683
75 changed files with 1801 additions and 917 deletions

View File

@@ -2,7 +2,7 @@ use crate::{DBColumn, Error, StoreItem};
use ssz::{Decode, Encode};
use types::{
EthSpec, ExecutionPayload, ExecutionPayloadBellatrix, ExecutionPayloadCapella,
ExecutionPayloadDeneb, ExecutionPayloadElectra, ExecutionPayloadFulu,
ExecutionPayloadDeneb, ExecutionPayloadElectra, ExecutionPayloadFulu, ExecutionPayloadGloas,
};
macro_rules! impl_store_item {
@@ -27,6 +27,7 @@ impl_store_item!(ExecutionPayloadCapella);
impl_store_item!(ExecutionPayloadDeneb);
impl_store_item!(ExecutionPayloadElectra);
impl_store_item!(ExecutionPayloadFulu);
impl_store_item!(ExecutionPayloadGloas);
/// This fork-agnostic implementation should be only used for writing.
///
@@ -42,24 +43,28 @@ impl<E: EthSpec> StoreItem for ExecutionPayload<E> {
}
fn from_store_bytes(bytes: &[u8]) -> Result<Self, Error> {
ExecutionPayloadFulu::from_ssz_bytes(bytes)
.map(Self::Fulu)
.or_else(|_| {
ExecutionPayloadElectra::from_ssz_bytes(bytes)
.map(Self::Electra)
.or_else(|_| {
ExecutionPayloadDeneb::from_ssz_bytes(bytes)
.map(Self::Deneb)
.or_else(|_| {
ExecutionPayloadCapella::from_ssz_bytes(bytes)
.map(Self::Capella)
.or_else(|_| {
ExecutionPayloadBellatrix::from_ssz_bytes(bytes)
.map(Self::Bellatrix)
})
})
})
})
if let Ok(payload) = ExecutionPayloadGloas::from_ssz_bytes(bytes) {
return Ok(Self::Gloas(payload));
}
if let Ok(payload) = ExecutionPayloadFulu::from_ssz_bytes(bytes) {
return Ok(Self::Fulu(payload));
}
if let Ok(payload) = ExecutionPayloadElectra::from_ssz_bytes(bytes) {
return Ok(Self::Electra(payload));
}
if let Ok(payload) = ExecutionPayloadDeneb::from_ssz_bytes(bytes) {
return Ok(Self::Deneb(payload));
}
if let Ok(payload) = ExecutionPayloadCapella::from_ssz_bytes(bytes) {
return Ok(Self::Capella(payload));
}
ExecutionPayloadBellatrix::from_ssz_bytes(bytes)
.map(Self::Bellatrix)
.map_err(Into::into)
}
}

View File

@@ -16,7 +16,7 @@ use types::*;
///
/// This can be deleted once schema versions prior to V22 are no longer supported.
#[superstruct(
variants(Base, Altair, Bellatrix, Capella, Deneb, Electra, Fulu),
variants(Base, Altair, Bellatrix, Capella, Deneb, Electra, Fulu, Gloas),
variant_attributes(derive(Debug, PartialEq, Clone, Encode, Decode))
)]
#[derive(Debug, PartialEq, Clone, Encode)]
@@ -68,9 +68,9 @@ where
pub current_epoch_attestations: List<PendingAttestation<E>, E::MaxPendingAttestations>,
// Participation (Altair and later)
#[superstruct(only(Altair, Bellatrix, Capella, Deneb, Electra, Fulu))]
#[superstruct(only(Altair, Bellatrix, Capella, Deneb, Electra, Fulu, Gloas))]
pub previous_epoch_participation: List<ParticipationFlags, E::ValidatorRegistryLimit>,
#[superstruct(only(Altair, Bellatrix, Capella, Deneb, Electra, Fulu))]
#[superstruct(only(Altair, Bellatrix, Capella, Deneb, Electra, Fulu, Gloas))]
pub current_epoch_participation: List<ParticipationFlags, E::ValidatorRegistryLimit>,
// Finality
@@ -80,13 +80,13 @@ where
pub finalized_checkpoint: Checkpoint,
// Inactivity
#[superstruct(only(Altair, Bellatrix, Capella, Deneb, Electra, Fulu))]
#[superstruct(only(Altair, Bellatrix, Capella, Deneb, Electra, Fulu, Gloas))]
pub inactivity_scores: List<u64, E::ValidatorRegistryLimit>,
// Light-client sync committees
#[superstruct(only(Altair, Bellatrix, Capella, Deneb, Electra, Fulu))]
#[superstruct(only(Altair, Bellatrix, Capella, Deneb, Electra, Fulu, Gloas))]
pub current_sync_committee: Arc<SyncCommittee<E>>,
#[superstruct(only(Altair, Bellatrix, Capella, Deneb, Electra, Fulu))]
#[superstruct(only(Altair, Bellatrix, Capella, Deneb, Electra, Fulu, Gloas))]
pub next_sync_committee: Arc<SyncCommittee<E>>,
// Execution
@@ -115,39 +115,44 @@ where
partial_getter(rename = "latest_execution_payload_header_fulu")
)]
pub latest_execution_payload_header: ExecutionPayloadHeaderFulu<E>,
#[superstruct(
only(Gloas),
partial_getter(rename = "latest_execution_payload_header_gloas")
)]
pub latest_execution_payload_header: ExecutionPayloadHeaderGloas<E>,
// Capella
#[superstruct(only(Capella, Deneb, Electra, Fulu))]
#[superstruct(only(Capella, Deneb, Electra, Fulu, Gloas))]
pub next_withdrawal_index: u64,
#[superstruct(only(Capella, Deneb, Electra, Fulu))]
#[superstruct(only(Capella, Deneb, Electra, Fulu, Gloas))]
pub next_withdrawal_validator_index: u64,
#[ssz(skip_serializing, skip_deserializing)]
#[superstruct(only(Capella, Deneb, Electra, Fulu))]
#[superstruct(only(Capella, Deneb, Electra, Fulu, Gloas))]
pub historical_summaries: Option<List<HistoricalSummary, E::HistoricalRootsLimit>>,
// Electra
#[superstruct(only(Electra, Fulu))]
#[superstruct(only(Electra, Fulu, Gloas))]
pub deposit_requests_start_index: u64,
#[superstruct(only(Electra, Fulu))]
#[superstruct(only(Electra, Fulu, Gloas))]
pub deposit_balance_to_consume: u64,
#[superstruct(only(Electra, Fulu))]
#[superstruct(only(Electra, Fulu, Gloas))]
pub exit_balance_to_consume: u64,
#[superstruct(only(Electra, Fulu))]
#[superstruct(only(Electra, Fulu, Gloas))]
pub earliest_exit_epoch: Epoch,
#[superstruct(only(Electra, Fulu))]
#[superstruct(only(Electra, Fulu, Gloas))]
pub consolidation_balance_to_consume: u64,
#[superstruct(only(Electra, Fulu))]
#[superstruct(only(Electra, Fulu, Gloas))]
pub earliest_consolidation_epoch: Epoch,
#[superstruct(only(Electra, Fulu))]
#[superstruct(only(Electra, Fulu, Gloas))]
pub pending_deposits: List<PendingDeposit, E::PendingDepositsLimit>,
#[superstruct(only(Electra, Fulu))]
#[superstruct(only(Electra, Fulu, Gloas))]
pub pending_partial_withdrawals:
List<PendingPartialWithdrawal, E::PendingPartialWithdrawalsLimit>,
#[superstruct(only(Electra, Fulu))]
#[superstruct(only(Electra, Fulu, Gloas))]
pub pending_consolidations: List<PendingConsolidation, E::PendingConsolidationsLimit>,
#[superstruct(only(Fulu))]
#[superstruct(only(Fulu, Gloas))]
pub proposer_lookahead: Vector<u64, E::ProposerLookaheadSlots>,
}
@@ -450,6 +455,32 @@ impl<E: EthSpec> TryInto<BeaconState<E>> for PartialBeaconState<E> {
],
[historical_summaries]
),
PartialBeaconState::Gloas(inner) => impl_try_into_beacon_state!(
inner,
Gloas,
BeaconStateGloas,
[
previous_epoch_participation,
current_epoch_participation,
current_sync_committee,
next_sync_committee,
inactivity_scores,
latest_execution_payload_header,
next_withdrawal_index,
next_withdrawal_validator_index,
deposit_requests_start_index,
deposit_balance_to_consume,
exit_balance_to_consume,
earliest_exit_epoch,
consolidation_balance_to_consume,
earliest_consolidation_epoch,
pending_deposits,
pending_partial_withdrawals,
pending_consolidations,
proposer_lookahead
],
[historical_summaries]
),
};
Ok(state)
}