mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-17 11:52:42 +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:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user