mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
Test runners for basic progressive containers and bitlists
This commit is contained in:
25
Cargo.lock
generated
25
Cargo.lock
generated
@@ -698,7 +698,7 @@ version = "1.1.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
|
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.60.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -709,7 +709,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"once_cell_polyfill",
|
"once_cell_polyfill",
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.60.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2856,6 +2856,7 @@ dependencies = [
|
|||||||
"context_deserialize",
|
"context_deserialize",
|
||||||
"educe",
|
"educe",
|
||||||
"eth2_network_config",
|
"eth2_network_config",
|
||||||
|
"ethereum_hashing",
|
||||||
"ethereum_ssz",
|
"ethereum_ssz",
|
||||||
"ethereum_ssz_derive",
|
"ethereum_ssz_derive",
|
||||||
"execution_layer",
|
"execution_layer",
|
||||||
@@ -3118,7 +3119,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3283,8 +3284,6 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ethereum_ssz"
|
name = "ethereum_ssz"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7e8cd8c4f47dfb947dbfe3cdf2945ae1da808dbedc592668658e827a12659ba1"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"arbitrary",
|
"arbitrary",
|
||||||
@@ -3300,8 +3299,6 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ethereum_ssz_derive"
|
name = "ethereum_ssz_derive"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "78d247bc40823c365a62e572441a8f8b12df03f171713f06bc76180fcd56ab71"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling 0.20.11",
|
"darling 0.20.11",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -4759,7 +4756,7 @@ checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"hermit-abi 0.5.2",
|
"hermit-abi 0.5.2",
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -6344,7 +6341,7 @@ version = "0.50.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
|
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -7786,7 +7783,7 @@ dependencies = [
|
|||||||
"errno",
|
"errno",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys 0.11.0",
|
"linux-raw-sys 0.11.0",
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -8873,7 +8870,7 @@ dependencies = [
|
|||||||
"getrandom 0.3.4",
|
"getrandom 0.3.4",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustix 1.1.2",
|
"rustix 1.1.2",
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -9446,8 +9443,6 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "tree_hash"
|
name = "tree_hash"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2db21caa355767db4fd6129876e5ae278a8699f4a6959b1e3e7aff610b532d52"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"ethereum_hashing",
|
"ethereum_hashing",
|
||||||
@@ -9459,8 +9454,6 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "tree_hash_derive"
|
name = "tree_hash_derive"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "711cc655fcbb48384a87dc2bf641b991a15c5ad9afc3caa0b1ab1df3b436f70f"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling 0.21.3",
|
"darling 0.21.3",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -10209,7 +10202,7 @@ version = "0.1.11"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -288,3 +288,7 @@ quick-protobuf = { git = "https://github.com/sigp/quick-protobuf.git", rev = "68
|
|||||||
# FIXME(sproul): REMOVE patch
|
# FIXME(sproul): REMOVE patch
|
||||||
# milhouse = { path = "../milhouse" }
|
# milhouse = { path = "../milhouse" }
|
||||||
milhouse = { git = "https://github.com/sigp/milhouse", branch = "progressive-list" }
|
milhouse = { git = "https://github.com/sigp/milhouse", branch = "progressive-list" }
|
||||||
|
ethereum_ssz = { path = "../packages/ethereum_ssz/ssz" }
|
||||||
|
ethereum_ssz_derive = { path = "../packages/ethereum_ssz/ssz_derive" }
|
||||||
|
tree_hash = { path = "../packages/tree_hash/tree_hash" }
|
||||||
|
tree_hash_derive = { path = "../packages/tree_hash/tree_hash_derive" }
|
||||||
|
|||||||
@@ -174,5 +174,6 @@ pub use bls::{
|
|||||||
pub use context_deserialize::{ContextDeserialize, context_deserialize};
|
pub use context_deserialize::{ContextDeserialize, context_deserialize};
|
||||||
pub use fixed_bytes::FixedBytesExtended;
|
pub use fixed_bytes::FixedBytesExtended;
|
||||||
pub use milhouse::{self, List, ProgressiveList, 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 ssz_types::{BitList, BitVector, FixedVector, VariableList, typenum, typenum::Unsigned};
|
||||||
pub use superstruct::superstruct;
|
pub use superstruct::superstruct;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ compare_fields = { workspace = true }
|
|||||||
context_deserialize = { workspace = true }
|
context_deserialize = { workspace = true }
|
||||||
educe = { workspace = true }
|
educe = { workspace = true }
|
||||||
eth2_network_config = { workspace = true }
|
eth2_network_config = { workspace = true }
|
||||||
|
ethereum_hashing = { workspace = true } # FIXME(sproul): remove
|
||||||
ethereum_ssz = { workspace = true }
|
ethereum_ssz = { workspace = true }
|
||||||
ethereum_ssz_derive = { workspace = true }
|
ethereum_ssz_derive = { workspace = true }
|
||||||
execution_layer = { workspace = true }
|
execution_layer = { workspace = true }
|
||||||
|
|||||||
@@ -8,9 +8,13 @@ use context_deserialize::{ContextDeserialize, context_deserialize};
|
|||||||
use serde::{Deserialize, Deserializer, de::Error as SerdeError};
|
use serde::{Deserialize, Deserializer, de::Error as SerdeError};
|
||||||
use ssz_derive::{Decode, Encode};
|
use ssz_derive::{Decode, Encode};
|
||||||
use tree_hash::TreeHash;
|
use tree_hash::TreeHash;
|
||||||
|
use tree_hash::{PackedEncoding, ProgressiveMerkleHasher, TreeHashType};
|
||||||
use tree_hash_derive::TreeHash;
|
use tree_hash_derive::TreeHash;
|
||||||
use types::typenum::*;
|
use types::typenum::*;
|
||||||
use types::{BitList, BitVector, FixedVector, ForkName, ProgressiveList, VariableList, Vector};
|
use types::{
|
||||||
|
BitList, BitVector, FixedVector, ForkName, Hash256, ProgressiveBitList, ProgressiveList,
|
||||||
|
VariableList, Vector,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
#[context_deserialize(ForkName)]
|
#[context_deserialize(ForkName)]
|
||||||
@@ -111,8 +115,7 @@ macro_rules! type_dispatch {
|
|||||||
"VarTestStruct" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* VarTestStruct>, $($rest)*),
|
"VarTestStruct" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* VarTestStruct>, $($rest)*),
|
||||||
"ComplexTestStruct" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* ComplexTestStruct>, $($rest)*),
|
"ComplexTestStruct" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* ComplexTestStruct>, $($rest)*),
|
||||||
"BitsStruct" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* BitsStruct>, $($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
|
"ProgressiveSingleFieldContainerTestStruct" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* ProgressiveSingleFieldContainerTestStruct>, $($rest)*),
|
||||||
"ProgressiveTestStruct" | "ProgressiveBitsStruct" => Err(Error::SkippedKnownFailure),
|
|
||||||
_ => Err(Error::FailedToParseTest(format!("unsupported: {}", $value))),
|
_ => Err(Error::FailedToParseTest(format!("unsupported: {}", $value))),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -195,6 +198,14 @@ impl Case for SszGeneric {
|
|||||||
[length => typenum]
|
[length => typenum]
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
"progressive_bitlist" => {
|
||||||
|
type_dispatch!(
|
||||||
|
ssz_generic_test,
|
||||||
|
(&self.path, fork_name),
|
||||||
|
ProgressiveBitList,
|
||||||
|
<>,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
"boolean" => {
|
"boolean" => {
|
||||||
ssz_generic_test::<bool>(&self.path, fork_name)?;
|
ssz_generic_test::<bool>(&self.path, fork_name)?;
|
||||||
}
|
}
|
||||||
@@ -220,6 +231,22 @@ impl Case for SszGeneric {
|
|||||||
[type_name => test_container]
|
[type_name => test_container]
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
"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),
|
||||||
|
_,
|
||||||
|
<>,
|
||||||
|
[type_name => test_container]
|
||||||
|
)?;
|
||||||
|
}
|
||||||
_ => panic!("unsupported handler: {}", self.handler_name),
|
_ => panic!("unsupported handler: {}", self.handler_name),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -321,6 +348,20 @@ struct BitsStruct {
|
|||||||
E: BitVector<U8>,
|
E: BitVector<U8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[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(1))]
|
||||||
|
#[context_deserialize(ForkName)]
|
||||||
|
struct ProgressiveSingleListContainerTestStruct {
|
||||||
|
C: ProgressiveBitList,
|
||||||
|
}
|
||||||
|
|
||||||
fn byte_list_from_hex_str<'de, D, N: Unsigned>(
|
fn byte_list_from_hex_str<'de, D, N: Unsigned>(
|
||||||
deserializer: D,
|
deserializer: D,
|
||||||
) -> Result<VariableList<u8, N>, D::Error>
|
) -> Result<VariableList<u8, N>, D::Error>
|
||||||
|
|||||||
@@ -1141,9 +1141,13 @@ pub struct Bitlist;
|
|||||||
type_name!(Bitlist, "bitlist");
|
type_name!(Bitlist, "bitlist");
|
||||||
pub struct Bitvector;
|
pub struct Bitvector;
|
||||||
type_name!(Bitvector, "bitvector");
|
type_name!(Bitvector, "bitvector");
|
||||||
|
pub struct ProgressiveBitlist;
|
||||||
|
type_name!(ProgressiveBitlist, "progressive_bitlist");
|
||||||
pub struct Boolean;
|
pub struct Boolean;
|
||||||
type_name!(Boolean, "boolean");
|
type_name!(Boolean, "boolean");
|
||||||
pub struct Uints;
|
pub struct Uints;
|
||||||
type_name!(Uints, "uints");
|
type_name!(Uints, "uints");
|
||||||
pub struct Containers;
|
pub struct Containers;
|
||||||
type_name!(Containers, "containers");
|
type_name!(Containers, "containers");
|
||||||
|
pub struct ProgressiveContainers;
|
||||||
|
type_name!(ProgressiveContainers, "progressive_containers");
|
||||||
|
|||||||
@@ -736,6 +736,8 @@ fn ssz_generic() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn ssz_generic_progressive() {
|
fn ssz_generic_progressive() {
|
||||||
SszGenericHandler::<BasicProgressiveList>::default().run();
|
SszGenericHandler::<BasicProgressiveList>::default().run();
|
||||||
|
SszGenericHandler::<ProgressiveBitlist>::default().run();
|
||||||
|
SszGenericHandler::<ProgressiveContainers>::default().run();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user