Skip to content

Commit 7d95ef3

Browse files
committed
Add Gloas EF test infrastructure and fork choice exclusion.
- Add fork choice constants to consts.rs (PayloadStatus, timeliness indices) - Add payload_timely_threshold() helper to EthSpec - Exclude Gloas from fork_choice tests until implementation is complete - Add PayloadAttestation operation test handler for EF tests
1 parent ae38421 commit 7d95ef3

File tree

5 files changed

+54
-2
lines changed

5 files changed

+54
-2
lines changed

consensus/types/src/core/consts.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,14 @@ pub mod deneb {
2828
pub mod gloas {
2929
pub const BUILDER_INDEX_SELF_BUILD: u64 = u64::MAX;
3030
pub const BUILDER_INDEX_FLAG: u64 = 1 << 40;
31+
32+
// Fork choice constants
33+
pub type PayloadStatus = u8;
34+
pub const PAYLOAD_STATUS_PENDING: PayloadStatus = 0;
35+
pub const PAYLOAD_STATUS_EMPTY: PayloadStatus = 1;
36+
pub const PAYLOAD_STATUS_FULL: PayloadStatus = 2;
37+
38+
pub const ATTESTATION_TIMELINESS_INDEX: usize = 0;
39+
pub const PTC_TIMELINESS_INDEX: usize = 1;
40+
pub const NUM_BLOCK_TIMELINESS_DEADLINES: usize = 2;
3141
}

consensus/types/src/core/eth_spec.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,11 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq +
437437
fn max_builders_per_withdrawals_sweep() -> usize {
438438
Self::MaxBuildersPerWithdrawalsSweep::to_usize()
439439
}
440+
441+
/// Returns the `PAYLOAD_TIMELY_THRESHOLD` constant (PTC_SIZE / 2).
442+
fn payload_timely_threshold() -> usize {
443+
Self::PTCSize::to_usize() / 2
444+
}
440445
}
441446

442447
/// Macro to inherit some type values from another EthSpec.

testing/ef_tests/src/cases/fork_choice.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ impl<E: EthSpec> Case for ForkChoiceTest<E> {
296296
self.description.clone()
297297
}
298298

299+
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
300+
// Gloas fork choice not yet implemented
301+
fork_name != ForkName::Gloas
302+
}
303+
299304
fn result(&self, _case_index: usize, fork_name: ForkName) -> Result<(), Error> {
300305
let tester = Tester::new(self, testing_spec::<E>(fork_name))?;
301306

testing/ef_tests/src/cases/operations.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use state_processing::common::update_progressive_balances_cache::initialize_prog
88
use state_processing::epoch_cache::initialize_epoch_cache;
99
use state_processing::per_block_processing::process_operations::{
1010
altair_deneb, base, gloas, process_consolidation_requests, process_deposit_requests,
11-
process_withdrawal_requests,
11+
process_payload_attestation, process_withdrawal_requests,
1212
};
1313
use state_processing::{
1414
ConsensusContext,
@@ -28,7 +28,7 @@ use types::{
2828
Attestation, AttesterSlashing, BeaconBlock, BeaconBlockBody, BeaconBlockBodyBellatrix,
2929
BeaconBlockBodyCapella, BeaconBlockBodyDeneb, BeaconBlockBodyElectra, BeaconBlockBodyFulu,
3030
BeaconState, BlindedPayload, ConsolidationRequest, Deposit, DepositRequest, ExecutionPayload,
31-
ForkVersionDecode, FullPayload, ProposerSlashing, SignedBlsToExecutionChange,
31+
ForkVersionDecode, FullPayload, PayloadAttestation, ProposerSlashing, SignedBlsToExecutionChange,
3232
SignedVoluntaryExit, SyncAggregate, WithdrawalRequest,
3333
};
3434

@@ -545,6 +545,32 @@ impl<E: EthSpec> Operation<E> for ConsolidationRequest {
545545
}
546546
}
547547

548+
impl<E: EthSpec> Operation<E> for PayloadAttestation<E> {
549+
fn handler_name() -> String {
550+
"payload_attestation".into()
551+
}
552+
553+
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
554+
fork_name.gloas_enabled()
555+
}
556+
557+
fn decode(path: &Path, _fork_name: ForkName, _spec: &ChainSpec) -> Result<Self, Error> {
558+
ssz_decode_file(path)
559+
}
560+
561+
fn apply_to(
562+
&self,
563+
state: &mut BeaconState<E>,
564+
spec: &ChainSpec,
565+
_extra: &Operations<E, Self>,
566+
) -> Result<(), BlockProcessingError> {
567+
initialize_epoch_cache(state, spec)?;
568+
initialize_progressive_balances_cache(state, spec)?;
569+
let mut ctxt = ConsensusContext::new(state.slot());
570+
process_payload_attestation(state, self, 0, VerifySignatures::True, &mut ctxt, spec)
571+
}
572+
}
573+
548574
impl<E: EthSpec, O: Operation<E>> LoadCase for Operations<E, O> {
549575
fn load_from_dir(path: &Path, fork_name: ForkName) -> Result<Self, Error> {
550576
let spec = &testing_spec::<E>(fork_name);

testing/ef_tests/tests/tests.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ fn operations_bls_to_execution_change() {
118118
OperationsHandler::<MainnetEthSpec, SignedBlsToExecutionChange>::default().run();
119119
}
120120

121+
#[test]
122+
fn operations_payload_attestation() {
123+
OperationsHandler::<MinimalEthSpec, PayloadAttestation<_>>::default().run();
124+
OperationsHandler::<MainnetEthSpec, PayloadAttestation<_>>::default().run();
125+
}
126+
121127
#[test]
122128
fn sanity_blocks() {
123129
SanityBlocksHandler::<MinimalEthSpec>::default().run();

0 commit comments

Comments
 (0)