diff --git a/Cargo.lock b/Cargo.lock index 481808b41f7..0ea1bdb0119 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2856,6 +2856,7 @@ dependencies = [ "context_deserialize", "educe", "eth2_network_config", + "ethereum_hashing", "ethereum_ssz", "ethereum_ssz_derive", "execution_layer", @@ -3283,8 +3284,7 @@ dependencies = [ [[package]] name = "ethereum_ssz" version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8cd8c4f47dfb947dbfe3cdf2945ae1da808dbedc592668658e827a12659ba1" +source = "git+https://github.com/sigp/ethereum_ssz?branch=progressive#952eb175cf463ec92d3abaf232e42fb72af7314e" dependencies = [ "alloy-primitives", "arbitrary", @@ -3300,8 +3300,7 @@ dependencies = [ [[package]] name = "ethereum_ssz_derive" version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78d247bc40823c365a62e572441a8f8b12df03f171713f06bc76180fcd56ab71" +source = "git+https://github.com/sigp/ethereum_ssz?branch=progressive#952eb175cf463ec92d3abaf232e42fb72af7314e" dependencies = [ "darling 0.20.11", "proc-macro2", @@ -5860,8 +5859,7 @@ dependencies = [ [[package]] name = "milhouse" version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "259dd9da2ae5e0278b95da0b7ecef9c18c309d0a2d9e6db57ed33b9e8910c5e7" +source = "git+https://github.com/sigp/milhouse?branch=progressive-list#556e7bb1f18af5c0ffeccc4ecaa9cd52ebb9003c" dependencies = [ "alloy-primitives", "arbitrary", @@ -9447,8 +9445,7 @@ dependencies = [ [[package]] name = "tree_hash" version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2db21caa355767db4fd6129876e5ae278a8699f4a6959b1e3e7aff610b532d52" +source = "git+https://github.com/sigp/tree_hash?branch=progressive#7400510546840a3985474380d934d33f9ba0d417" dependencies = [ "alloy-primitives", "ethereum_hashing", @@ -9460,8 +9457,7 @@ dependencies = [ [[package]] name = "tree_hash_derive" version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711cc655fcbb48384a87dc2bf641b991a15c5ad9afc3caa0b1ab1df3b436f70f" +source = "git+https://github.com/sigp/tree_hash?branch=progressive#7400510546840a3985474380d934d33f9ba0d417" dependencies = [ "darling 0.21.3", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 21cf551c48d..2b988524cd1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -285,3 +285,9 @@ debug = true [patch.crates-io] quick-protobuf = { git = "https://github.com/sigp/quick-protobuf.git", rev = "681f413312404ab6e51f0b46f39b0075c6f4ebfd" } +# FIXME(sproul): REMOVE patch +milhouse = { git = "https://github.com/sigp/milhouse", branch = "progressive-list" } +ethereum_ssz = { git = "https://github.com/sigp/ethereum_ssz", branch = "progressive" } +ethereum_ssz_derive = { git = "https://github.com/sigp/ethereum_ssz", branch = "progressive" } +tree_hash = { git = "https://github.com/sigp/tree_hash", branch = "progressive" } +tree_hash_derive = { git = "https://github.com/sigp/tree_hash", branch = "progressive" } diff --git a/consensus/types/src/lib.rs b/consensus/types/src/lib.rs index a8a78f8cfbf..2663eda38fb 100644 --- a/consensus/types/src/lib.rs +++ b/consensus/types/src/lib.rs @@ -173,6 +173,7 @@ pub use bls::{ }; pub use context_deserialize::{ContextDeserialize, context_deserialize}; pub use fixed_bytes::FixedBytesExtended; -pub use milhouse::{self, List, Vector}; +pub use milhouse::{self, List, ProgressiveList, Vector}; +pub use ssz::ProgressiveBitList; pub use ssz_types::{BitList, BitVector, FixedVector, VariableList, typenum, typenum::Unsigned}; pub use superstruct::superstruct; diff --git a/testing/ef_tests/Cargo.toml b/testing/ef_tests/Cargo.toml index 581785e2a97..17ad777699a 100644 --- a/testing/ef_tests/Cargo.toml +++ b/testing/ef_tests/Cargo.toml @@ -19,6 +19,7 @@ compare_fields = { workspace = true } context_deserialize = { workspace = true } educe = { workspace = true } eth2_network_config = { workspace = true } +ethereum_hashing = { workspace = true } # FIXME(sproul): remove ethereum_ssz = { workspace = true } ethereum_ssz_derive = { workspace = true } execution_layer = { workspace = true } diff --git a/testing/ef_tests/Makefile b/testing/ef_tests/Makefile index 0ead9d00472..724990cbecc 100644 --- a/testing/ef_tests/Makefile +++ b/testing/ef_tests/Makefile @@ -1,6 +1,6 @@ # To download/extract nightly tests, run: # CONSENSUS_SPECS_TEST_VERSION=nightly make -CONSENSUS_SPECS_TEST_VERSION ?= v1.6.0-beta.1 +CONSENSUS_SPECS_TEST_VERSION ?= v1.6.1 REPO_NAME := consensus-spec-tests OUTPUT_DIR := ./$(REPO_NAME) diff --git a/testing/ef_tests/check_all_files_accessed.py b/testing/ef_tests/check_all_files_accessed.py index 1f70881a887..4f278916db0 100755 --- a/testing/ef_tests/check_all_files_accessed.py +++ b/testing/ef_tests/check_all_files_accessed.py @@ -51,7 +51,6 @@ "tests/.*/fulu/ssz_static/MatrixEntry/.*", # EIP-7916 is still in draft and hasn't been implemented yet https://eips.ethereum.org/EIPS/eip-7916 "tests/general/phase0/ssz_generic/progressive_bitlist", - "tests/general/phase0/ssz_generic/basic_progressive_list", "tests/general/phase0/ssz_generic/containers/.*/ProgressiveBitsStruct.*", "tests/general/phase0/ssz_generic/containers/.*/ProgressiveTestStruct.*", "tests/general/phase0/ssz_generic/progressive_containers/.*", diff --git a/testing/ef_tests/src/cases/ssz_generic.rs b/testing/ef_tests/src/cases/ssz_generic.rs index 8742f8a1409..ca42ac1d1d4 100644 --- a/testing/ef_tests/src/cases/ssz_generic.rs +++ b/testing/ef_tests/src/cases/ssz_generic.rs @@ -10,7 +10,13 @@ use ssz_derive::{Decode, Encode}; use tree_hash::TreeHash; use tree_hash_derive::TreeHash; use types::typenum::*; -use types::{BitList, BitVector, FixedVector, ForkName, VariableList, Vector}; +use types::{ + 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)] @@ -111,8 +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)*), - // EIP-7916 is still in draft and hasn't been implemented yet https://eips.ethereum.org/EIPS/eip-7916 - "ProgressiveTestStruct" | "ProgressiveBitsStruct" => Err(Error::SkippedKnownFailure), + "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))), } }; @@ -157,6 +167,17 @@ impl Case for SszGeneric { [length => typenum] )?; } + "basic_progressive_list" => { + let elem_ty = parts[1]; + + type_dispatch!( + ssz_generic_test, + (&self.path, fork_name), + ProgressiveList, + <>, + [elem_ty => primitive_type] + )?; + } "bitlist" => { let mut limit = parts[1]; @@ -184,6 +205,14 @@ impl Case for SszGeneric { [length => typenum] )?; } + "progressive_bitlist" => { + type_dispatch!( + ssz_generic_test, + (&self.path, fork_name), + ProgressiveBitList, + <>, + )?; + } "boolean" => { ssz_generic_test::(&self.path, fork_name)?; } @@ -209,6 +238,17 @@ impl Case for SszGeneric { [type_name => test_container] )?; } + "progressive_containers" => { + let type_name = parts[0]; + + type_dispatch!( + ssz_generic_test, + (&self.path, fork_name), + _, + <>, + [type_name => test_container] + )?; + } _ => panic!("unsupported handler: {}", self.handler_name), } Ok(()) @@ -300,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 { @@ -310,6 +359,69 @@ 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)] +struct ProgressiveSingleFieldContainerTestStruct { + A: u8, +} + +#[derive(Debug, Clone, PartialEq, Decode, Encode, TreeHash, Deserialize)] +#[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> diff --git a/testing/ef_tests/src/handler.rs b/testing/ef_tests/src/handler.rs index a5b2ffada37..15ff0c70e57 100644 --- a/testing/ef_tests/src/handler.rs +++ b/testing/ef_tests/src/handler.rs @@ -1135,13 +1135,19 @@ impl Handler for SszGenericHandler { // Supported SSZ generic handlers pub struct BasicVector; type_name!(BasicVector, "basic_vector"); +pub struct BasicProgressiveList; +type_name!(BasicProgressiveList, "basic_progressive_list"); pub struct Bitlist; type_name!(Bitlist, "bitlist"); pub struct Bitvector; type_name!(Bitvector, "bitvector"); +pub struct ProgressiveBitlist; +type_name!(ProgressiveBitlist, "progressive_bitlist"); pub struct Boolean; type_name!(Boolean, "boolean"); pub struct Uints; type_name!(Uints, "uints"); pub struct Containers; type_name!(Containers, "containers"); +pub struct ProgressiveContainers; +type_name!(ProgressiveContainers, "progressive_containers"); diff --git a/testing/ef_tests/tests/tests.rs b/testing/ef_tests/tests/tests.rs index 089e4464cd7..4504e366dbb 100644 --- a/testing/ef_tests/tests/tests.rs +++ b/testing/ef_tests/tests/tests.rs @@ -733,6 +733,13 @@ fn ssz_generic() { SszGenericHandler::::default().run(); } +#[test] +fn ssz_generic_progressive() { + SszGenericHandler::::default().run(); + SszGenericHandler::::default().run(); + SszGenericHandler::::default().run(); +} + #[test] fn epoch_processing_justification_and_finalization() { EpochProcessingHandler::::default().run();