mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 11:41:51 +00:00
Fulu update to spec v1.6.0-alpha.4 (#7890)
Fulu update to spec [v1.6.0-alpha.4](https://github.com/ethereum/consensus-specs/releases/tag/v1.6.0-alpha.4). - Make `number_of_columns` a preset - Optimise `get_custody_groups` to avoid computing if cgc = 128 - Add support for additional typenum values in type_dispatch macro
This commit is contained in:
@@ -50,7 +50,7 @@ pub use bls_eth_fast_aggregate_verify::*;
|
||||
pub use bls_fast_aggregate_verify::*;
|
||||
pub use bls_sign_msg::*;
|
||||
pub use bls_verify_msg::*;
|
||||
pub use common::{DataColumnsByRootIdentifierWrapper, SszStaticType};
|
||||
pub use common::SszStaticType;
|
||||
pub use compute_columns_for_custody_groups::*;
|
||||
pub use epoch_processing::*;
|
||||
pub use fork::ForkTest;
|
||||
|
||||
@@ -3,9 +3,6 @@ use serde::{Deserialize, Deserializer};
|
||||
use ssz::Encode;
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use std::fmt::Debug;
|
||||
use std::marker::PhantomData;
|
||||
use tree_hash::TreeHash;
|
||||
use types::{DataColumnsByRootIdentifier, EthSpec, ForkName, Hash256};
|
||||
|
||||
/// Macro to wrap U128 and U256 so they deserialize correctly.
|
||||
macro_rules! uint_wrapper {
|
||||
@@ -63,62 +60,6 @@ pub trait SszStaticType: Encode + Clone + PartialEq + Debug + Sync {}
|
||||
|
||||
impl<T> SszStaticType for T where T: Encode + Clone + PartialEq + Debug + Sync {}
|
||||
|
||||
/// We need the `EthSpec` to implement `LoadCase` for this type, in order to work out the
|
||||
/// ChainSpec.
|
||||
///
|
||||
/// No other type currently requires this kind of context.
|
||||
#[derive(Debug, Encode, Clone, PartialEq)]
|
||||
#[ssz(struct_behaviour = "transparent")]
|
||||
pub struct DataColumnsByRootIdentifierWrapper<E: EthSpec> {
|
||||
pub value: DataColumnsByRootIdentifier,
|
||||
// SSZ derive is a bit buggy and requires skip_deserializing for transparent to work.
|
||||
#[ssz(skip_serializing, skip_deserializing)]
|
||||
pub _phantom: PhantomData<E>,
|
||||
}
|
||||
|
||||
impl<'de, E: EthSpec> ContextDeserialize<'de, (ForkName, usize)>
|
||||
for DataColumnsByRootIdentifierWrapper<E>
|
||||
{
|
||||
fn context_deserialize<D>(deserializer: D, context: (ForkName, usize)) -> Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let value = DataColumnsByRootIdentifier::context_deserialize(deserializer, context)?;
|
||||
Ok(DataColumnsByRootIdentifierWrapper {
|
||||
value,
|
||||
_phantom: PhantomData,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// We can delete this if we ever get `tree_hash(struct_behaviour = "transparent")`.
|
||||
impl<E: EthSpec> TreeHash for DataColumnsByRootIdentifierWrapper<E> {
|
||||
fn tree_hash_type() -> tree_hash::TreeHashType {
|
||||
DataColumnsByRootIdentifier::tree_hash_type()
|
||||
}
|
||||
|
||||
fn tree_hash_packed_encoding(&self) -> tree_hash::PackedEncoding {
|
||||
self.value.tree_hash_packed_encoding()
|
||||
}
|
||||
|
||||
fn tree_hash_packing_factor() -> usize {
|
||||
DataColumnsByRootIdentifier::tree_hash_packing_factor()
|
||||
}
|
||||
|
||||
fn tree_hash_root(&self) -> Hash256 {
|
||||
self.value.tree_hash_root()
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> From<DataColumnsByRootIdentifier> for DataColumnsByRootIdentifierWrapper<E> {
|
||||
fn from(value: DataColumnsByRootIdentifier) -> Self {
|
||||
Self {
|
||||
value,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! impl_bls_load_case {
|
||||
($case_name:ident) => {
|
||||
|
||||
@@ -27,7 +27,7 @@ impl<E: EthSpec> Case for ComputeColumnsForCustodyGroups<E> {
|
||||
|
||||
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
|
||||
let spec = E::default_spec();
|
||||
let computed_columns = compute_columns_for_custody_group(self.custody_group, &spec)
|
||||
let computed_columns = compute_columns_for_custody_group::<E>(self.custody_group, &spec)
|
||||
.expect("should compute custody columns from group")
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
|
||||
@@ -80,12 +80,16 @@ macro_rules! type_dispatch {
|
||||
"7" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* U7>, $($rest)*),
|
||||
"8" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* U8>, $($rest)*),
|
||||
"9" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* U9>, $($rest)*),
|
||||
"15" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* U15>, $($rest)*),
|
||||
"16" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* U16>, $($rest)*),
|
||||
"17" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* U17>, $($rest)*),
|
||||
"31" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* U31>, $($rest)*),
|
||||
"32" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* U32>, $($rest)*),
|
||||
"33" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* U33>, $($rest)*),
|
||||
"64" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* U64>, $($rest)*),
|
||||
"128" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* U128>, $($rest)*),
|
||||
"256" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* U256>, $($rest)*),
|
||||
"511" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* U511>, $($rest)*),
|
||||
"512" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* U512>, $($rest)*),
|
||||
"513" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* U513>, $($rest)*),
|
||||
"1024" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* U1024>, $($rest)*),
|
||||
@@ -107,6 +111,8 @@ macro_rules! type_dispatch {
|
||||
"VarTestStruct" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* VarTestStruct>, $($rest)*),
|
||||
"ComplexTestStruct" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* ComplexTestStruct>, $($rest)*),
|
||||
"BitsStruct" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* BitsStruct>, $($rest)*),
|
||||
// EIP-7916 is still in draft and hasn't been implemented yet https://eips.ethereum.org/EIPS/eip-7916
|
||||
"ProgressiveTestStruct" | "ProgressiveBitsStruct" => Err(Error::SkippedKnownFailure),
|
||||
_ => Err(Error::FailedToParseTest(format!("unsupported: {}", $value))),
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use super::*;
|
||||
use crate::case_result::compare_result;
|
||||
use crate::cases::common::DataColumnsByRootIdentifierWrapper;
|
||||
use crate::decode::{context_yaml_decode_file, snappy_decode_file, yaml_decode_file};
|
||||
use context_deserialize::ContextDeserialize;
|
||||
use serde::Deserialize;
|
||||
@@ -168,11 +167,9 @@ impl<E: EthSpec> Case for SszStaticWithSpec<SignedBeaconBlock<E>> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> LoadCase for SszStaticWithSpec<DataColumnsByRootIdentifierWrapper<E>> {
|
||||
impl<E: EthSpec> LoadCase for SszStaticWithSpec<DataColumnsByRootIdentifier<E>> {
|
||||
fn load_from_dir(path: &Path, fork_name: ForkName) -> Result<Self, Error> {
|
||||
let spec = &testing_spec::<E>(fork_name);
|
||||
let context = (fork_name, spec.number_of_columns as usize);
|
||||
load_from_dir_with_context(path, context).map(|(roots, serialized, value)| Self {
|
||||
load_from_dir(path, fork_name).map(|(roots, serialized, value)| Self {
|
||||
roots,
|
||||
serialized,
|
||||
value,
|
||||
@@ -180,12 +177,10 @@ impl<E: EthSpec> LoadCase for SszStaticWithSpec<DataColumnsByRootIdentifierWrapp
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> Case for SszStaticWithSpec<DataColumnsByRootIdentifierWrapper<E>> {
|
||||
fn result(&self, _case_index: usize, fork_name: ForkName) -> Result<(), Error> {
|
||||
let spec = &testing_spec::<E>(fork_name);
|
||||
impl<E: EthSpec> Case for SszStaticWithSpec<DataColumnsByRootIdentifier<E>> {
|
||||
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
|
||||
check_serialization(&self.value, &self.serialized, |bytes| {
|
||||
DataColumnsByRootIdentifier::from_ssz_bytes(bytes, spec.number_of_columns as usize)
|
||||
.map(Into::into)
|
||||
DataColumnsByRootIdentifier::from_ssz_bytes(bytes)
|
||||
})?;
|
||||
check_tree_hash(&self.roots.root, self.value.tree_hash_root().as_slice())?;
|
||||
Ok(())
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
pub use case_result::CaseResult;
|
||||
pub use cases::WithdrawalsPayload;
|
||||
pub use cases::{
|
||||
Case, DataColumnsByRootIdentifierWrapper, EffectiveBalanceUpdates, Eth1DataReset, FeatureName,
|
||||
HistoricalRootsUpdate, HistoricalSummariesUpdate, InactivityUpdates,
|
||||
JustificationAndFinalization, ParticipationFlagUpdates, ParticipationRecordUpdates,
|
||||
PendingBalanceDeposits, PendingConsolidations, ProposerLookahead, RandaoMixesReset,
|
||||
RegistryUpdates, RewardsAndPenalties, Slashings, SlashingsReset, SyncCommitteeUpdates,
|
||||
Case, EffectiveBalanceUpdates, Eth1DataReset, FeatureName, HistoricalRootsUpdate,
|
||||
HistoricalSummariesUpdate, InactivityUpdates, JustificationAndFinalization,
|
||||
ParticipationFlagUpdates, ParticipationRecordUpdates, PendingBalanceDeposits,
|
||||
PendingConsolidations, ProposerLookahead, RandaoMixesReset, RegistryUpdates,
|
||||
RewardsAndPenalties, Slashings, SlashingsReset, SyncCommitteeUpdates,
|
||||
};
|
||||
pub use decode::log_file_access;
|
||||
pub use error::Error;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//! Mapping from types to canonical string identifiers used in testing.
|
||||
use crate::DataColumnsByRootIdentifierWrapper;
|
||||
use types::historical_summary::HistoricalSummary;
|
||||
use types::*;
|
||||
|
||||
@@ -59,11 +58,7 @@ type_name_generic!(BeaconBlockBodyFulu, "BeaconBlockBody");
|
||||
type_name!(BeaconBlockHeader);
|
||||
type_name_generic!(BeaconState);
|
||||
type_name!(BlobIdentifier);
|
||||
type_name!(DataColumnsByRootIdentifier);
|
||||
type_name_generic!(
|
||||
DataColumnsByRootIdentifierWrapper,
|
||||
"DataColumnsByRootIdentifier"
|
||||
);
|
||||
type_name_generic!(DataColumnsByRootIdentifier, "DataColumnsByRootIdentifier");
|
||||
type_name_generic!(BlobSidecar);
|
||||
type_name_generic!(DataColumnSidecar);
|
||||
type_name!(Checkpoint);
|
||||
|
||||
Reference in New Issue
Block a user