From 0a152ed68d7804d47a89356393d91940ef41b166 Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Tue, 20 Jan 2026 14:49:17 +1100 Subject: [PATCH] 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 --- consensus/types/src/core/chain_spec.rs | 12 +++- consensus/types/src/core/eth_spec.rs | 11 +++- testing/ef_tests/src/handler.rs | 12 ++++ testing/ef_tests/tests/tests.rs | 85 +++++++++++++++++++++++++- 4 files changed, 115 insertions(+), 5 deletions(-) diff --git a/consensus/types/src/core/chain_spec.rs b/consensus/types/src/core/chain_spec.rs index 1bdf6c2cb8..abc97ecf9a 100644 --- a/consensus/types/src/core/chain_spec.rs +++ b/consensus/types/src/core/chain_spec.rs @@ -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, 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 diff --git a/consensus/types/src/core/eth_spec.rs b/consensus/types/src/core/eth_spec.rs index 5160b4c813..09ef9ce8da 100644 --- a/consensus/types/src/core/eth_spec.rs +++ b/consensus/types/src/core/eth_spec.rs @@ -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() diff --git a/testing/ef_tests/src/handler.rs b/testing/ef_tests/src/handler.rs index 3fa0ef09d5..4fc3667583 100644 --- a/testing/ef_tests/src/handler.rs +++ b/testing/ef_tests/src/handler.rs @@ -305,6 +305,10 @@ impl SszStaticHandler { 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 SszStaticHandler { 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 SszStaticWithSpecHandler { 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 Handler for SszStaticHandler diff --git a/testing/ef_tests/tests/tests.rs b/testing/ef_tests/tests/tests.rs index b2f65db6f3..7d6c1b8c31 100644 --- a/testing/ef_tests/tests/tests.rs +++ b/testing/ef_tests/tests/tests.rs @@ -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::, MinimalEthSpec>::fulu_only().run(); SszStaticHandler::, MainnetEthSpec>::fulu_only().run(); + SszStaticHandler::, MinimalEthSpec>::gloas_only().run(); + SszStaticHandler::, MainnetEthSpec>::gloas_only().run(); } // Altair and later @@ -722,6 +728,81 @@ mod ssz_static { SszStaticHandler::, MinimalEthSpec>::electra_and_later() .run(); } + + // Gloas and later + #[test] + fn builder() { + SszStaticHandler::::gloas_and_later().run(); + SszStaticHandler::::gloas_and_later().run(); + } + + #[test] + fn builder_pending_payment() { + SszStaticHandler::::gloas_and_later().run(); + SszStaticHandler::::gloas_and_later().run(); + } + + #[test] + fn builder_pending_withdrawal() { + SszStaticHandler::::gloas_and_later().run(); + SszStaticHandler::::gloas_and_later().run(); + } + + #[test] + fn payload_attestation_data() { + SszStaticHandler::::gloas_and_later().run(); + SszStaticHandler::::gloas_and_later().run(); + } + + #[test] + fn payload_attestation() { + SszStaticHandler::, MinimalEthSpec>::gloas_and_later() + .run(); + SszStaticHandler::, MainnetEthSpec>::gloas_and_later() + .run(); + } + + #[test] + fn payload_attestation_message() { + SszStaticHandler::::gloas_and_later().run(); + SszStaticHandler::::gloas_and_later().run(); + } + + #[test] + fn indexed_payload_attestation() { + SszStaticHandler::, MinimalEthSpec>::gloas_and_later() + .run(); + SszStaticHandler::, MainnetEthSpec>::gloas_and_later() + .run(); + } + + #[test] + fn execution_payload_bid() { + SszStaticHandler::::gloas_and_later().run(); + SszStaticHandler::::gloas_and_later().run(); + } + + #[test] + fn signed_execution_payload_bid() { + SszStaticHandler::::gloas_and_later().run(); + SszStaticHandler::::gloas_and_later().run(); + } + + #[test] + fn execution_payload_envelope() { + SszStaticHandler::, MinimalEthSpec>::gloas_and_later() + .run(); + SszStaticHandler::, MainnetEthSpec>::gloas_and_later() + .run(); + } + + #[test] + fn signed_execution_payload_envelope() { + SszStaticHandler::, MinimalEthSpec>::gloas_and_later() + .run(); + SszStaticHandler::, MainnetEthSpec>::gloas_and_later() + .run(); + } } #[test]