From fffd203cc5156cda0bba4a27100d894ed93c7ccd Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Thu, 18 Dec 2025 21:50:02 +1100 Subject: [PATCH] Rest of the progressive container tests --- Cargo.lock | 1 - Cargo.toml | 3 +- testing/ef_tests/src/cases/ssz_generic.rs | 76 ++++++++++++++++++++--- 3 files changed, 69 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a5bf115961..1e9e774f6c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5857,7 +5857,6 @@ dependencies = [ [[package]] name = "milhouse" version = "0.9.0" -source = "git+https://github.com/sigp/milhouse?branch=progressive-list#52bae1f50da93519cfb4ec31f7dab19659be4d14" dependencies = [ "alloy-primitives", "arbitrary", diff --git a/Cargo.toml b/Cargo.toml index 157ef55602..37d07d467f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -286,8 +286,7 @@ debug = true [patch.crates-io] quick-protobuf = { git = "https://github.com/sigp/quick-protobuf.git", rev = "681f413312404ab6e51f0b46f39b0075c6f4ebfd" } # FIXME(sproul): REMOVE patch -# milhouse = { path = "../milhouse" } -milhouse = { git = "https://github.com/sigp/milhouse", branch = "progressive-list" } +milhouse = { path = "../milhouse" } ethereum_ssz = { path = "../packages/ethereum_ssz/ssz" } ethereum_ssz_derive = { path = "../packages/ethereum_ssz/ssz_derive" } tree_hash = { path = "../packages/tree_hash/tree_hash" } diff --git a/testing/ef_tests/src/cases/ssz_generic.rs b/testing/ef_tests/src/cases/ssz_generic.rs index c632439bc7..ca42ac1d1d 100644 --- a/testing/ef_tests/src/cases/ssz_generic.rs +++ b/testing/ef_tests/src/cases/ssz_generic.rs @@ -8,14 +8,16 @@ use context_deserialize::{ContextDeserialize, context_deserialize}; use serde::{Deserialize, Deserializer, de::Error as SerdeError}; use ssz_derive::{Decode, Encode}; use tree_hash::TreeHash; -use tree_hash::{PackedEncoding, ProgressiveMerkleHasher, TreeHashType}; use tree_hash_derive::TreeHash; use types::typenum::*; use types::{ - BitList, BitVector, FixedVector, ForkName, Hash256, ProgressiveBitList, ProgressiveList, + BitList, BitVector, FixedVector, ForkName, List, ProgressiveBitList, ProgressiveList, VariableList, Vector, }; +type U1280 = op!(U128 * U10); +type U1281 = op!(U1280 + U1); + #[derive(Debug, Clone, Deserialize)] #[context_deserialize(ForkName)] struct Metadata { @@ -115,7 +117,12 @@ 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)*), + "ProgressiveBitsStruct" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* ProgressiveBitsStruct>, $($rest)*), "ProgressiveSingleFieldContainerTestStruct" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* ProgressiveSingleFieldContainerTestStruct>, $($rest)*), + "ProgressiveSingleListContainerTestStruct" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* ProgressiveSingleListContainerTestStruct>, $($rest)*), + "ProgressiveVarTestStruct" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* ProgressiveVarTestStruct>, $($rest)*), + "ProgressiveComplexTestStruct" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* ProgressiveComplexTestStruct>, $($rest)*), + "ProgressiveTestStruct" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* ProgressiveTestStruct>, $($rest)*), _ => Err(Error::FailedToParseTest(format!("unsupported: {}", $value))), } }; @@ -234,11 +241,6 @@ impl Case for SszGeneric { "progressive_containers" => { let type_name = parts[0]; - // FIXME(sproul): delete - if type_name != "ProgressiveSingleFieldContainerTestStruct" { - return Ok(()); - } - type_dispatch!( ssz_generic_test, (&self.path, fork_name), @@ -338,6 +340,15 @@ struct ComplexTestStruct { G: Vector, } +#[derive(Debug, Clone, PartialEq, Decode, Encode, TreeHash, Deserialize)] +#[context_deserialize(ForkName)] +struct ProgressiveTestStruct { + A: ProgressiveList, + B: ProgressiveList, + C: ProgressiveList, + D: ProgressiveList>, +} + #[derive(Debug, Clone, PartialEq, Decode, Encode, TreeHash, Deserialize)] #[context_deserialize(ForkName)] struct BitsStruct { @@ -348,6 +359,23 @@ struct BitsStruct { E: BitVector, } +#[derive(Debug, Clone, PartialEq, Decode, Encode, TreeHash, Deserialize)] +#[context_deserialize(ForkName)] +struct ProgressiveBitsStruct { + A: BitVector, + B: BitList, + C: ProgressiveBitList, + D: BitVector, + E: BitList, + F: ProgressiveBitList, + G: BitVector, + H: BitList, + I: ProgressiveBitList, + J: BitVector, + K: BitList, + L: ProgressiveBitList, +} + #[derive(Debug, Clone, PartialEq, Decode, Encode, TreeHash, Deserialize)] #[tree_hash(struct_behaviour = "progressive_container", active_fields(1))] #[context_deserialize(ForkName)] @@ -356,12 +384,44 @@ struct ProgressiveSingleFieldContainerTestStruct { } #[derive(Debug, Clone, PartialEq, Decode, Encode, TreeHash, Deserialize)] -#[tree_hash(struct_behaviour = "progressive_container", active_fields(1))] +#[tree_hash( + struct_behaviour = "progressive_container", + active_fields(0, 0, 0, 0, 1) +)] #[context_deserialize(ForkName)] struct ProgressiveSingleListContainerTestStruct { C: ProgressiveBitList, } +#[derive(Debug, Clone, PartialEq, Decode, Encode, TreeHash, Deserialize)] +#[tree_hash( + struct_behaviour = "progressive_container", + active_fields(1, 0, 1, 0, 1) +)] +#[context_deserialize(ForkName)] +struct ProgressiveVarTestStruct { + A: u8, + B: List, + C: ProgressiveBitList, +} + +#[derive(Debug, Clone, PartialEq, Decode, Encode, TreeHash, Deserialize)] +#[tree_hash( + struct_behaviour = "progressive_container", + active_fields(1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1) +)] +#[context_deserialize(ForkName)] +struct ProgressiveComplexTestStruct { + A: u8, + B: List, + C: ProgressiveBitList, + D: ProgressiveList, + E: ProgressiveList, + F: ProgressiveList>, + G: List, + H: ProgressiveList, +} + fn byte_list_from_hex_str<'de, D, N: Unsigned>( deserializer: D, ) -> Result, D::Error>