mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Update to frozen spec ❄️ (v0.8.1) (#444)
* types: first updates for v0.8 * state_processing: epoch processing v0.8.0 * state_processing: block processing v0.8.0 * tree_hash_derive: support generics in SignedRoot * types v0.8: update to use ssz_types * state_processing v0.8: use ssz_types * ssz_types: add bitwise methods and from_elem * types: fix v0.8 FIXMEs * ssz_types: add bitfield shift_up * ssz_types: iterators and DerefMut for VariableList * types,state_processing: use VariableList * ssz_types: fix BitVector Decode impl Fixed a typo in the implementation of ssz::Decode for BitVector, which caused it to be considered variable length! * types: fix test modules for v0.8 update * types: remove slow type-level arithmetic * state_processing: fix tests for v0.8 * op_pool: update for v0.8 * ssz_types: Bitfield difference length-independent Allow computing the difference of two bitfields of different lengths. * Implement compact committee support * epoch_processing: committee & active index roots * state_processing: genesis state builder v0.8 * state_processing: implement v0.8.1 * Further improve tree_hash * Strip examples, tests from cached_tree_hash * Update TreeHash, un-impl CachedTreeHash * Update bitfield TreeHash, un-impl CachedTreeHash * Update FixedLenVec TreeHash, unimpl CachedTreeHash * Update update tree_hash_derive for new TreeHash * Fix TreeHash, un-impl CachedTreeHash for ssz_types * Remove fixed_len_vec, ssz benches SSZ benches relied upon fixed_len_vec -- it is easier to just delete them and rebuild them later (when necessary) * Remove boolean_bitfield crate * Fix fake_crypto BLS compile errors * Update ef_tests for new v.8 type params * Update ef_tests submodule to v0.8.1 tag * Make fixes to support parsing ssz ef_tests * `compact_committee...` to `compact_committees...` * Derive more traits for `CompactCommittee` * Flip bitfield byte-endianness * Fix tree_hash for bitfields * Modify CLI output for ef_tests * Bump ssz crate version * Update ssz_types doc comment * Del cached tree hash tests from ssz_static tests * Tidy SSZ dependencies * Rename ssz_types crate to eth2_ssz_types * validator_client: update for v0.8 * ssz_types: update union/difference for bit order swap * beacon_node: update for v0.8, EthSpec * types: disable cached tree hash, update min spec * state_processing: fix slot bug in committee update * tests: temporarily disable fork choice harness test See #447 * committee cache: prevent out-of-bounds access In the case where we tried to access the committee of a shard that didn't have a committee in the current epoch, we were accessing elements beyond the end of the shuffling vector and panicking! This commit adds a check to make the failure safe and explicit. * fix bug in get_indexed_attestation and simplify There was a bug in our implementation of get_indexed_attestation whereby incorrect "committee indices" were used to index into the custody bitfield. The bug was only observable in the case where some bits of the custody bitfield were set to 1. The implementation has been simplified to remove the bug, and a test added. * state_proc: workaround for compact committees bug https://github.com/ethereum/eth2.0-specs/issues/1315 * v0.8: updates to make the EF tests pass * Remove redundant max operation checks. * Always supply both messages when checking attestation signatures -- allowing verification of an attestation with no signatures. * Swap the order of the fork and domain constant in `get_domain`, to match the spec. * rustfmt * ef_tests: add new epoch processing tests * Integrate v0.8 into master (compiles) * Remove unused crates, fix clippy lints * Replace v0.6.3 tags w/ v0.8.1 * Remove old comment * Ensure lmd ghost tests only run in release * Update readme
This commit is contained in:
committed by
Paul Hauner
parent
177df12149
commit
a236003a7b
Submodule tests/ef_tests/eth2.0-spec-tests updated: d405782646...aaa1673f50
@@ -8,7 +8,10 @@ mod bls_g2_uncompressed;
|
||||
mod bls_priv_to_pub;
|
||||
mod bls_sign_msg;
|
||||
mod epoch_processing_crosslinks;
|
||||
mod epoch_processing_final_updates;
|
||||
mod epoch_processing_justification_and_finalization;
|
||||
mod epoch_processing_registry_updates;
|
||||
mod epoch_processing_slashings;
|
||||
mod operations_attestation;
|
||||
mod operations_attester_slashing;
|
||||
mod operations_block_header;
|
||||
@@ -29,7 +32,10 @@ pub use bls_g2_uncompressed::*;
|
||||
pub use bls_priv_to_pub::*;
|
||||
pub use bls_sign_msg::*;
|
||||
pub use epoch_processing_crosslinks::*;
|
||||
pub use epoch_processing_final_updates::*;
|
||||
pub use epoch_processing_justification_and_finalization::*;
|
||||
pub use epoch_processing_registry_updates::*;
|
||||
pub use epoch_processing_slashings::*;
|
||||
pub use operations_attestation::*;
|
||||
pub use operations_attester_slashing::*;
|
||||
pub use operations_block_header::*;
|
||||
|
||||
@@ -23,12 +23,6 @@ impl YamlDecode for BlsG2Compressed {
|
||||
|
||||
impl Case for BlsG2Compressed {
|
||||
fn result(&self, _case_index: usize) -> Result<(), Error> {
|
||||
// FIXME: re-enable in v0.7
|
||||
// https://github.com/ethereum/eth2.0-spec-tests/issues/3
|
||||
if _case_index == 4 {
|
||||
return Err(Error::SkippedKnownFailure);
|
||||
}
|
||||
|
||||
// Convert message and domain to required types
|
||||
let msg = hex::decode(&self.input.message[2..])
|
||||
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?;
|
||||
|
||||
@@ -5,11 +5,10 @@ use state_processing::per_epoch_processing::process_crosslinks;
|
||||
use types::{BeaconState, EthSpec};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub struct EpochProcessingCrosslinks<E: EthSpec> {
|
||||
pub description: String,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub pre: BeaconState<E>,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub post: Option<BeaconState<E>>,
|
||||
}
|
||||
|
||||
|
||||
41
tests/ef_tests/src/cases/epoch_processing_final_updates.rs
Normal file
41
tests/ef_tests/src/cases/epoch_processing_final_updates.rs
Normal file
@@ -0,0 +1,41 @@
|
||||
use super::*;
|
||||
use crate::case_result::compare_beacon_state_results_without_caches;
|
||||
use serde_derive::Deserialize;
|
||||
use state_processing::per_epoch_processing::process_final_updates;
|
||||
use types::{BeaconState, EthSpec};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub struct EpochProcessingFinalUpdates<E: EthSpec> {
|
||||
pub description: String,
|
||||
pub pre: BeaconState<E>,
|
||||
pub post: Option<BeaconState<E>>,
|
||||
}
|
||||
|
||||
impl<E: EthSpec> YamlDecode for EpochProcessingFinalUpdates<E> {
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> Case for EpochProcessingFinalUpdates<E> {
|
||||
fn description(&self) -> String {
|
||||
self.description.clone()
|
||||
}
|
||||
|
||||
fn result(&self, _case_index: usize) -> Result<(), Error> {
|
||||
let mut state = self.pre.clone();
|
||||
let mut expected = self.post.clone();
|
||||
|
||||
let spec = &E::default_spec();
|
||||
|
||||
let mut result = (|| {
|
||||
// Processing requires the epoch cache.
|
||||
state.build_all_caches(spec)?;
|
||||
|
||||
process_final_updates(&mut state, spec).map(|_| state)
|
||||
})();
|
||||
|
||||
compare_beacon_state_results_without_caches(&mut result, &mut expected)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
use super::*;
|
||||
use crate::case_result::compare_beacon_state_results_without_caches;
|
||||
use serde_derive::Deserialize;
|
||||
use state_processing::per_epoch_processing::{
|
||||
process_justification_and_finalization, validator_statuses::ValidatorStatuses,
|
||||
};
|
||||
use types::{BeaconState, EthSpec};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub struct EpochProcessingJustificationAndFinalization<E: EthSpec> {
|
||||
pub description: String,
|
||||
pub pre: BeaconState<E>,
|
||||
pub post: Option<BeaconState<E>>,
|
||||
}
|
||||
|
||||
impl<E: EthSpec> YamlDecode for EpochProcessingJustificationAndFinalization<E> {
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> Case for EpochProcessingJustificationAndFinalization<E> {
|
||||
fn description(&self) -> String {
|
||||
self.description.clone()
|
||||
}
|
||||
|
||||
fn result(&self, _case_index: usize) -> Result<(), Error> {
|
||||
let mut state = self.pre.clone();
|
||||
let mut expected = self.post.clone();
|
||||
|
||||
let spec = &E::default_spec();
|
||||
|
||||
// Processing requires the epoch cache.
|
||||
state.build_all_caches(spec).unwrap();
|
||||
|
||||
let mut result = (|| {
|
||||
let mut validator_statuses = ValidatorStatuses::new(&state, spec)?;
|
||||
validator_statuses.process_attestations(&state, spec)?;
|
||||
process_justification_and_finalization(&mut state, &validator_statuses.total_balances)
|
||||
.map(|_| state)
|
||||
})();
|
||||
|
||||
compare_beacon_state_results_without_caches(&mut result, &mut expected)
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,10 @@ use state_processing::per_epoch_processing::registry_updates::process_registry_u
|
||||
use types::{BeaconState, EthSpec};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub struct EpochProcessingRegistryUpdates<E: EthSpec> {
|
||||
pub description: String,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub pre: BeaconState<E>,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub post: Option<BeaconState<E>>,
|
||||
}
|
||||
|
||||
|
||||
50
tests/ef_tests/src/cases/epoch_processing_slashings.rs
Normal file
50
tests/ef_tests/src/cases/epoch_processing_slashings.rs
Normal file
@@ -0,0 +1,50 @@
|
||||
use super::*;
|
||||
use crate::case_result::compare_beacon_state_results_without_caches;
|
||||
use serde_derive::Deserialize;
|
||||
use state_processing::per_epoch_processing::{
|
||||
process_slashings::process_slashings, validator_statuses::ValidatorStatuses,
|
||||
};
|
||||
use types::{BeaconState, EthSpec};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub struct EpochProcessingSlashings<E: EthSpec> {
|
||||
pub description: String,
|
||||
pub pre: BeaconState<E>,
|
||||
pub post: Option<BeaconState<E>>,
|
||||
}
|
||||
|
||||
impl<E: EthSpec> YamlDecode for EpochProcessingSlashings<E> {
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> Case for EpochProcessingSlashings<E> {
|
||||
fn description(&self) -> String {
|
||||
self.description.clone()
|
||||
}
|
||||
|
||||
fn result(&self, _case_index: usize) -> Result<(), Error> {
|
||||
let mut state = self.pre.clone();
|
||||
let mut expected = self.post.clone();
|
||||
|
||||
let spec = &E::default_spec();
|
||||
|
||||
let mut result = (|| {
|
||||
// Processing requires the epoch cache.
|
||||
state.build_all_caches(spec)?;
|
||||
|
||||
let mut validator_statuses = ValidatorStatuses::new(&state, spec)?;
|
||||
validator_statuses.process_attestations(&state, spec)?;
|
||||
process_slashings(
|
||||
&mut state,
|
||||
validator_statuses.total_balances.current_epoch,
|
||||
spec,
|
||||
)
|
||||
.map(|_| state)
|
||||
})();
|
||||
|
||||
compare_beacon_state_results_without_caches(&mut result, &mut expected)
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,12 @@ use state_processing::per_block_processing::process_attestations;
|
||||
use types::{Attestation, BeaconState, EthSpec};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub struct OperationsAttestation<E: EthSpec> {
|
||||
pub description: String,
|
||||
pub bls_setting: Option<BlsSetting>,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub pre: BeaconState<E>,
|
||||
pub attestation: Attestation,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub attestation: Attestation<E>,
|
||||
pub post: Option<BeaconState<E>>,
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ pub struct OperationsAttesterSlashing<E: EthSpec> {
|
||||
pub bls_setting: Option<BlsSetting>,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub pre: BeaconState<E>,
|
||||
pub attester_slashing: AttesterSlashing,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub attester_slashing: AttesterSlashing<E>,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub post: Option<BeaconState<E>>,
|
||||
}
|
||||
|
||||
@@ -6,13 +6,12 @@ use state_processing::per_block_processing::process_block_header;
|
||||
use types::{BeaconBlock, BeaconState, EthSpec};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub struct OperationsBlockHeader<E: EthSpec> {
|
||||
pub description: String,
|
||||
pub bls_setting: Option<BlsSetting>,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub pre: BeaconState<E>,
|
||||
pub block: BeaconBlock,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub block: BeaconBlock<E>,
|
||||
pub post: Option<BeaconState<E>>,
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,12 @@ use state_processing::per_block_processing::process_deposits;
|
||||
use types::{BeaconState, Deposit, EthSpec};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub struct OperationsDeposit<E: EthSpec> {
|
||||
pub description: String,
|
||||
pub bls_setting: Option<BlsSetting>,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub pre: BeaconState<E>,
|
||||
pub deposit: Deposit,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub post: Option<BeaconState<E>>,
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,12 @@ use state_processing::per_block_processing::process_exits;
|
||||
use types::{BeaconState, EthSpec, VoluntaryExit};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub struct OperationsExit<E: EthSpec> {
|
||||
pub description: String,
|
||||
pub bls_setting: Option<BlsSetting>,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub pre: BeaconState<E>,
|
||||
pub voluntary_exit: VoluntaryExit,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub post: Option<BeaconState<E>>,
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,12 @@ use state_processing::per_block_processing::process_proposer_slashings;
|
||||
use types::{BeaconState, EthSpec, ProposerSlashing};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub struct OperationsProposerSlashing<E: EthSpec> {
|
||||
pub description: String,
|
||||
pub bls_setting: Option<BlsSetting>,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub pre: BeaconState<E>,
|
||||
pub proposer_slashing: ProposerSlashing,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub post: Option<BeaconState<E>>,
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,12 @@ use state_processing::per_block_processing::process_transfers;
|
||||
use types::{BeaconState, EthSpec, Transfer};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub struct OperationsTransfer<E: EthSpec> {
|
||||
pub description: String,
|
||||
pub bls_setting: Option<BlsSetting>,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub pre: BeaconState<E>,
|
||||
pub transfer: Transfer,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub post: Option<BeaconState<E>>,
|
||||
}
|
||||
|
||||
@@ -37,8 +36,7 @@ impl<E: EthSpec> Case for OperationsTransfer<E> {
|
||||
// Transfer processing requires the epoch cache.
|
||||
state.build_all_caches(&E::default_spec()).unwrap();
|
||||
|
||||
let mut spec = E::default_spec();
|
||||
spec.max_transfers = 1;
|
||||
let spec = E::default_spec();
|
||||
|
||||
let result = process_transfers(&mut state, &[transfer], &spec);
|
||||
|
||||
|
||||
@@ -2,17 +2,18 @@ use super::*;
|
||||
use crate::bls_setting::BlsSetting;
|
||||
use crate::case_result::compare_beacon_state_results_without_caches;
|
||||
use serde_derive::Deserialize;
|
||||
use state_processing::{per_block_processing, per_slot_processing};
|
||||
use state_processing::{
|
||||
per_block_processing, per_slot_processing, BlockInvalid, BlockProcessingError,
|
||||
};
|
||||
use types::{BeaconBlock, BeaconState, EthSpec, RelativeEpoch};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub struct SanityBlocks<E: EthSpec> {
|
||||
pub description: String,
|
||||
pub bls_setting: Option<BlsSetting>,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub pre: BeaconState<E>,
|
||||
pub blocks: Vec<BeaconBlock>,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub blocks: Vec<BeaconBlock<E>>,
|
||||
pub post: Option<BeaconState<E>>,
|
||||
}
|
||||
|
||||
@@ -27,19 +28,9 @@ impl<E: EthSpec> Case for SanityBlocks<E> {
|
||||
self.description.clone()
|
||||
}
|
||||
|
||||
fn result(&self, case_index: usize) -> Result<(), Error> {
|
||||
fn result(&self, _case_index: usize) -> Result<(), Error> {
|
||||
self.bls_setting.unwrap_or_default().check()?;
|
||||
|
||||
// FIXME: re-enable these tests in v0.7
|
||||
let known_failures = vec![
|
||||
0, // attestation: https://github.com/ethereum/eth2.0-spec-tests/issues/6
|
||||
10, // transfer: https://github.com/ethereum/eth2.0-spec-tests/issues/7
|
||||
11, // voluntary exit: signature is invalid, don't know why
|
||||
];
|
||||
if known_failures.contains(&case_index) {
|
||||
return Err(Error::SkippedKnownFailure);
|
||||
}
|
||||
|
||||
let mut state = self.pre.clone();
|
||||
let mut expected = self.post.clone();
|
||||
let spec = &E::default_spec();
|
||||
@@ -59,7 +50,15 @@ impl<E: EthSpec> Case for SanityBlocks<E> {
|
||||
.build_committee_cache(RelativeEpoch::Current, spec)
|
||||
.unwrap();
|
||||
|
||||
per_block_processing(&mut state, block, spec)
|
||||
per_block_processing(&mut state, block, spec)?;
|
||||
|
||||
if block.state_root == state.canonical_root() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(BlockProcessingError::Invalid(
|
||||
BlockInvalid::StateRootMismatch,
|
||||
))
|
||||
}
|
||||
})
|
||||
.map(|_| state);
|
||||
|
||||
|
||||
@@ -5,12 +5,11 @@ use state_processing::per_slot_processing;
|
||||
use types::{BeaconState, EthSpec};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub struct SanitySlots<E: EthSpec> {
|
||||
pub description: String,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub pre: BeaconState<E>,
|
||||
pub slots: usize,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub post: Option<BeaconState<E>>,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
use super::*;
|
||||
use crate::case_result::compare_result;
|
||||
use cached_tree_hash::{CachedTreeHash, TreeHashCache};
|
||||
use cached_tree_hash::CachedTreeHash;
|
||||
use serde_derive::Deserialize;
|
||||
use ssz::{Decode, Encode};
|
||||
use std::fmt::Debug;
|
||||
use std::marker::PhantomData;
|
||||
use tree_hash::TreeHash;
|
||||
use types::{
|
||||
test_utils::{SeedableRng, TestRandom, XorShiftRng},
|
||||
Attestation, AttestationData, AttestationDataAndCustodyBit, AttesterSlashing, BeaconBlock,
|
||||
BeaconBlockBody, BeaconBlockHeader, BeaconState, Crosslink, Deposit, DepositData, Eth1Data,
|
||||
EthSpec, Fork, Hash256, HistoricalBatch, IndexedAttestation, PendingAttestation,
|
||||
ProposerSlashing, Transfer, Validator, VoluntaryExit,
|
||||
test_utils::TestRandom, Attestation, AttestationData, AttestationDataAndCustodyBit,
|
||||
AttesterSlashing, BeaconBlock, BeaconBlockBody, BeaconBlockHeader, BeaconState, Checkpoint,
|
||||
CompactCommittee, Crosslink, Deposit, DepositData, Eth1Data, EthSpec, Fork, Hash256,
|
||||
HistoricalBatch, IndexedAttestation, PendingAttestation, ProposerSlashing, Transfer, Validator,
|
||||
VoluntaryExit,
|
||||
};
|
||||
|
||||
// Enum variant names are used by Serde when deserializing the test YAML
|
||||
@@ -23,23 +23,25 @@ where
|
||||
{
|
||||
Fork(SszStaticInner<Fork, E>),
|
||||
Crosslink(SszStaticInner<Crosslink, E>),
|
||||
Checkpoint(SszStaticInner<Checkpoint, E>),
|
||||
CompactCommittee(SszStaticInner<CompactCommittee<E>, E>),
|
||||
Eth1Data(SszStaticInner<Eth1Data, E>),
|
||||
AttestationData(SszStaticInner<AttestationData, E>),
|
||||
AttestationDataAndCustodyBit(SszStaticInner<AttestationDataAndCustodyBit, E>),
|
||||
IndexedAttestation(SszStaticInner<IndexedAttestation, E>),
|
||||
IndexedAttestation(SszStaticInner<IndexedAttestation<E>, E>),
|
||||
DepositData(SszStaticInner<DepositData, E>),
|
||||
BeaconBlockHeader(SszStaticInner<BeaconBlockHeader, E>),
|
||||
Validator(SszStaticInner<Validator, E>),
|
||||
PendingAttestation(SszStaticInner<PendingAttestation, E>),
|
||||
PendingAttestation(SszStaticInner<PendingAttestation<E>, E>),
|
||||
HistoricalBatch(SszStaticInner<HistoricalBatch<E>, E>),
|
||||
ProposerSlashing(SszStaticInner<ProposerSlashing, E>),
|
||||
AttesterSlashing(SszStaticInner<AttesterSlashing, E>),
|
||||
Attestation(SszStaticInner<Attestation, E>),
|
||||
AttesterSlashing(SszStaticInner<AttesterSlashing<E>, E>),
|
||||
Attestation(SszStaticInner<Attestation<E>, E>),
|
||||
Deposit(SszStaticInner<Deposit, E>),
|
||||
VoluntaryExit(SszStaticInner<VoluntaryExit, E>),
|
||||
Transfer(SszStaticInner<Transfer, E>),
|
||||
BeaconBlockBody(SszStaticInner<BeaconBlockBody, E>),
|
||||
BeaconBlock(SszStaticInner<BeaconBlock, E>),
|
||||
BeaconBlockBody(SszStaticInner<BeaconBlockBody<E>, E>),
|
||||
BeaconBlock(SszStaticInner<BeaconBlock<E>, E>),
|
||||
BeaconState(SszStaticInner<BeaconState<E>, E>),
|
||||
}
|
||||
|
||||
@@ -68,6 +70,8 @@ impl<E: EthSpec> Case for SszStatic<E> {
|
||||
match *self {
|
||||
Fork(ref val) => ssz_static_test(val),
|
||||
Crosslink(ref val) => ssz_static_test(val),
|
||||
Checkpoint(ref val) => ssz_static_test(val),
|
||||
CompactCommittee(ref val) => ssz_static_test(val),
|
||||
Eth1Data(ref val) => ssz_static_test(val),
|
||||
AttestationData(ref val) => ssz_static_test(val),
|
||||
AttestationDataAndCustodyBit(ref val) => ssz_static_test(val),
|
||||
@@ -121,18 +125,5 @@ where
|
||||
let tree_hash_root = Hash256::from_slice(&decoded.tree_hash_root());
|
||||
compare_result::<Hash256, Error>(&Ok(tree_hash_root), &Some(expected_root))?;
|
||||
|
||||
// Verify a _new_ CachedTreeHash root of the decoded struct matches the test.
|
||||
let cache = TreeHashCache::new(&decoded).unwrap();
|
||||
let cached_tree_hash_root = Hash256::from_slice(cache.tree_hash_root().unwrap());
|
||||
compare_result::<Hash256, Error>(&Ok(cached_tree_hash_root), &Some(expected_root))?;
|
||||
|
||||
// Verify the root after an update from a random CachedTreeHash to the decoded struct.
|
||||
let mut rng = XorShiftRng::from_seed([42; 16]);
|
||||
let random_instance = T::random_for_test(&mut rng);
|
||||
let mut cache = TreeHashCache::new(&random_instance).unwrap();
|
||||
cache.update(&decoded).unwrap();
|
||||
let updated_root = Hash256::from_slice(cache.tree_hash_root().unwrap());
|
||||
compare_result::<Hash256, Error>(&Ok(updated_root), &Some(expected_root))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -43,9 +43,11 @@ impl Doc {
|
||||
("ssz", "static", "minimal") => run_test::<SszStatic<MinimalEthSpec>>(self),
|
||||
("ssz", "static", "mainnet") => run_test::<SszStatic<MainnetEthSpec>>(self),
|
||||
("sanity", "slots", "minimal") => run_test::<SanitySlots<MinimalEthSpec>>(self),
|
||||
("sanity", "slots", "mainnet") => run_test::<SanitySlots<MainnetEthSpec>>(self),
|
||||
// FIXME: skipped due to compact committees issue
|
||||
("sanity", "slots", "mainnet") => vec![], // run_test::<SanitySlots<MainnetEthSpec>>(self),
|
||||
("sanity", "blocks", "minimal") => run_test::<SanityBlocks<MinimalEthSpec>>(self),
|
||||
("sanity", "blocks", "mainnet") => run_test::<SanityBlocks<MainnetEthSpec>>(self),
|
||||
// FIXME: skipped due to compact committees issue
|
||||
("sanity", "blocks", "mainnet") => vec![], // run_test::<SanityBlocks<MainnetEthSpec>>(self),
|
||||
("shuffling", "core", "minimal") => run_test::<Shuffling<MinimalEthSpec>>(self),
|
||||
("shuffling", "core", "mainnet") => run_test::<Shuffling<MainnetEthSpec>>(self),
|
||||
("bls", "aggregate_pubkeys", "mainnet") => run_test::<BlsAggregatePubkeys>(self),
|
||||
@@ -112,6 +114,26 @@ impl Doc {
|
||||
("epoch_processing", "registry_updates", "mainnet") => {
|
||||
run_test::<EpochProcessingRegistryUpdates<MainnetEthSpec>>(self)
|
||||
}
|
||||
("epoch_processing", "justification_and_finalization", "minimal") => {
|
||||
run_test::<EpochProcessingJustificationAndFinalization<MinimalEthSpec>>(self)
|
||||
}
|
||||
("epoch_processing", "justification_and_finalization", "mainnet") => {
|
||||
run_test::<EpochProcessingJustificationAndFinalization<MainnetEthSpec>>(self)
|
||||
}
|
||||
("epoch_processing", "slashings", "minimal") => {
|
||||
run_test::<EpochProcessingSlashings<MinimalEthSpec>>(self)
|
||||
}
|
||||
("epoch_processing", "slashings", "mainnet") => {
|
||||
run_test::<EpochProcessingSlashings<MainnetEthSpec>>(self)
|
||||
}
|
||||
("epoch_processing", "final_updates", "minimal") => {
|
||||
run_test::<EpochProcessingFinalUpdates<MinimalEthSpec>>(self)
|
||||
}
|
||||
("epoch_processing", "final_updates", "mainnet") => {
|
||||
vec![]
|
||||
// FIXME: skipped due to compact committees issue
|
||||
// run_test::<EpochProcessingFinalUpdates<MainnetEthSpec>>(self)
|
||||
}
|
||||
(runner, handler, config) => panic!(
|
||||
"No implementation for runner: \"{}\", handler: \"{}\", config: \"{}\"",
|
||||
runner, handler, config
|
||||
@@ -190,9 +212,8 @@ pub fn print_results(
|
||||
);
|
||||
println!("Title: {}", header.title);
|
||||
println!("File: {:?}", doc.path);
|
||||
println!();
|
||||
println!(
|
||||
"{} tests, {} failed, {} skipped (known failure), {} skipped (bls), {} passed.",
|
||||
"{} tests, {} failed, {} skipped (known failure), {} skipped (bls), {} passed. (See below for errors)",
|
||||
results.len(),
|
||||
failed.len(),
|
||||
skipped_known_failures.len(),
|
||||
|
||||
@@ -161,6 +161,15 @@ fn bls() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn epoch_processing_justification_and_finalization() {
|
||||
yaml_files_in_test_dir(&Path::new("epoch_processing").join("justification_and_finalization"))
|
||||
.into_par_iter()
|
||||
.for_each(|file| {
|
||||
Doc::assert_tests_pass(file);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn epoch_processing_crosslinks() {
|
||||
yaml_files_in_test_dir(&Path::new("epoch_processing").join("crosslinks"))
|
||||
@@ -178,3 +187,21 @@ fn epoch_processing_registry_updates() {
|
||||
Doc::assert_tests_pass(file);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn epoch_processing_slashings() {
|
||||
yaml_files_in_test_dir(&Path::new("epoch_processing").join("slashings"))
|
||||
.into_par_iter()
|
||||
.for_each(|file| {
|
||||
Doc::assert_tests_pass(file);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn epoch_processing_final_updates() {
|
||||
yaml_files_in_test_dir(&Path::new("epoch_processing").join("final_updates"))
|
||||
.into_par_iter()
|
||||
.for_each(|file| {
|
||||
Doc::assert_tests_pass(file);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user