Skip to content

Commit 0a152ed

Browse files
committed
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
1 parent 5897ea0 commit 0a152ed

File tree

4 files changed

+115
-5
lines changed

4 files changed

+115
-5
lines changed

consensus/types/src/core/chain_spec.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub enum Domain {
3636
SyncCommitteeSelectionProof,
3737
BeaconBuilder,
3838
PTCAttester,
39+
ProposerPreferences,
3940
ApplicationMask(ApplicationDomain),
4041
}
4142

@@ -130,6 +131,7 @@ pub struct ChainSpec {
130131
pub(crate) domain_aggregate_and_proof: u32,
131132
pub(crate) domain_beacon_builder: u32,
132133
pub(crate) domain_ptc_attester: u32,
134+
pub(crate) domain_proposer_preferences: u32,
133135

134136
/*
135137
* Fork choice
@@ -234,6 +236,7 @@ pub struct ChainSpec {
234236
pub gloas_fork_epoch: Option<Epoch>,
235237
pub builder_payment_threshold_numerator: u64,
236238
pub builder_payment_threshold_denominator: u64,
239+
pub min_builder_withdrawability_delay: Epoch,
237240

238241
/*
239242
* Networking
@@ -500,6 +503,7 @@ impl ChainSpec {
500503
Domain::AggregateAndProof => self.domain_aggregate_and_proof,
501504
Domain::BeaconBuilder => self.domain_beacon_builder,
502505
Domain::PTCAttester => self.domain_ptc_attester,
506+
Domain::ProposerPreferences => self.domain_proposer_preferences,
503507
Domain::SyncCommittee => self.domain_sync_committee,
504508
Domain::ContributionAndProof => self.domain_contribution_and_proof,
505509
Domain::SyncCommitteeSelectionProof => self.domain_sync_committee_selection_proof,
@@ -977,8 +981,9 @@ impl ChainSpec {
977981
domain_voluntary_exit: 4,
978982
domain_selection_proof: 5,
979983
domain_aggregate_and_proof: 6,
980-
domain_beacon_builder: 0x1B,
984+
domain_beacon_builder: 0x0B,
981985
domain_ptc_attester: 0x0C,
986+
domain_proposer_preferences: 0x0D,
982987

983988
/*
984989
* Fork choice
@@ -1102,6 +1107,7 @@ impl ChainSpec {
11021107
gloas_fork_epoch: None,
11031108
builder_payment_threshold_numerator: 6,
11041109
builder_payment_threshold_denominator: 10,
1110+
min_builder_withdrawability_delay: Epoch::new(4096),
11051111

11061112
/*
11071113
* Network specific
@@ -1350,8 +1356,9 @@ impl ChainSpec {
13501356
domain_voluntary_exit: 4,
13511357
domain_selection_proof: 5,
13521358
domain_aggregate_and_proof: 6,
1353-
domain_beacon_builder: 0x1B,
1359+
domain_beacon_builder: 0x0B,
13541360
domain_ptc_attester: 0x0C,
1361+
domain_proposer_preferences: 0x0D,
13551362

13561363
/*
13571364
* Fork choice
@@ -1474,6 +1481,7 @@ impl ChainSpec {
14741481
gloas_fork_epoch: None,
14751482
builder_payment_threshold_numerator: 6,
14761483
builder_payment_threshold_denominator: 10,
1484+
min_builder_withdrawability_delay: Epoch::new(4096),
14771485

14781486
/*
14791487
* Network specific

consensus/types/src/core/eth_spec.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use safe_arith::{ArithError, SafeArith};
77
use serde::{Deserialize, Serialize};
88
use typenum::{
99
U0, U1, U2, U4, U8, U16, U17, U32, U64, U128, U256, U512, U625, U1024, U2048, U4096, U8192,
10-
U65536, U131072, U262144, U1048576, U16777216, U33554432, U134217728, U1073741824,
10+
U16384, U65536, U131072, U262144, U1048576, U16777216, U33554432, U134217728, U1073741824,
1111
U1099511627776, UInt, Unsigned, bit::B0,
1212
};
1313

@@ -179,6 +179,7 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq +
179179
type MaxPayloadAttestations: Unsigned + Clone + Sync + Send + Debug + PartialEq;
180180
type BuilderPendingPaymentsLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
181181
type BuilderPendingWithdrawalsLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
182+
type MaxBuildersPerWithdrawalsSweep: Unsigned + Clone + Sync + Send + Debug + PartialEq;
182183

183184
fn default_spec() -> ChainSpec;
184185

@@ -431,6 +432,11 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq +
431432
fn max_payload_attestations() -> usize {
432433
Self::MaxPayloadAttestations::to_usize()
433434
}
435+
436+
/// Returns the `MaxBuildersPerWithdrawalsSweep` constant for this specification.
437+
fn max_builders_per_withdrawals_sweep() -> usize {
438+
Self::MaxBuildersPerWithdrawalsSweep::to_usize()
439+
}
434440
}
435441

436442
/// Macro to inherit some type values from another EthSpec.
@@ -505,6 +511,7 @@ impl EthSpec for MainnetEthSpec {
505511
type MaxPendingDepositsPerEpoch = U16;
506512
type PTCSize = U512;
507513
type MaxPayloadAttestations = U4;
514+
type MaxBuildersPerWithdrawalsSweep = U16384;
508515

509516
fn default_spec() -> ChainSpec {
510517
ChainSpec::mainnet()
@@ -549,6 +556,7 @@ impl EthSpec for MinimalEthSpec {
549556
type ProposerLookaheadSlots = U16; // Derived from (MIN_SEED_LOOKAHEAD + 1) * SLOTS_PER_EPOCH
550557
type BuilderPendingPaymentsLimit = U16; // 2 * SLOTS_PER_EPOCH = 2 * 8 = 16
551558
type PTCSize = U2;
559+
type MaxBuildersPerWithdrawalsSweep = U16;
552560

553561
params_from_eth_spec!(MainnetEthSpec {
554562
JustificationBitsLength,
@@ -656,6 +664,7 @@ impl EthSpec for GnosisEthSpec {
656664
type BuilderRegistryLimit = U1099511627776;
657665
type PTCSize = U512;
658666
type MaxPayloadAttestations = U2;
667+
type MaxBuildersPerWithdrawalsSweep = U16384;
659668

660669
fn default_spec() -> ChainSpec {
661670
ChainSpec::gnosis()

testing/ef_tests/src/handler.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@ impl<T, E> SszStaticHandler<T, E> {
305305
Self::for_forks(vec![ForkName::Fulu])
306306
}
307307

308+
pub fn gloas_only() -> Self {
309+
Self::for_forks(vec![ForkName::Gloas])
310+
}
311+
308312
pub fn altair_and_later() -> Self {
309313
Self::for_forks(ForkName::list_all()[1..].to_vec())
310314
}
@@ -329,6 +333,10 @@ impl<T, E> SszStaticHandler<T, E> {
329333
Self::for_forks(ForkName::list_all()[6..].to_vec())
330334
}
331335

336+
pub fn gloas_and_later() -> Self {
337+
Self::for_forks(ForkName::list_all()[7..].to_vec())
338+
}
339+
332340
pub fn pre_electra() -> Self {
333341
Self::for_forks(ForkName::list_all()[0..5].to_vec())
334342
}
@@ -362,6 +370,10 @@ impl<T, E> SszStaticWithSpecHandler<T, E> {
362370
pub fn fulu_and_later() -> Self {
363371
Self::for_forks(ForkName::list_all()[6..].to_vec())
364372
}
373+
374+
pub fn gloas_and_later() -> Self {
375+
Self::for_forks(ForkName::list_all()[7..].to_vec())
376+
}
365377
}
366378

367379
impl<T, E> Handler for SszStaticHandler<T, E>

testing/ef_tests/tests/tests.rs

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,12 @@ mod ssz_static {
241241
use ef_tests::{Handler, SszStaticHandler, SszStaticTHCHandler, SszStaticWithSpecHandler};
242242
use types::state::HistoricalSummary;
243243
use types::{
244-
AttesterSlashingBase, AttesterSlashingElectra, ConsolidationRequest, DepositRequest,
245-
LightClientBootstrapAltair, PendingDeposit, PendingPartialWithdrawal, WithdrawalRequest, *,
244+
AttesterSlashingBase, AttesterSlashingElectra, Builder, BuilderPendingPayment,
245+
BuilderPendingWithdrawal, ConsolidationRequest, DepositRequest, ExecutionPayloadBid,
246+
ExecutionPayloadEnvelope, IndexedPayloadAttestation, LightClientBootstrapAltair,
247+
PayloadAttestation, PayloadAttestationData, PayloadAttestationMessage, PendingDeposit,
248+
PendingPartialWithdrawal, SignedExecutionPayloadBid, SignedExecutionPayloadEnvelope,
249+
WithdrawalRequest, *,
246250
};
247251

248252
ssz_static_test!(attestation_data, AttestationData);
@@ -368,6 +372,8 @@ mod ssz_static {
368372
.run();
369373
SszStaticHandler::<BeaconBlockBodyFulu<MinimalEthSpec>, MinimalEthSpec>::fulu_only().run();
370374
SszStaticHandler::<BeaconBlockBodyFulu<MainnetEthSpec>, MainnetEthSpec>::fulu_only().run();
375+
SszStaticHandler::<BeaconBlockBodyGloas<MinimalEthSpec>, MinimalEthSpec>::gloas_only().run();
376+
SszStaticHandler::<BeaconBlockBodyGloas<MainnetEthSpec>, MainnetEthSpec>::gloas_only().run();
371377
}
372378

373379
// Altair and later
@@ -722,6 +728,81 @@ mod ssz_static {
722728
SszStaticHandler::<ExecutionRequests<MinimalEthSpec>, MinimalEthSpec>::electra_and_later()
723729
.run();
724730
}
731+
732+
// Gloas and later
733+
#[test]
734+
fn builder() {
735+
SszStaticHandler::<Builder, MinimalEthSpec>::gloas_and_later().run();
736+
SszStaticHandler::<Builder, MainnetEthSpec>::gloas_and_later().run();
737+
}
738+
739+
#[test]
740+
fn builder_pending_payment() {
741+
SszStaticHandler::<BuilderPendingPayment, MinimalEthSpec>::gloas_and_later().run();
742+
SszStaticHandler::<BuilderPendingPayment, MainnetEthSpec>::gloas_and_later().run();
743+
}
744+
745+
#[test]
746+
fn builder_pending_withdrawal() {
747+
SszStaticHandler::<BuilderPendingWithdrawal, MinimalEthSpec>::gloas_and_later().run();
748+
SszStaticHandler::<BuilderPendingWithdrawal, MainnetEthSpec>::gloas_and_later().run();
749+
}
750+
751+
#[test]
752+
fn payload_attestation_data() {
753+
SszStaticHandler::<PayloadAttestationData, MinimalEthSpec>::gloas_and_later().run();
754+
SszStaticHandler::<PayloadAttestationData, MainnetEthSpec>::gloas_and_later().run();
755+
}
756+
757+
#[test]
758+
fn payload_attestation() {
759+
SszStaticHandler::<PayloadAttestation<MinimalEthSpec>, MinimalEthSpec>::gloas_and_later()
760+
.run();
761+
SszStaticHandler::<PayloadAttestation<MainnetEthSpec>, MainnetEthSpec>::gloas_and_later()
762+
.run();
763+
}
764+
765+
#[test]
766+
fn payload_attestation_message() {
767+
SszStaticHandler::<PayloadAttestationMessage, MinimalEthSpec>::gloas_and_later().run();
768+
SszStaticHandler::<PayloadAttestationMessage, MainnetEthSpec>::gloas_and_later().run();
769+
}
770+
771+
#[test]
772+
fn indexed_payload_attestation() {
773+
SszStaticHandler::<IndexedPayloadAttestation<MinimalEthSpec>, MinimalEthSpec>::gloas_and_later()
774+
.run();
775+
SszStaticHandler::<IndexedPayloadAttestation<MainnetEthSpec>, MainnetEthSpec>::gloas_and_later()
776+
.run();
777+
}
778+
779+
#[test]
780+
fn execution_payload_bid() {
781+
SszStaticHandler::<ExecutionPayloadBid, MinimalEthSpec>::gloas_and_later().run();
782+
SszStaticHandler::<ExecutionPayloadBid, MainnetEthSpec>::gloas_and_later().run();
783+
}
784+
785+
#[test]
786+
fn signed_execution_payload_bid() {
787+
SszStaticHandler::<SignedExecutionPayloadBid, MinimalEthSpec>::gloas_and_later().run();
788+
SszStaticHandler::<SignedExecutionPayloadBid, MainnetEthSpec>::gloas_and_later().run();
789+
}
790+
791+
#[test]
792+
fn execution_payload_envelope() {
793+
SszStaticHandler::<ExecutionPayloadEnvelope<MinimalEthSpec>, MinimalEthSpec>::gloas_and_later()
794+
.run();
795+
SszStaticHandler::<ExecutionPayloadEnvelope<MainnetEthSpec>, MainnetEthSpec>::gloas_and_later()
796+
.run();
797+
}
798+
799+
#[test]
800+
fn signed_execution_payload_envelope() {
801+
SszStaticHandler::<SignedExecutionPayloadEnvelope<MinimalEthSpec>, MinimalEthSpec>::gloas_and_later()
802+
.run();
803+
SszStaticHandler::<SignedExecutionPayloadEnvelope<MainnetEthSpec>, MainnetEthSpec>::gloas_and_later()
804+
.run();
805+
}
725806
}
726807

727808
#[test]

0 commit comments

Comments
 (0)