Fix gloas consensus-specs discrepancies and add EF tests

- Fix DOMAIN_BEACON_BUILDER value (0x1B -> 0x0B per spec)
- Add DOMAIN_PROPOSER_PREFERENCES (0x0D)
- Add min_builder_withdrawability_delay config (4096 epochs)
- Add MaxBuildersPerWithdrawalsSweep to EthSpec trait
- Add gloas_only/gloas_and_later handlers for EF tests
- Add SSZ static tests for all new Gloas types
This commit is contained in:
Jimmy Chen
2026-01-20 14:49:17 +11:00
parent 5897ea037b
commit 0a152ed68d
4 changed files with 115 additions and 5 deletions

View File

@@ -36,6 +36,7 @@ pub enum Domain {
SyncCommitteeSelectionProof,
BeaconBuilder,
PTCAttester,
ProposerPreferences,
ApplicationMask(ApplicationDomain),
}
@@ -130,6 +131,7 @@ pub struct ChainSpec {
pub(crate) domain_aggregate_and_proof: u32,
pub(crate) domain_beacon_builder: u32,
pub(crate) domain_ptc_attester: u32,
pub(crate) domain_proposer_preferences: u32,
/*
* Fork choice
@@ -234,6 +236,7 @@ pub struct ChainSpec {
pub gloas_fork_epoch: Option<Epoch>,
pub builder_payment_threshold_numerator: u64,
pub builder_payment_threshold_denominator: u64,
pub min_builder_withdrawability_delay: Epoch,
/*
* Networking
@@ -500,6 +503,7 @@ impl ChainSpec {
Domain::AggregateAndProof => self.domain_aggregate_and_proof,
Domain::BeaconBuilder => self.domain_beacon_builder,
Domain::PTCAttester => self.domain_ptc_attester,
Domain::ProposerPreferences => self.domain_proposer_preferences,
Domain::SyncCommittee => self.domain_sync_committee,
Domain::ContributionAndProof => self.domain_contribution_and_proof,
Domain::SyncCommitteeSelectionProof => self.domain_sync_committee_selection_proof,
@@ -977,8 +981,9 @@ impl ChainSpec {
domain_voluntary_exit: 4,
domain_selection_proof: 5,
domain_aggregate_and_proof: 6,
domain_beacon_builder: 0x1B,
domain_beacon_builder: 0x0B,
domain_ptc_attester: 0x0C,
domain_proposer_preferences: 0x0D,
/*
* Fork choice
@@ -1102,6 +1107,7 @@ impl ChainSpec {
gloas_fork_epoch: None,
builder_payment_threshold_numerator: 6,
builder_payment_threshold_denominator: 10,
min_builder_withdrawability_delay: Epoch::new(4096),
/*
* Network specific
@@ -1350,8 +1356,9 @@ impl ChainSpec {
domain_voluntary_exit: 4,
domain_selection_proof: 5,
domain_aggregate_and_proof: 6,
domain_beacon_builder: 0x1B,
domain_beacon_builder: 0x0B,
domain_ptc_attester: 0x0C,
domain_proposer_preferences: 0x0D,
/*
* Fork choice
@@ -1474,6 +1481,7 @@ impl ChainSpec {
gloas_fork_epoch: None,
builder_payment_threshold_numerator: 6,
builder_payment_threshold_denominator: 10,
min_builder_withdrawability_delay: Epoch::new(4096),
/*
* Network specific

View File

@@ -7,7 +7,7 @@ use safe_arith::{ArithError, SafeArith};
use serde::{Deserialize, Serialize};
use typenum::{
U0, U1, U2, U4, U8, U16, U17, U32, U64, U128, U256, U512, U625, U1024, U2048, U4096, U8192,
U65536, U131072, U262144, U1048576, U16777216, U33554432, U134217728, U1073741824,
U16384, U65536, U131072, U262144, U1048576, U16777216, U33554432, U134217728, U1073741824,
U1099511627776, UInt, Unsigned, bit::B0,
};
@@ -179,6 +179,7 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq +
type MaxPayloadAttestations: Unsigned + Clone + Sync + Send + Debug + PartialEq;
type BuilderPendingPaymentsLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
type BuilderPendingWithdrawalsLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
type MaxBuildersPerWithdrawalsSweep: Unsigned + Clone + Sync + Send + Debug + PartialEq;
fn default_spec() -> ChainSpec;
@@ -431,6 +432,11 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq +
fn max_payload_attestations() -> usize {
Self::MaxPayloadAttestations::to_usize()
}
/// Returns the `MaxBuildersPerWithdrawalsSweep` constant for this specification.
fn max_builders_per_withdrawals_sweep() -> usize {
Self::MaxBuildersPerWithdrawalsSweep::to_usize()
}
}
/// Macro to inherit some type values from another EthSpec.
@@ -505,6 +511,7 @@ impl EthSpec for MainnetEthSpec {
type MaxPendingDepositsPerEpoch = U16;
type PTCSize = U512;
type MaxPayloadAttestations = U4;
type MaxBuildersPerWithdrawalsSweep = U16384;
fn default_spec() -> ChainSpec {
ChainSpec::mainnet()
@@ -549,6 +556,7 @@ impl EthSpec for MinimalEthSpec {
type ProposerLookaheadSlots = U16; // Derived from (MIN_SEED_LOOKAHEAD + 1) * SLOTS_PER_EPOCH
type BuilderPendingPaymentsLimit = U16; // 2 * SLOTS_PER_EPOCH = 2 * 8 = 16
type PTCSize = U2;
type MaxBuildersPerWithdrawalsSweep = U16;
params_from_eth_spec!(MainnetEthSpec {
JustificationBitsLength,
@@ -656,6 +664,7 @@ impl EthSpec for GnosisEthSpec {
type BuilderRegistryLimit = U1099511627776;
type PTCSize = U512;
type MaxPayloadAttestations = U2;
type MaxBuildersPerWithdrawalsSweep = U16384;
fn default_spec() -> ChainSpec {
ChainSpec::gnosis()

View File

@@ -305,6 +305,10 @@ impl<T, E> SszStaticHandler<T, E> {
Self::for_forks(vec![ForkName::Fulu])
}
pub fn gloas_only() -> Self {
Self::for_forks(vec![ForkName::Gloas])
}
pub fn altair_and_later() -> Self {
Self::for_forks(ForkName::list_all()[1..].to_vec())
}
@@ -329,6 +333,10 @@ impl<T, E> SszStaticHandler<T, E> {
Self::for_forks(ForkName::list_all()[6..].to_vec())
}
pub fn gloas_and_later() -> Self {
Self::for_forks(ForkName::list_all()[7..].to_vec())
}
pub fn pre_electra() -> Self {
Self::for_forks(ForkName::list_all()[0..5].to_vec())
}
@@ -362,6 +370,10 @@ impl<T, E> SszStaticWithSpecHandler<T, E> {
pub fn fulu_and_later() -> Self {
Self::for_forks(ForkName::list_all()[6..].to_vec())
}
pub fn gloas_and_later() -> Self {
Self::for_forks(ForkName::list_all()[7..].to_vec())
}
}
impl<T, E> Handler for SszStaticHandler<T, E>

View File

@@ -241,8 +241,12 @@ mod ssz_static {
use ef_tests::{Handler, SszStaticHandler, SszStaticTHCHandler, SszStaticWithSpecHandler};
use types::state::HistoricalSummary;
use types::{
AttesterSlashingBase, AttesterSlashingElectra, ConsolidationRequest, DepositRequest,
LightClientBootstrapAltair, PendingDeposit, PendingPartialWithdrawal, WithdrawalRequest, *,
AttesterSlashingBase, AttesterSlashingElectra, Builder, BuilderPendingPayment,
BuilderPendingWithdrawal, ConsolidationRequest, DepositRequest, ExecutionPayloadBid,
ExecutionPayloadEnvelope, IndexedPayloadAttestation, LightClientBootstrapAltair,
PayloadAttestation, PayloadAttestationData, PayloadAttestationMessage, PendingDeposit,
PendingPartialWithdrawal, SignedExecutionPayloadBid, SignedExecutionPayloadEnvelope,
WithdrawalRequest, *,
};
ssz_static_test!(attestation_data, AttestationData);
@@ -368,6 +372,8 @@ mod ssz_static {
.run();
SszStaticHandler::<BeaconBlockBodyFulu<MinimalEthSpec>, MinimalEthSpec>::fulu_only().run();
SszStaticHandler::<BeaconBlockBodyFulu<MainnetEthSpec>, MainnetEthSpec>::fulu_only().run();
SszStaticHandler::<BeaconBlockBodyGloas<MinimalEthSpec>, MinimalEthSpec>::gloas_only().run();
SszStaticHandler::<BeaconBlockBodyGloas<MainnetEthSpec>, MainnetEthSpec>::gloas_only().run();
}
// Altair and later
@@ -722,6 +728,81 @@ mod ssz_static {
SszStaticHandler::<ExecutionRequests<MinimalEthSpec>, MinimalEthSpec>::electra_and_later()
.run();
}
// Gloas and later
#[test]
fn builder() {
SszStaticHandler::<Builder, MinimalEthSpec>::gloas_and_later().run();
SszStaticHandler::<Builder, MainnetEthSpec>::gloas_and_later().run();
}
#[test]
fn builder_pending_payment() {
SszStaticHandler::<BuilderPendingPayment, MinimalEthSpec>::gloas_and_later().run();
SszStaticHandler::<BuilderPendingPayment, MainnetEthSpec>::gloas_and_later().run();
}
#[test]
fn builder_pending_withdrawal() {
SszStaticHandler::<BuilderPendingWithdrawal, MinimalEthSpec>::gloas_and_later().run();
SszStaticHandler::<BuilderPendingWithdrawal, MainnetEthSpec>::gloas_and_later().run();
}
#[test]
fn payload_attestation_data() {
SszStaticHandler::<PayloadAttestationData, MinimalEthSpec>::gloas_and_later().run();
SszStaticHandler::<PayloadAttestationData, MainnetEthSpec>::gloas_and_later().run();
}
#[test]
fn payload_attestation() {
SszStaticHandler::<PayloadAttestation<MinimalEthSpec>, MinimalEthSpec>::gloas_and_later()
.run();
SszStaticHandler::<PayloadAttestation<MainnetEthSpec>, MainnetEthSpec>::gloas_and_later()
.run();
}
#[test]
fn payload_attestation_message() {
SszStaticHandler::<PayloadAttestationMessage, MinimalEthSpec>::gloas_and_later().run();
SszStaticHandler::<PayloadAttestationMessage, MainnetEthSpec>::gloas_and_later().run();
}
#[test]
fn indexed_payload_attestation() {
SszStaticHandler::<IndexedPayloadAttestation<MinimalEthSpec>, MinimalEthSpec>::gloas_and_later()
.run();
SszStaticHandler::<IndexedPayloadAttestation<MainnetEthSpec>, MainnetEthSpec>::gloas_and_later()
.run();
}
#[test]
fn execution_payload_bid() {
SszStaticHandler::<ExecutionPayloadBid, MinimalEthSpec>::gloas_and_later().run();
SszStaticHandler::<ExecutionPayloadBid, MainnetEthSpec>::gloas_and_later().run();
}
#[test]
fn signed_execution_payload_bid() {
SszStaticHandler::<SignedExecutionPayloadBid, MinimalEthSpec>::gloas_and_later().run();
SszStaticHandler::<SignedExecutionPayloadBid, MainnetEthSpec>::gloas_and_later().run();
}
#[test]
fn execution_payload_envelope() {
SszStaticHandler::<ExecutionPayloadEnvelope<MinimalEthSpec>, MinimalEthSpec>::gloas_and_later()
.run();
SszStaticHandler::<ExecutionPayloadEnvelope<MainnetEthSpec>, MainnetEthSpec>::gloas_and_later()
.run();
}
#[test]
fn signed_execution_payload_envelope() {
SszStaticHandler::<SignedExecutionPayloadEnvelope<MinimalEthSpec>, MinimalEthSpec>::gloas_and_later()
.run();
SszStaticHandler::<SignedExecutionPayloadEnvelope<MainnetEthSpec>, MainnetEthSpec>::gloas_and_later()
.run();
}
}
#[test]