Skip to content

Commit

Permalink
Update Fulu spec tests. Revert back to testing Fulu as "feature", bec…
Browse files Browse the repository at this point in the history
…ause all non-PeerDAS Fulu SSZ types are the same as Electra, and serde deserializes the vectors into Electra types.
  • Loading branch information
jimmygchen committed Jan 17, 2025
1 parent 4d407fe commit 8980832
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 24 deletions.
6 changes: 3 additions & 3 deletions testing/ef_tests/check_all_files_accessed.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
"bls12-381-tests/hash_to_G2",
"tests/.*/eip6110",
"tests/.*/whisk",
# Fulu tests are not yet being run
"tests/.*/fulu",
# TODO(electra): SingleAttestation tests are waiting on Eitan's PR
"tests/.*/electra/ssz_static/SingleAttestation"
"tests/.*/electra/ssz_static/SingleAttestation",
"tests/.*/fulu/ssz_static/SingleAttestation",
"tests/.*/fulu/ssz_static/MatrixEntry",
]


Expand Down
11 changes: 7 additions & 4 deletions testing/ef_tests/src/cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,29 @@ pub use transition::TransitionTest;
/// to return `true` for the feature in order for the feature test vector to be tested.
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum FeatureName {
Placeholder,
// TODO(fulu): to be removed once we start using Fulu types for test vectors.
// Existing SSZ types for PeerDAS (Fulu) are the same as Electra, so the test vectors get
// loaded as Electra types (default serde behaviour for untagged enums).
Fulu,
}

impl FeatureName {
pub fn list_all() -> Vec<FeatureName> {
vec![FeatureName::Placeholder]
vec![FeatureName::Fulu]
}

/// `ForkName` to use when running the feature tests.
pub fn fork_name(&self) -> ForkName {
match self {
FeatureName::Placeholder => ForkName::Fulu,
FeatureName::Fulu => ForkName::Electra,
}
}
}

impl Display for FeatureName {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
FeatureName::Placeholder => f.write_str("placeholder"),
FeatureName::Fulu => f.write_str("fulu"),
}
}
}
Expand Down
51 changes: 51 additions & 0 deletions testing/ef_tests/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,25 @@ where
fn is_enabled_for_fork(&self, fork_name: ForkName) -> bool {
self.supported_forks.contains(&fork_name)
}

fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
// TODO(fulu): to be removed once Fulu types start differing from Electra. We currently run Fulu tests as a
// "feature" - this means we use Electra types for Fulu SSZ tests (except for PeerDAS types, e.g. `DataColumnSidecar`).
//
// This ensures we only run the tests **once** for `Fulu`, using the types matching the
// correct fork, e.g. `Fulu` uses SSZ types from `Electra` as of spec test version
// `v1.5.0-beta.0`, therefore the `Fulu` tests should get included when testing Deneb types.
//
// e.g. Fulu test vectors are executed in the 2nd line below, but excluded in the 1st
// line when testing the type `AttestationElectra`:
//
// ```
// SszStaticHandler::<AttestationBase<MainnetEthSpec>, MainnetEthSpec>::pre_electra().run();
// SszStaticHandler::<AttestationElectra<MainnetEthSpec>, MainnetEthSpec>::electra_only().run();
// ```
feature_name == FeatureName::Fulu
&& self.supported_forks.contains(&feature_name.fork_name())
}
}

impl<E> Handler for SszStaticTHCHandler<BeaconState<E>, E>
Expand All @@ -372,6 +391,10 @@ where
fn handler_name(&self) -> String {
BeaconState::<E>::name().into()
}

fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
}
}

impl<T, E> Handler for SszStaticWithSpecHandler<T, E>
Expand All @@ -393,6 +416,10 @@ where
fn handler_name(&self) -> String {
T::name().into()
}

fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
}
}

#[derive(Derivative)]
Expand Down Expand Up @@ -866,6 +893,10 @@ impl<E: EthSpec + TypeName> Handler for GetCustodyGroupsHandler<E> {
fn handler_name(&self) -> String {
"get_custody_groups".into()
}

fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
}
}

#[derive(Derivative)]
Expand All @@ -886,6 +917,10 @@ impl<E: EthSpec + TypeName> Handler for ComputeColumnsForCustodyGroupHandler<E>
fn handler_name(&self) -> String {
"compute_columns_for_custody_group".into()
}

fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
}
}

#[derive(Derivative)]
Expand All @@ -906,6 +941,10 @@ impl<E: EthSpec> Handler for KZGComputeCellsAndKZGProofHandler<E> {
fn handler_name(&self) -> String {
"compute_cells_and_kzg_proofs".into()
}

fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
}
}

#[derive(Derivative)]
Expand All @@ -926,6 +965,10 @@ impl<E: EthSpec> Handler for KZGVerifyCellKZGProofBatchHandler<E> {
fn handler_name(&self) -> String {
"verify_cell_kzg_proof_batch".into()
}

fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
}
}

#[derive(Derivative)]
Expand All @@ -946,6 +989,10 @@ impl<E: EthSpec> Handler for KZGRecoverCellsAndKZGProofHandler<E> {
fn handler_name(&self) -> String {
"recover_cells_and_kzg_proofs".into()
}

fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
}
}

#[derive(Derivative)]
Expand Down Expand Up @@ -994,6 +1041,10 @@ impl<E: EthSpec + TypeName> Handler for KzgInclusionMerkleProofValidityHandler<E
fn is_enabled_for_fork(&self, fork_name: ForkName) -> bool {
fork_name.deneb_enabled()
}

fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
}
}

#[derive(Derivative)]
Expand Down
11 changes: 11 additions & 0 deletions testing/ef_tests/src/type_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type_name_generic!(BeaconBlockBodyBellatrix, "BeaconBlockBody");
type_name_generic!(BeaconBlockBodyCapella, "BeaconBlockBody");
type_name_generic!(BeaconBlockBodyDeneb, "BeaconBlockBody");
type_name_generic!(BeaconBlockBodyElectra, "BeaconBlockBody");
type_name_generic!(BeaconBlockBodyFulu, "BeaconBlockBody");
type_name!(BeaconBlockHeader);
type_name_generic!(BeaconState);
type_name!(BlobIdentifier);
Expand All @@ -74,12 +75,14 @@ type_name_generic!(ExecutionPayloadBellatrix, "ExecutionPayload");
type_name_generic!(ExecutionPayloadCapella, "ExecutionPayload");
type_name_generic!(ExecutionPayloadDeneb, "ExecutionPayload");
type_name_generic!(ExecutionPayloadElectra, "ExecutionPayload");
type_name_generic!(ExecutionPayloadFulu, "ExecutionPayload");
type_name_generic!(FullPayload, "ExecutionPayload");
type_name_generic!(ExecutionPayloadHeader);
type_name_generic!(ExecutionPayloadHeaderBellatrix, "ExecutionPayloadHeader");
type_name_generic!(ExecutionPayloadHeaderCapella, "ExecutionPayloadHeader");
type_name_generic!(ExecutionPayloadHeaderDeneb, "ExecutionPayloadHeader");
type_name_generic!(ExecutionPayloadHeaderElectra, "ExecutionPayloadHeader");
type_name_generic!(ExecutionPayloadHeaderFulu, "ExecutionPayloadHeader");
type_name_generic!(ExecutionRequests);
type_name_generic!(BlindedPayload, "ExecutionPayloadHeader");
type_name!(Fork);
Expand All @@ -93,6 +96,7 @@ type_name_generic!(LightClientBootstrapAltair, "LightClientBootstrap");
type_name_generic!(LightClientBootstrapCapella, "LightClientBootstrap");
type_name_generic!(LightClientBootstrapDeneb, "LightClientBootstrap");
type_name_generic!(LightClientBootstrapElectra, "LightClientBootstrap");
type_name_generic!(LightClientBootstrapFulu, "LightClientBootstrap");
type_name_generic!(LightClientFinalityUpdate);
type_name_generic!(LightClientFinalityUpdateAltair, "LightClientFinalityUpdate");
type_name_generic!(
Expand All @@ -104,11 +108,13 @@ type_name_generic!(
LightClientFinalityUpdateElectra,
"LightClientFinalityUpdate"
);
type_name_generic!(LightClientFinalityUpdateFulu, "LightClientFinalityUpdate");
type_name_generic!(LightClientHeader);
type_name_generic!(LightClientHeaderAltair, "LightClientHeader");
type_name_generic!(LightClientHeaderCapella, "LightClientHeader");
type_name_generic!(LightClientHeaderDeneb, "LightClientHeader");
type_name_generic!(LightClientHeaderElectra, "LightClientHeader");
type_name_generic!(LightClientHeaderFulu, "LightClientHeader");
type_name_generic!(LightClientOptimisticUpdate);
type_name_generic!(
LightClientOptimisticUpdateAltair,
Expand All @@ -126,11 +132,16 @@ type_name_generic!(
LightClientOptimisticUpdateElectra,
"LightClientOptimisticUpdate"
);
type_name_generic!(
LightClientOptimisticUpdateFulu,
"LightClientOptimisticUpdate"
);
type_name_generic!(LightClientUpdate);
type_name_generic!(LightClientUpdateAltair, "LightClientUpdate");
type_name_generic!(LightClientUpdateCapella, "LightClientUpdate");
type_name_generic!(LightClientUpdateDeneb, "LightClientUpdate");
type_name_generic!(LightClientUpdateElectra, "LightClientUpdate");
type_name_generic!(LightClientUpdateFulu, "LightClientUpdate");
type_name_generic!(PendingAttestation);
type_name!(PendingConsolidation);
type_name!(PendingPartialWithdrawal);
Expand Down
Loading

0 comments on commit 8980832

Please sign in to comment.