mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-29 19:04:27 +00:00
Merge remote-tracking branch 'origin/unstable' into tree-states
This commit is contained in:
@@ -29,18 +29,8 @@ excluded_paths = [
|
||||
"tests/.*/.*/light_client",
|
||||
# LightClientStore
|
||||
"tests/.*/.*/ssz_static/LightClientStore",
|
||||
# LightClientUpdate
|
||||
"tests/.*/.*/ssz_static/LightClientUpdate",
|
||||
# LightClientSnapshot
|
||||
"tests/.*/.*/ssz_static/LightClientSnapshot",
|
||||
# LightClientBootstrap
|
||||
"tests/.*/.*/ssz_static/LightClientBootstrap",
|
||||
# LightClientOptimistic
|
||||
"tests/.*/.*/ssz_static/LightClientOptimistic",
|
||||
# LightClientFinalityUpdate
|
||||
"tests/.*/.*/ssz_static/LightClientFinalityUpdate",
|
||||
# LightClientHeader
|
||||
"tests/.*/.*/ssz_static/LightClientHeader",
|
||||
# One of the EF researchers likes to pack the tarballs on a Mac
|
||||
".*\.DS_Store.*",
|
||||
# More Mac weirdness.
|
||||
|
||||
@@ -33,9 +33,9 @@ impl CaseResult {
|
||||
|
||||
/// Same as `compare_result_detailed`, however it drops the caches on both states before
|
||||
/// comparison.
|
||||
pub fn compare_beacon_state_results_without_caches<T: EthSpec, E: Debug>(
|
||||
result: &mut Result<BeaconState<T>, E>,
|
||||
expected: &mut Option<BeaconState<T>>,
|
||||
pub fn compare_beacon_state_results_without_caches<E: EthSpec, T: Debug>(
|
||||
result: &mut Result<BeaconState<E>, T>,
|
||||
expected: &mut Option<BeaconState<E>>,
|
||||
) -> Result<(), Error> {
|
||||
if let (Ok(ref mut result), Some(ref mut expected)) = (result.as_mut(), expected.as_mut()) {
|
||||
result.drop_all_caches().unwrap();
|
||||
@@ -50,13 +50,13 @@ pub fn compare_beacon_state_results_without_caches<T: EthSpec, E: Debug>(
|
||||
|
||||
/// Same as `compare_result`, however utilizes the `CompareFields` trait to give a list of
|
||||
/// mismatching fields when `Ok(result) != Some(expected)`.
|
||||
pub fn compare_result_detailed<T, E>(
|
||||
result: &Result<T, E>,
|
||||
pub fn compare_result_detailed<T, U>(
|
||||
result: &Result<T, U>,
|
||||
expected: &Option<T>,
|
||||
) -> Result<(), Error>
|
||||
where
|
||||
T: PartialEq<T> + Debug + CompareFields,
|
||||
E: Debug,
|
||||
U: Debug,
|
||||
{
|
||||
match (result, expected) {
|
||||
(Ok(result), Some(expected)) => {
|
||||
@@ -88,10 +88,10 @@ where
|
||||
///
|
||||
/// If `expected.is_none()` then `result` is expected to be `Err`. Otherwise, `T` in `result` and
|
||||
/// `expected` must be equal.
|
||||
pub fn compare_result<T, E>(result: &Result<T, E>, expected: &Option<T>) -> Result<(), Error>
|
||||
pub fn compare_result<T, U>(result: &Result<T, U>, expected: &Option<T>) -> Result<(), Error>
|
||||
where
|
||||
T: PartialEq<T> + Debug,
|
||||
E: Debug,
|
||||
U: Debug,
|
||||
{
|
||||
match (result, expected) {
|
||||
// Pass: The should have failed and did fail.
|
||||
|
||||
@@ -3,7 +3,6 @@ use crate::case_result::compare_result;
|
||||
use crate::impl_bls_load_case;
|
||||
use bls::{AggregateSignature, PublicKeyBytes};
|
||||
use serde::Deserialize;
|
||||
use std::convert::TryInto;
|
||||
use types::Hash256;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
|
||||
@@ -3,7 +3,6 @@ use crate::case_result::compare_result;
|
||||
use crate::impl_bls_load_case;
|
||||
use bls::{AggregateSignature, PublicKeyBytes};
|
||||
use serde::Deserialize;
|
||||
use std::convert::TryInto;
|
||||
use types::Hash256;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
|
||||
@@ -3,7 +3,6 @@ use crate::case_result::compare_result;
|
||||
use crate::impl_bls_load_case;
|
||||
use bls::{PublicKey, PublicKeyBytes, Signature, SignatureBytes};
|
||||
use serde::Deserialize;
|
||||
use std::convert::TryInto;
|
||||
use types::Hash256;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use serde::Deserialize;
|
||||
use ssz::Encode;
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt::Debug;
|
||||
use tree_hash::TreeHash;
|
||||
use types::ForkName;
|
||||
@@ -67,6 +66,7 @@ pub fn previous_fork(fork_name: ForkName) -> ForkName {
|
||||
ForkName::Merge => ForkName::Altair,
|
||||
ForkName::Capella => ForkName::Merge,
|
||||
ForkName::Deneb => ForkName::Capella,
|
||||
ForkName::Electra => ForkName::Deneb,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ use crate::bls_setting::BlsSetting;
|
||||
use crate::case_result::{check_state_diff, compare_beacon_state_results_without_caches};
|
||||
use crate::decode::{ssz_decode_state, yaml_decode_file};
|
||||
use crate::type_name;
|
||||
use crate::type_name::TypeName;
|
||||
use serde::Deserialize;
|
||||
use state_processing::common::update_progressive_balances_cache::initialize_progressive_balances_cache;
|
||||
use state_processing::epoch_cache::initialize_epoch_cache;
|
||||
@@ -20,8 +19,7 @@ use state_processing::per_epoch_processing::{
|
||||
};
|
||||
use state_processing::EpochProcessingError;
|
||||
use std::marker::PhantomData;
|
||||
use std::path::{Path, PathBuf};
|
||||
use types::{BeaconState, ChainSpec, EthSpec, ForkName};
|
||||
use types::BeaconState;
|
||||
|
||||
#[derive(Debug, Clone, Default, Deserialize)]
|
||||
pub struct Metadata {
|
||||
@@ -109,7 +107,8 @@ impl<E: EthSpec> EpochTransition<E> for JustificationAndFinalization {
|
||||
BeaconState::Altair(_)
|
||||
| BeaconState::Merge(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_) => {
|
||||
| BeaconState::Deneb(_)
|
||||
| BeaconState::Electra(_) => {
|
||||
initialize_progressive_balances_cache(state, spec)?;
|
||||
let justification_and_finalization_state =
|
||||
altair::process_justification_and_finalization(state)?;
|
||||
@@ -131,7 +130,8 @@ impl<E: EthSpec> EpochTransition<E> for RewardsAndPenalties {
|
||||
BeaconState::Altair(_)
|
||||
| BeaconState::Merge(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_) => altair::process_rewards_and_penalties_slow(state, spec),
|
||||
| BeaconState::Deneb(_)
|
||||
| BeaconState::Electra(_) => altair::process_rewards_and_penalties_slow(state, spec),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,8 @@ impl<E: EthSpec> EpochTransition<E> for Slashings {
|
||||
BeaconState::Altair(_)
|
||||
| BeaconState::Merge(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_) => {
|
||||
| BeaconState::Deneb(_)
|
||||
| BeaconState::Electra(_) => {
|
||||
process_slashings_slow(state, spec)?;
|
||||
}
|
||||
};
|
||||
@@ -213,7 +214,7 @@ impl<E: EthSpec> EpochTransition<E> for HistoricalRootsUpdate {
|
||||
impl<E: EthSpec> EpochTransition<E> for HistoricalSummariesUpdate {
|
||||
fn run(state: &mut BeaconState<E>, _spec: &ChainSpec) -> Result<(), EpochProcessingError> {
|
||||
match state {
|
||||
BeaconState::Capella(_) | BeaconState::Deneb(_) => {
|
||||
BeaconState::Capella(_) | BeaconState::Deneb(_) | BeaconState::Electra(_) => {
|
||||
process_historical_summaries_update(state)
|
||||
}
|
||||
_ => Ok(()),
|
||||
@@ -238,7 +239,8 @@ impl<E: EthSpec> EpochTransition<E> for SyncCommitteeUpdates {
|
||||
BeaconState::Altair(_)
|
||||
| BeaconState::Merge(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_) => altair::process_sync_committee_updates(state, spec),
|
||||
| BeaconState::Deneb(_)
|
||||
| BeaconState::Electra(_) => altair::process_sync_committee_updates(state, spec),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -250,7 +252,8 @@ impl<E: EthSpec> EpochTransition<E> for InactivityUpdates {
|
||||
BeaconState::Altair(_)
|
||||
| BeaconState::Merge(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_) => altair::process_inactivity_updates_slow(state, spec),
|
||||
| BeaconState::Deneb(_)
|
||||
| BeaconState::Electra(_) => altair::process_inactivity_updates_slow(state, spec),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -262,7 +265,8 @@ impl<E: EthSpec> EpochTransition<E> for ParticipationFlagUpdates {
|
||||
BeaconState::Altair(_)
|
||||
| BeaconState::Merge(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_) => altair::process_participation_flag_updates(state),
|
||||
| BeaconState::Deneb(_)
|
||||
| BeaconState::Electra(_) => altair::process_participation_flag_updates(state),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -313,7 +317,7 @@ impl<E: EthSpec, T: EpochTransition<E>> Case for EpochProcessing<E, T> {
|
||||
T::name() != "participation_record_updates"
|
||||
&& T::name() != "historical_summaries_update"
|
||||
}
|
||||
ForkName::Capella | ForkName::Deneb => {
|
||||
ForkName::Capella | ForkName::Deneb | ForkName::Electra => {
|
||||
T::name() != "participation_record_updates"
|
||||
&& T::name() != "historical_roots_update"
|
||||
}
|
||||
|
||||
@@ -5,8 +5,9 @@ use crate::decode::{ssz_decode_state, yaml_decode_file};
|
||||
use serde::Deserialize;
|
||||
use state_processing::upgrade::{
|
||||
upgrade_to_altair, upgrade_to_bellatrix, upgrade_to_capella, upgrade_to_deneb,
|
||||
upgrade_to_electra,
|
||||
};
|
||||
use types::{BeaconState, ForkName};
|
||||
use types::BeaconState;
|
||||
|
||||
#[derive(Debug, Clone, Default, Deserialize)]
|
||||
pub struct Metadata {
|
||||
@@ -65,6 +66,7 @@ impl<E: EthSpec> Case for ForkTest<E> {
|
||||
ForkName::Merge => upgrade_to_bellatrix(&mut result_state, spec).map(|_| result_state),
|
||||
ForkName::Capella => upgrade_to_capella(&mut result_state, spec).map(|_| result_state),
|
||||
ForkName::Deneb => upgrade_to_deneb(&mut result_state, spec).map(|_| result_state),
|
||||
ForkName::Electra => upgrade_to_electra(&mut result_state, spec).map(|_| result_state),
|
||||
};
|
||||
|
||||
compare_beacon_state_results_without_caches(&mut result, &mut expected)
|
||||
|
||||
@@ -4,7 +4,8 @@ use ::fork_choice::{PayloadVerificationStatus, ProposerHeadError};
|
||||
use beacon_chain::beacon_proposer_cache::compute_proposer_duties_from_head;
|
||||
use beacon_chain::blob_verification::GossipBlobError;
|
||||
use beacon_chain::chain_config::{
|
||||
DisallowedReOrgOffsets, DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION, DEFAULT_RE_ORG_THRESHOLD,
|
||||
DisallowedReOrgOffsets, DEFAULT_RE_ORG_HEAD_THRESHOLD,
|
||||
DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION, DEFAULT_RE_ORG_PARENT_THRESHOLD,
|
||||
};
|
||||
use beacon_chain::slot_clock::SlotClock;
|
||||
use beacon_chain::{
|
||||
@@ -746,7 +747,8 @@ impl<E: EthSpec> Tester<E> {
|
||||
let proposer_head_result = fc.get_proposer_head(
|
||||
slot,
|
||||
canonical_head,
|
||||
DEFAULT_RE_ORG_THRESHOLD,
|
||||
DEFAULT_RE_ORG_HEAD_THRESHOLD,
|
||||
DEFAULT_RE_ORG_PARENT_THRESHOLD,
|
||||
&DisallowedReOrgOffsets::default(),
|
||||
DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION,
|
||||
);
|
||||
|
||||
@@ -3,8 +3,7 @@ use crate::case_result::compare_beacon_state_results_without_caches;
|
||||
use crate::decode::{ssz_decode_file, ssz_decode_file_with, ssz_decode_state, yaml_decode_file};
|
||||
use serde::Deserialize;
|
||||
use state_processing::initialize_beacon_state_from_eth1;
|
||||
use std::path::PathBuf;
|
||||
use types::{BeaconState, Deposit, EthSpec, ExecutionPayloadHeader, ForkName, Hash256};
|
||||
use types::{BeaconState, Deposit, ExecutionPayloadHeader, Hash256};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
struct Metadata {
|
||||
|
||||
@@ -2,8 +2,7 @@ use super::*;
|
||||
use crate::decode::{ssz_decode_state, yaml_decode_file};
|
||||
use serde::Deserialize;
|
||||
use state_processing::is_valid_genesis_state;
|
||||
use std::path::Path;
|
||||
use types::{BeaconState, EthSpec, ForkName};
|
||||
use types::BeaconState;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Metadata {
|
||||
|
||||
@@ -4,7 +4,6 @@ use beacon_chain::kzg_utils::validate_blob;
|
||||
use eth2_network_config::TRUSTED_SETUP_BYTES;
|
||||
use kzg::{Error as KzgError, Kzg, KzgCommitment, KzgProof, TrustedSetup};
|
||||
use serde::Deserialize;
|
||||
use std::convert::TryInto;
|
||||
use std::marker::PhantomData;
|
||||
use types::Blob;
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
use super::*;
|
||||
use crate::decode::{ssz_decode_file, ssz_decode_state, yaml_decode_file};
|
||||
use serde::Deserialize;
|
||||
use std::path::Path;
|
||||
use tree_hash::Hash256;
|
||||
use types::{BeaconBlockBody, BeaconBlockBodyDeneb, BeaconState, EthSpec, ForkName};
|
||||
use types::{
|
||||
BeaconBlockBody, BeaconBlockBodyDeneb, BeaconBlockBodyElectra, BeaconState, FullPayload,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Metadata {
|
||||
@@ -90,7 +91,7 @@ pub struct KzgInclusionMerkleProofValidity<E: EthSpec> {
|
||||
|
||||
impl<E: EthSpec> LoadCase for KzgInclusionMerkleProofValidity<E> {
|
||||
fn load_from_dir(path: &Path, fork_name: ForkName) -> Result<Self, Error> {
|
||||
let block = match fork_name {
|
||||
let block: BeaconBlockBody<E, FullPayload<E>> = match fork_name {
|
||||
ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => {
|
||||
return Err(Error::InternalError(format!(
|
||||
"KZG inclusion merkle proof validity test skipped for {:?}",
|
||||
@@ -98,7 +99,11 @@ impl<E: EthSpec> LoadCase for KzgInclusionMerkleProofValidity<E> {
|
||||
)))
|
||||
}
|
||||
ForkName::Deneb => {
|
||||
ssz_decode_file::<BeaconBlockBodyDeneb<E>>(&path.join("object.ssz_snappy"))?
|
||||
ssz_decode_file::<BeaconBlockBodyDeneb<E>>(&path.join("object.ssz_snappy"))?.into()
|
||||
}
|
||||
ForkName::Electra => {
|
||||
ssz_decode_file::<BeaconBlockBodyElectra<E>>(&path.join("object.ssz_snappy"))?
|
||||
.into()
|
||||
}
|
||||
};
|
||||
let merkle_proof = yaml_decode_file(&path.join("proof.yaml"))?;
|
||||
@@ -112,7 +117,7 @@ impl<E: EthSpec> LoadCase for KzgInclusionMerkleProofValidity<E> {
|
||||
|
||||
Ok(Self {
|
||||
metadata,
|
||||
block: block.into(),
|
||||
block,
|
||||
merkle_proof,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ use super::*;
|
||||
use crate::bls_setting::BlsSetting;
|
||||
use crate::case_result::{check_state_diff, compare_beacon_state_results_without_caches};
|
||||
use crate::decode::{ssz_decode_file, ssz_decode_file_with, ssz_decode_state, yaml_decode_file};
|
||||
use crate::testing_spec;
|
||||
use serde::Deserialize;
|
||||
use ssz::Decode;
|
||||
use state_processing::common::update_progressive_balances_cache::initialize_progressive_balances_cache;
|
||||
@@ -20,11 +19,10 @@ use state_processing::{
|
||||
ConsensusContext,
|
||||
};
|
||||
use std::fmt::Debug;
|
||||
use std::path::Path;
|
||||
use types::{
|
||||
Attestation, AttesterSlashing, BeaconBlock, BeaconBlockBody, BeaconBlockBodyCapella,
|
||||
BeaconBlockBodyDeneb, BeaconBlockBodyMerge, BeaconState, BlindedPayload, ChainSpec, Deposit,
|
||||
EthSpec, ExecutionPayload, ForkName, FullPayload, ProposerSlashing, SignedBlsToExecutionChange,
|
||||
BeaconBlockBodyDeneb, BeaconBlockBodyMerge, BeaconState, BlindedPayload, Deposit,
|
||||
ExecutionPayload, FullPayload, ProposerSlashing, SignedBlsToExecutionChange,
|
||||
SignedVoluntaryExit, SyncAggregate,
|
||||
};
|
||||
|
||||
@@ -41,8 +39,8 @@ struct ExecutionMetadata {
|
||||
|
||||
/// Newtype for testing withdrawals.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct WithdrawalsPayload<T: EthSpec> {
|
||||
payload: FullPayload<T>,
|
||||
pub struct WithdrawalsPayload<E: EthSpec> {
|
||||
payload: FullPayload<E>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -103,7 +101,8 @@ impl<E: EthSpec> Operation<E> for Attestation<E> {
|
||||
BeaconState::Altair(_)
|
||||
| BeaconState::Merge(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_) => {
|
||||
| BeaconState::Deneb(_)
|
||||
| BeaconState::Electra(_) => {
|
||||
initialize_progressive_balances_cache(state, spec)?;
|
||||
altair_deneb::process_attestation(
|
||||
state,
|
||||
|
||||
@@ -7,7 +7,7 @@ use state_processing::{
|
||||
per_block_processing, per_slot_processing, BlockProcessingError, BlockSignatureStrategy,
|
||||
ConsensusContext, StateProcessingStrategy, VerifyBlockRoot,
|
||||
};
|
||||
use types::{BeaconState, EthSpec, ForkName, RelativeEpoch, SignedBeaconBlock};
|
||||
use types::{BeaconState, RelativeEpoch, SignedBeaconBlock};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Metadata {
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::case_result::{check_state_diff, compare_beacon_state_results_without_
|
||||
use crate::decode::{ssz_decode_state, yaml_decode_file};
|
||||
use serde::Deserialize;
|
||||
use state_processing::per_slot_processing;
|
||||
use types::{BeaconState, EthSpec, ForkName};
|
||||
use types::BeaconState;
|
||||
|
||||
#[derive(Debug, Clone, Default, Deserialize)]
|
||||
pub struct Metadata {
|
||||
|
||||
@@ -4,29 +4,28 @@ use crate::decode::yaml_decode_file;
|
||||
use serde::Deserialize;
|
||||
use std::marker::PhantomData;
|
||||
use swap_or_not_shuffle::{compute_shuffled_index, shuffle_list};
|
||||
use types::ForkName;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Shuffling<T> {
|
||||
pub struct Shuffling<E> {
|
||||
pub seed: String,
|
||||
pub count: usize,
|
||||
pub mapping: Vec<usize>,
|
||||
#[serde(skip)]
|
||||
_phantom: PhantomData<T>,
|
||||
_phantom: PhantomData<E>,
|
||||
}
|
||||
|
||||
impl<T: EthSpec> LoadCase for Shuffling<T> {
|
||||
impl<E: EthSpec> LoadCase for Shuffling<E> {
|
||||
fn load_from_dir(path: &Path, _fork_name: ForkName) -> Result<Self, Error> {
|
||||
yaml_decode_file(&path.join("mapping.yaml"))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EthSpec> Case for Shuffling<T> {
|
||||
impl<E: EthSpec> Case for Shuffling<E> {
|
||||
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
|
||||
if self.count == 0 {
|
||||
compare_result::<_, Error>(&Ok(vec![]), &Some(self.mapping.clone()))?;
|
||||
} else {
|
||||
let spec = T::default_spec();
|
||||
let spec = E::default_spec();
|
||||
let seed = hex::decode(&self.seed[2..])
|
||||
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?;
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ use crate::cases::ssz_static::{check_serialization, check_tree_hash};
|
||||
use crate::decode::{log_file_access, snappy_decode_file, yaml_decode_file};
|
||||
use serde::{de::Error as SerdeError, Deserialize, Deserializer};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use std::path::{Path, PathBuf};
|
||||
use tree_hash_derive::TreeHash;
|
||||
use types::typenum::*;
|
||||
use types::{BitList, BitVector, ForkName, VariableList, Vector};
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use super::*;
|
||||
use crate::case_result::compare_result;
|
||||
use crate::cases::common::SszStaticType;
|
||||
use crate::decode::{snappy_decode_file, yaml_decode_file};
|
||||
use serde::Deserialize;
|
||||
use ssz::Decode;
|
||||
use tree_hash::TreeHash;
|
||||
use types::{BeaconBlock, BeaconState, ForkName, Hash256, SignedBeaconBlock};
|
||||
use types::{BeaconBlock, BeaconState, Hash256, SignedBeaconBlock};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
struct SszStaticRoots {
|
||||
|
||||
@@ -7,7 +7,7 @@ use state_processing::{
|
||||
ConsensusContext, StateProcessingStrategy, VerifyBlockRoot,
|
||||
};
|
||||
use std::str::FromStr;
|
||||
use types::{BeaconState, Epoch, ForkName, SignedBeaconBlock};
|
||||
use types::{BeaconState, Epoch, SignedBeaconBlock};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Metadata {
|
||||
@@ -53,6 +53,13 @@ impl<E: EthSpec> LoadCase for TransitionTest<E> {
|
||||
spec.capella_fork_epoch = Some(Epoch::new(0));
|
||||
spec.deneb_fork_epoch = Some(metadata.fork_epoch);
|
||||
}
|
||||
ForkName::Electra => {
|
||||
spec.altair_fork_epoch = Some(Epoch::new(0));
|
||||
spec.bellatrix_fork_epoch = Some(Epoch::new(0));
|
||||
spec.capella_fork_epoch = Some(Epoch::new(0));
|
||||
spec.deneb_fork_epoch = Some(Epoch::new(0));
|
||||
spec.electra_fork_epoch = Some(metadata.fork_epoch);
|
||||
}
|
||||
}
|
||||
|
||||
// Load blocks
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::fs::{self};
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use types::{BeaconState, EthSpec};
|
||||
use types::BeaconState;
|
||||
|
||||
/// See `log_file_access` for details.
|
||||
const ACCESSED_FILE_LOG_FILENAME: &str = ".accessed_file_log.txt";
|
||||
|
||||
@@ -18,13 +18,20 @@ pub trait Handler {
|
||||
|
||||
fn handler_name(&self) -> String;
|
||||
|
||||
// Add forks here to exclude them from EF spec testing. Helpful for adding future or
|
||||
// unspecified forks.
|
||||
// TODO(electra): Enable Electra once spec tests are available.
|
||||
fn disabled_forks(&self) -> Vec<ForkName> {
|
||||
vec![ForkName::Electra]
|
||||
}
|
||||
|
||||
fn is_enabled_for_fork(&self, fork_name: ForkName) -> bool {
|
||||
Self::Case::is_enabled_for_fork(fork_name)
|
||||
}
|
||||
|
||||
fn run(&self) {
|
||||
for fork_name in ForkName::list_all() {
|
||||
if self.is_enabled_for_fork(fork_name) {
|
||||
if !self.disabled_forks().contains(&fork_name) && self.is_enabled_for_fork(fork_name) {
|
||||
self.run_for_fork(fork_name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,38 @@ type_name!(Fork);
|
||||
type_name!(ForkData);
|
||||
type_name_generic!(HistoricalBatch);
|
||||
type_name_generic!(IndexedAttestation);
|
||||
type_name_generic!(LightClientBootstrap);
|
||||
type_name_generic!(LightClientBootstrapAltair, "LightClientBootstrap");
|
||||
type_name_generic!(LightClientBootstrapCapella, "LightClientBootstrap");
|
||||
type_name_generic!(LightClientBootstrapDeneb, "LightClientBootstrap");
|
||||
type_name_generic!(LightClientFinalityUpdate);
|
||||
type_name_generic!(LightClientFinalityUpdateAltair, "LightClientFinalityUpdate");
|
||||
type_name_generic!(
|
||||
LightClientFinalityUpdateCapella,
|
||||
"LightClientFinalityUpdate"
|
||||
);
|
||||
type_name_generic!(LightClientFinalityUpdateDeneb, "LightClientFinalityUpdate");
|
||||
type_name_generic!(LightClientHeader);
|
||||
type_name_generic!(LightClientHeaderDeneb, "LightClientHeader");
|
||||
type_name_generic!(LightClientHeaderCapella, "LightClientHeader");
|
||||
type_name_generic!(LightClientHeaderAltair, "LightClientHeader");
|
||||
type_name_generic!(LightClientOptimisticUpdate);
|
||||
type_name_generic!(
|
||||
LightClientOptimisticUpdateAltair,
|
||||
"LightClientOptimisticUpdate"
|
||||
);
|
||||
type_name_generic!(
|
||||
LightClientOptimisticUpdateCapella,
|
||||
"LightClientOptimisticUpdate"
|
||||
);
|
||||
type_name_generic!(
|
||||
LightClientOptimisticUpdateDeneb,
|
||||
"LightClientOptimisticUpdate"
|
||||
);
|
||||
type_name_generic!(LightClientUpdate);
|
||||
type_name_generic!(LightClientUpdateAltair, "LightClientUpdate");
|
||||
type_name_generic!(LightClientUpdateCapella, "LightClientUpdate");
|
||||
type_name_generic!(LightClientUpdateDeneb, "LightClientUpdate");
|
||||
type_name_generic!(PendingAttestation);
|
||||
type_name!(ProposerSlashing);
|
||||
type_name_generic!(SignedAggregateAndProof);
|
||||
|
||||
@@ -217,7 +217,7 @@ mod ssz_static {
|
||||
use ef_tests::{Handler, SszStaticHandler, SszStaticTHCHandler, SszStaticWithSpecHandler};
|
||||
use types::blob_sidecar::BlobIdentifier;
|
||||
use types::historical_summary::HistoricalSummary;
|
||||
use types::*;
|
||||
use types::{LightClientBootstrapAltair, *};
|
||||
|
||||
ssz_static_test!(aggregate_and_proof, AggregateAndProof<_>);
|
||||
ssz_static_test!(attestation, Attestation<_>);
|
||||
@@ -236,7 +236,6 @@ mod ssz_static {
|
||||
ssz_static_test!(fork_data, ForkData);
|
||||
ssz_static_test!(historical_batch, HistoricalBatch<_>);
|
||||
ssz_static_test!(indexed_attestation, IndexedAttestation<_>);
|
||||
// NOTE: LightClient* intentionally omitted
|
||||
ssz_static_test!(pending_attestation, PendingAttestation<_>);
|
||||
ssz_static_test!(proposer_slashing, ProposerSlashing);
|
||||
ssz_static_test!(signed_aggregate_and_proof, SignedAggregateAndProof<_>);
|
||||
@@ -250,7 +249,6 @@ mod ssz_static {
|
||||
ssz_static_test!(signing_data, SigningData);
|
||||
ssz_static_test!(validator, Validator);
|
||||
ssz_static_test!(voluntary_exit, VoluntaryExit);
|
||||
|
||||
// BeaconBlockBody has no internal indicator of which fork it is for, so we test it separately.
|
||||
#[test]
|
||||
fn beacon_block_body() {
|
||||
@@ -285,6 +283,135 @@ mod ssz_static {
|
||||
.run();
|
||||
}
|
||||
|
||||
// LightClientBootstrap has no internal indicator of which fork it is for, so we test it separately.
|
||||
#[test]
|
||||
fn light_client_bootstrap() {
|
||||
SszStaticHandler::<LightClientBootstrapAltair<MinimalEthSpec>, MinimalEthSpec>::altair_only()
|
||||
.run();
|
||||
SszStaticHandler::<LightClientBootstrapAltair<MainnetEthSpec>, MainnetEthSpec>::altair_only()
|
||||
.run();
|
||||
SszStaticHandler::<LightClientBootstrapAltair<MinimalEthSpec>, MinimalEthSpec>::merge_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientBootstrapAltair<MainnetEthSpec>, MainnetEthSpec>::merge_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientBootstrapCapella<MinimalEthSpec>, MinimalEthSpec>::capella_only()
|
||||
.run();
|
||||
SszStaticHandler::<LightClientBootstrapCapella<MainnetEthSpec>, MainnetEthSpec>::capella_only()
|
||||
.run();
|
||||
SszStaticHandler::<LightClientBootstrapDeneb<MinimalEthSpec>, MinimalEthSpec>::deneb_only()
|
||||
.run();
|
||||
SszStaticHandler::<LightClientBootstrapDeneb<MainnetEthSpec>, MainnetEthSpec>::deneb_only()
|
||||
.run();
|
||||
}
|
||||
|
||||
// LightClientHeader has no internal indicator of which fork it is for, so we test it separately.
|
||||
#[test]
|
||||
fn light_client_header() {
|
||||
SszStaticHandler::<LightClientHeaderAltair<MinimalEthSpec>, MinimalEthSpec>::altair_only()
|
||||
.run();
|
||||
SszStaticHandler::<LightClientHeaderAltair<MainnetEthSpec>, MainnetEthSpec>::altair_only()
|
||||
.run();
|
||||
SszStaticHandler::<LightClientHeaderAltair<MinimalEthSpec>, MinimalEthSpec>::merge_only()
|
||||
.run();
|
||||
SszStaticHandler::<LightClientHeaderAltair<MainnetEthSpec>, MainnetEthSpec>::merge_only()
|
||||
.run();
|
||||
|
||||
SszStaticHandler::<LightClientHeaderCapella<MinimalEthSpec>, MinimalEthSpec>::capella_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientHeaderCapella<MainnetEthSpec>, MainnetEthSpec>::capella_only(
|
||||
)
|
||||
.run();
|
||||
|
||||
SszStaticHandler::<LightClientHeaderDeneb<MinimalEthSpec>, MinimalEthSpec>::deneb_only()
|
||||
.run();
|
||||
SszStaticHandler::<LightClientHeaderDeneb<MainnetEthSpec>, MainnetEthSpec>::deneb_only()
|
||||
.run();
|
||||
}
|
||||
|
||||
// LightClientOptimisticUpdate has no internal indicator of which fork it is for, so we test it separately.
|
||||
#[test]
|
||||
fn light_client_optimistic_update() {
|
||||
SszStaticHandler::<LightClientOptimisticUpdateAltair<MinimalEthSpec>, MinimalEthSpec>::altair_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientOptimisticUpdateAltair<MainnetEthSpec>, MainnetEthSpec>::altair_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientOptimisticUpdateAltair<MinimalEthSpec>, MinimalEthSpec>::merge_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientOptimisticUpdateAltair<MainnetEthSpec>, MainnetEthSpec>::merge_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientOptimisticUpdateCapella<MinimalEthSpec>, MinimalEthSpec>::capella_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientOptimisticUpdateCapella<MainnetEthSpec>, MainnetEthSpec>::capella_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientOptimisticUpdateDeneb<MinimalEthSpec>, MinimalEthSpec>::deneb_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientOptimisticUpdateDeneb<MainnetEthSpec>, MainnetEthSpec>::deneb_only(
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
// LightClientFinalityUpdate has no internal indicator of which fork it is for, so we test it separately.
|
||||
#[test]
|
||||
fn light_client_finality_update() {
|
||||
SszStaticHandler::<LightClientFinalityUpdateAltair<MinimalEthSpec>, MinimalEthSpec>::altair_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientFinalityUpdateAltair<MainnetEthSpec>, MainnetEthSpec>::altair_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientFinalityUpdateAltair<MinimalEthSpec>, MinimalEthSpec>::merge_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientFinalityUpdateAltair<MainnetEthSpec>, MainnetEthSpec>::merge_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientFinalityUpdateCapella<MinimalEthSpec>, MinimalEthSpec>::capella_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientFinalityUpdateCapella<MainnetEthSpec>, MainnetEthSpec>::capella_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientFinalityUpdateDeneb<MinimalEthSpec>, MinimalEthSpec>::deneb_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientFinalityUpdateDeneb<MainnetEthSpec>, MainnetEthSpec>::deneb_only(
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
// LightClientUpdate has no internal indicator of which fork it is for, so we test it separately.
|
||||
#[test]
|
||||
fn light_client_update() {
|
||||
SszStaticHandler::<LightClientUpdateAltair<MinimalEthSpec>, MinimalEthSpec>::altair_only()
|
||||
.run();
|
||||
SszStaticHandler::<LightClientUpdateAltair<MainnetEthSpec>, MainnetEthSpec>::altair_only()
|
||||
.run();
|
||||
SszStaticHandler::<LightClientUpdateAltair<MinimalEthSpec>, MinimalEthSpec>::merge_only()
|
||||
.run();
|
||||
SszStaticHandler::<LightClientUpdateAltair<MainnetEthSpec>, MainnetEthSpec>::merge_only()
|
||||
.run();
|
||||
SszStaticHandler::<LightClientUpdateCapella<MinimalEthSpec>, MinimalEthSpec>::capella_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientUpdateCapella<MainnetEthSpec>, MainnetEthSpec>::capella_only(
|
||||
)
|
||||
.run();
|
||||
SszStaticHandler::<LightClientUpdateDeneb<MinimalEthSpec>, MinimalEthSpec>::deneb_only()
|
||||
.run();
|
||||
SszStaticHandler::<LightClientUpdateDeneb<MainnetEthSpec>, MainnetEthSpec>::deneb_only()
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signed_contribution_and_proof() {
|
||||
SszStaticHandler::<SignedContributionAndProof<MinimalEthSpec>, MinimalEthSpec>::altair_and_later().run();
|
||||
|
||||
Reference in New Issue
Block a user