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:
Jimmy Chen
2025-08-20 12:05:04 +10:00
committed by GitHub
parent 95882bfa66
commit b4704eab4a
56 changed files with 214 additions and 400 deletions

View File

@@ -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) => {