mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 04:01:51 +00:00
@@ -1,6 +1,7 @@
|
||||
use crate::cases::{self, Case, Cases, EpochTransition, LoadCase, Operation};
|
||||
use crate::type_name::TypeName;
|
||||
use crate::{type_name, FeatureName};
|
||||
use context_deserialize::ContextDeserialize;
|
||||
use derivative::Derivative;
|
||||
use std::fs::{self, DirEntry};
|
||||
use std::marker::PhantomData;
|
||||
@@ -21,7 +22,7 @@ pub trait Handler {
|
||||
// Add forks here to exclude them from EF spec testing. Helpful for adding future or
|
||||
// unspecified forks.
|
||||
fn disabled_forks(&self) -> Vec<ForkName> {
|
||||
vec![ForkName::Fulu]
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn is_enabled_for_fork(&self, fork_name: ForkName) -> bool {
|
||||
@@ -50,6 +51,19 @@ pub trait Handler {
|
||||
}
|
||||
}
|
||||
|
||||
// Do NOT override this function.
|
||||
// TODO: use default keyword when stable.
|
||||
fn rayon_enabled() -> bool {
|
||||
#[cfg(feature = "disable_rayon")]
|
||||
{
|
||||
false
|
||||
}
|
||||
#[cfg(not(feature = "disable_rayon"))]
|
||||
{
|
||||
Self::use_rayon()
|
||||
}
|
||||
}
|
||||
|
||||
fn use_rayon() -> bool {
|
||||
true
|
||||
}
|
||||
@@ -85,7 +99,7 @@ pub trait Handler {
|
||||
})
|
||||
.collect();
|
||||
|
||||
let results = Cases { test_cases }.test_results(fork_name, Self::use_rayon());
|
||||
let results = Cases { test_cases }.test_results(fork_name, Self::rayon_enabled());
|
||||
|
||||
let name = format!(
|
||||
"{}/{}/{}",
|
||||
@@ -127,7 +141,7 @@ pub trait Handler {
|
||||
})
|
||||
.collect();
|
||||
|
||||
let results = Cases { test_cases }.test_results(fork_name, Self::use_rayon());
|
||||
let results = Cases { test_cases }.test_results(fork_name, Self::rayon_enabled());
|
||||
|
||||
let name = format!(
|
||||
"{}/{}/{}",
|
||||
@@ -205,7 +219,7 @@ macro_rules! bls_handler {
|
||||
})
|
||||
.collect();
|
||||
|
||||
let results = Cases { test_cases }.test_results(fork_name, Self::use_rayon());
|
||||
let results = Cases { test_cases }.test_results(fork_name, Self::rayon_enabled());
|
||||
|
||||
let name = format!(
|
||||
"{}/{}/{}",
|
||||
@@ -327,13 +341,37 @@ impl<T, E> SszStaticHandler<T, E> {
|
||||
pub struct SszStaticTHCHandler<T, E>(PhantomData<(T, E)>);
|
||||
|
||||
/// Handler for SSZ types that don't implement `ssz::Decode`.
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Default(bound = ""))]
|
||||
pub struct SszStaticWithSpecHandler<T, E>(PhantomData<(T, E)>);
|
||||
pub struct SszStaticWithSpecHandler<T, E> {
|
||||
supported_forks: Vec<ForkName>,
|
||||
_phantom: PhantomData<(T, E)>,
|
||||
}
|
||||
|
||||
impl<T, E> Default for SszStaticWithSpecHandler<T, E> {
|
||||
fn default() -> Self {
|
||||
Self::for_forks(ForkName::list_all())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E> SszStaticWithSpecHandler<T, E> {
|
||||
pub fn for_forks(supported_forks: Vec<ForkName>) -> Self {
|
||||
SszStaticWithSpecHandler {
|
||||
supported_forks,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fulu_and_later() -> Self {
|
||||
Self::for_forks(ForkName::list_all()[6..].to_vec())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E> Handler for SszStaticHandler<T, E>
|
||||
where
|
||||
T: cases::SszStaticType + tree_hash::TreeHash + ssz::Decode + TypeName,
|
||||
T: cases::SszStaticType
|
||||
+ for<'de> ContextDeserialize<'de, ForkName>
|
||||
+ tree_hash::TreeHash
|
||||
+ ssz::Decode
|
||||
+ TypeName,
|
||||
E: TypeName,
|
||||
{
|
||||
type Case = cases::SszStatic<T>;
|
||||
@@ -353,25 +391,6 @@ 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>
|
||||
@@ -391,10 +410,6 @@ 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>
|
||||
@@ -417,8 +432,8 @@ where
|
||||
T::name().into()
|
||||
}
|
||||
|
||||
fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
|
||||
feature_name == FeatureName::Fulu
|
||||
fn is_enabled_for_fork(&self, fork_name: ForkName) -> bool {
|
||||
self.supported_forks.contains(&fork_name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -898,10 +913,6 @@ 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)]
|
||||
@@ -922,9 +933,25 @@ 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)]
|
||||
#[derivative(Default(bound = ""))]
|
||||
pub struct KZGComputeCellsHandler<E>(PhantomData<E>);
|
||||
|
||||
impl<E: EthSpec> Handler for KZGComputeCellsHandler<E> {
|
||||
type Case = cases::KZGComputeCells<E>;
|
||||
|
||||
fn config_name() -> &'static str {
|
||||
"general"
|
||||
}
|
||||
|
||||
fn runner_name() -> &'static str {
|
||||
"kzg"
|
||||
}
|
||||
|
||||
fn handler_name(&self) -> String {
|
||||
"compute_cells".into()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -946,10 +973,6 @@ 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)]
|
||||
@@ -970,10 +993,6 @@ 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)]
|
||||
@@ -994,10 +1013,6 @@ 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)]
|
||||
@@ -1022,10 +1037,6 @@ 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)]
|
||||
@@ -1073,7 +1084,8 @@ impl<E: EthSpec + TypeName> Handler for LightClientUpdateHandler<E> {
|
||||
|
||||
fn is_enabled_for_fork(&self, fork_name: ForkName) -> bool {
|
||||
// Enabled in Altair
|
||||
fork_name.altair_enabled()
|
||||
// No test in Fulu yet.
|
||||
fork_name.altair_enabled() && fork_name != ForkName::Fulu
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user