mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-22 23:38:24 +00:00
Compare commits
12 Commits
epbs-devne
...
progressiv
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
827ff953bc | ||
|
|
e9d53ea5bc | ||
|
|
be9d697ad9 | ||
|
|
ecd207f421 | ||
|
|
e98b6db3f6 | ||
|
|
9aad3c6004 | ||
|
|
6b5d87869b | ||
|
|
30289cd750 | ||
|
|
fffd203cc5 | ||
|
|
9e15231ba2 | ||
|
|
d7ebdeb450 | ||
|
|
86f8c2e642 |
16
Cargo.lock
generated
16
Cargo.lock
generated
@@ -2842,6 +2842,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",
|
||||||
@@ -3275,8 +3276,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ethereum_ssz"
|
name = "ethereum_ssz"
|
||||||
version = "0.10.1"
|
version = "0.10.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/sigp/ethereum_ssz?branch=progressive#8619b2daa809366631c59f6317748677eb77848e"
|
||||||
checksum = "2128a84f7a3850d54ee343334e3392cca61f9f6aa9441eec481b9394b43c238b"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"arbitrary",
|
"arbitrary",
|
||||||
@@ -3292,8 +3292,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ethereum_ssz_derive"
|
name = "ethereum_ssz_derive"
|
||||||
version = "0.10.1"
|
version = "0.10.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/sigp/ethereum_ssz?branch=progressive#8619b2daa809366631c59f6317748677eb77848e"
|
||||||
checksum = "cd596f91cff004fc8d02be44c21c0f9b93140a04b66027ae052f5f8e05b48eba"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling 0.23.0",
|
"darling 0.23.0",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -5750,8 +5749,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "milhouse"
|
name = "milhouse"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/sigp/milhouse?branch=progressive-list#e406637155747f9de5fddc04cf83232f1ccdf0a9"
|
||||||
checksum = "259dd9da2ae5e0278b95da0b7ecef9c18c309d0a2d9e6db57ed33b9e8910c5e7"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"arbitrary",
|
"arbitrary",
|
||||||
@@ -9251,8 +9249,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "tree_hash"
|
name = "tree_hash"
|
||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/sigp/tree_hash?branch=progressive#ca07459738c9b1584eec99e37f3a52774fa97dd0"
|
||||||
checksum = "f7fd51aa83d2eb83b04570808430808b5d24fdbf479a4d5ac5dee4a2e2dd2be4"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"ethereum_hashing",
|
"ethereum_hashing",
|
||||||
@@ -9264,8 +9261,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "tree_hash_derive"
|
name = "tree_hash_derive"
|
||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/sigp/tree_hash?branch=progressive#ca07459738c9b1584eec99e37f3a52774fa97dd0"
|
||||||
checksum = "8840ad4d852e325d3afa7fde8a50b2412f89dce47d7eb291c0cc7f87cd040f38"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling 0.23.0",
|
"darling 0.23.0",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
|
|||||||
@@ -302,3 +302,9 @@ debug = true
|
|||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
quick-protobuf = { git = "https://github.com/sigp/quick-protobuf.git", rev = "681f413312404ab6e51f0b46f39b0075c6f4ebfd" }
|
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" }
|
||||||
|
|||||||
@@ -495,7 +495,9 @@ async fn invalid_attestation_bad_aggregation_bitfield_len() {
|
|||||||
.next()
|
.next()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.aggregation_bits_base_mut()
|
.aggregation_bits_base_mut()
|
||||||
.unwrap() = Bitfield::with_capacity(spec.target_committee_size).unwrap();
|
.unwrap() =
|
||||||
|
Bitfield::<ssz::Variable<<MainnetEthSpec as EthSpec>::MaxValidatorsPerCommittee>>::with_capacity(spec.target_committee_size)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let mut ctxt = ConsensusContext::new(state.slot());
|
let mut ctxt = ConsensusContext::new(state.slot());
|
||||||
let result = process_operations::process_attestations(
|
let result = process_operations::process_attestations(
|
||||||
|
|||||||
@@ -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 }
|
||||||
|
|||||||
@@ -66,13 +66,6 @@ excluded_paths = [
|
|||||||
"tests/.*/gloas/ssz_static/ExecutionPayloadHeader/.*",
|
"tests/.*/gloas/ssz_static/ExecutionPayloadHeader/.*",
|
||||||
# ForkChoiceNode is internal to fork choice and probably doesn't need SSZ tests.
|
# ForkChoiceNode is internal to fork choice and probably doesn't need SSZ tests.
|
||||||
"tests/.*/gloas/ssz_static/ForkChoiceNode/.*",
|
"tests/.*/gloas/ssz_static/ForkChoiceNode/.*",
|
||||||
# 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/.*",
|
|
||||||
"tests/general/phase0/ssz_generic/compatible_unions/.*",
|
|
||||||
# Ignore full epoch tests for now (just test the sub-transitions).
|
# Ignore full epoch tests for now (just test the sub-transitions).
|
||||||
"tests/.*/.*/epoch_processing/.*/pre_epoch.ssz_snappy",
|
"tests/.*/.*/epoch_processing/.*/pre_epoch.ssz_snappy",
|
||||||
"tests/.*/.*/epoch_processing/.*/post_epoch.ssz_snappy",
|
"tests/.*/.*/epoch_processing/.*/post_epoch.ssz_snappy",
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ use crate::cases::common::{DecimalU128, DecimalU256, SszStaticType};
|
|||||||
use crate::cases::ssz_static::{check_serialization, check_tree_hash};
|
use crate::cases::ssz_static::{check_serialization, check_tree_hash};
|
||||||
use crate::decode::{context_yaml_decode_file, log_file_access, snappy_decode_file};
|
use crate::decode::{context_yaml_decode_file, log_file_access, snappy_decode_file};
|
||||||
use context_deserialize::{ContextDeserialize, context_deserialize};
|
use context_deserialize::{ContextDeserialize, context_deserialize};
|
||||||
use milhouse::Vector;
|
use milhouse::{List, ProgressiveList, Vector};
|
||||||
use serde::{Deserialize, Deserializer, de::Error as SerdeError};
|
use serde::{Deserialize, Deserializer, de::Error as SerdeError};
|
||||||
|
use serde_json::Value as JsonValue;
|
||||||
|
use ssz::ProgressiveBitList;
|
||||||
use ssz_derive::{Decode, Encode};
|
use ssz_derive::{Decode, Encode};
|
||||||
use ssz_types::{BitList, BitVector, FixedVector, VariableList};
|
use ssz_types::{BitList, BitVector, FixedVector, VariableList};
|
||||||
use tree_hash::TreeHash;
|
use tree_hash::TreeHash;
|
||||||
@@ -14,6 +16,46 @@ use tree_hash_derive::TreeHash;
|
|||||||
use typenum::*;
|
use typenum::*;
|
||||||
use types::ForkName;
|
use types::ForkName;
|
||||||
|
|
||||||
|
/// Helper struct for deserializing compatible unions from `{selector, data}` YAML format.
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct CompatibleUnionYaml {
|
||||||
|
selector: u8,
|
||||||
|
data: JsonValue,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Implements `Deserialize` for compatible union types to handle the EF test YAML format.
|
||||||
|
///
|
||||||
|
/// Deserialize into `CompatibleUnionYaml` which captures `selector` (`u8`) and
|
||||||
|
/// `data` (`JsonValue`).
|
||||||
|
/// Match on the selector to determine which variant to construct.
|
||||||
|
/// Deserialize the `data` field into the appropriate inner type.
|
||||||
|
macro_rules! impl_compatible_union_deserialize {
|
||||||
|
($type:ty, { $($selector:literal => $variant:ident($inner:ty)),+ $(,)? }) => {
|
||||||
|
impl<'de> Deserialize<'de> for $type {
|
||||||
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
|
where
|
||||||
|
D: Deserializer<'de>,
|
||||||
|
{
|
||||||
|
let yaml = CompatibleUnionYaml::deserialize(deserializer)?;
|
||||||
|
match yaml.selector {
|
||||||
|
$(
|
||||||
|
$selector => {
|
||||||
|
let inner: $inner = serde_json::from_value(yaml.data).map_err(D::Error::custom)?;
|
||||||
|
Ok(<$type>::$variant(inner))
|
||||||
|
}
|
||||||
|
)+
|
||||||
|
s => Err(D::Error::custom(format!(
|
||||||
|
"unknown selector {s} for {}", stringify!($type)
|
||||||
|
))),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
type U1280 = op!(U128 * U10);
|
||||||
|
type U1281 = op!(U1280 + U1);
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
#[context_deserialize(ForkName)]
|
#[context_deserialize(ForkName)]
|
||||||
struct Metadata {
|
struct Metadata {
|
||||||
@@ -113,8 +155,15 @@ 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
|
"ProgressiveBitsStruct" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* ProgressiveBitsStruct>, $($rest)*),
|
||||||
"ProgressiveTestStruct" | "ProgressiveBitsStruct" => Err(Error::SkippedKnownFailure),
|
"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)*),
|
||||||
|
"CompatibleUnionA" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* CompatibleUnionA>, $($rest)*),
|
||||||
|
"CompatibleUnionBC" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* CompatibleUnionBC>, $($rest)*),
|
||||||
|
"CompatibleUnionABCA" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* CompatibleUnionABCA>, $($rest)*),
|
||||||
_ => Err(Error::FailedToParseTest(format!("unsupported: {}", $value))),
|
_ => Err(Error::FailedToParseTest(format!("unsupported: {}", $value))),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -159,6 +208,17 @@ impl Case for SszGeneric {
|
|||||||
[length => typenum]
|
[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" => {
|
"bitlist" => {
|
||||||
let mut limit = parts[1];
|
let mut limit = parts[1];
|
||||||
|
|
||||||
@@ -186,6 +246,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)?;
|
||||||
}
|
}
|
||||||
@@ -211,6 +279,28 @@ impl Case for SszGeneric {
|
|||||||
[type_name => test_container]
|
[type_name => test_container]
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
"progressive_containers" => {
|
||||||
|
let type_name = parts[0];
|
||||||
|
|
||||||
|
type_dispatch!(
|
||||||
|
ssz_generic_test,
|
||||||
|
(&self.path, fork_name),
|
||||||
|
_,
|
||||||
|
<>,
|
||||||
|
[type_name => test_container]
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
"compatible_unions" => {
|
||||||
|
let type_name = parts[0];
|
||||||
|
|
||||||
|
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(())
|
||||||
@@ -302,6 +392,15 @@ struct ComplexTestStruct {
|
|||||||
G: Vector<VarTestStruct, U2>,
|
G: Vector<VarTestStruct, U2>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Decode, Encode, TreeHash, Deserialize)]
|
||||||
|
#[context_deserialize(ForkName)]
|
||||||
|
struct ProgressiveTestStruct {
|
||||||
|
A: ProgressiveList<u8>,
|
||||||
|
B: ProgressiveList<u64>,
|
||||||
|
C: ProgressiveList<SmallTestStruct>,
|
||||||
|
D: ProgressiveList<ProgressiveList<VarTestStruct>>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Decode, Encode, TreeHash, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Decode, Encode, TreeHash, Deserialize)]
|
||||||
#[context_deserialize(ForkName)]
|
#[context_deserialize(ForkName)]
|
||||||
struct BitsStruct {
|
struct BitsStruct {
|
||||||
@@ -312,6 +411,120 @@ struct BitsStruct {
|
|||||||
E: BitVector<U8>,
|
E: BitVector<U8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Decode, Encode, TreeHash, Deserialize)]
|
||||||
|
#[context_deserialize(ForkName)]
|
||||||
|
struct ProgressiveBitsStruct {
|
||||||
|
A: BitVector<U256>,
|
||||||
|
B: BitList<U256>,
|
||||||
|
C: ProgressiveBitList,
|
||||||
|
D: BitVector<U257>,
|
||||||
|
E: BitList<U257>,
|
||||||
|
F: ProgressiveBitList,
|
||||||
|
G: BitVector<U1280>,
|
||||||
|
H: BitList<U1280>,
|
||||||
|
I: ProgressiveBitList,
|
||||||
|
J: BitVector<U1281>,
|
||||||
|
K: BitList<U1281>,
|
||||||
|
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<u16, U123>,
|
||||||
|
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<u16, U123>,
|
||||||
|
C: ProgressiveBitList,
|
||||||
|
D: ProgressiveList<u64>,
|
||||||
|
E: ProgressiveList<SmallTestStruct>,
|
||||||
|
F: ProgressiveList<ProgressiveList<VarTestStruct>>,
|
||||||
|
G: List<ProgressiveSingleFieldContainerTestStruct, U10>,
|
||||||
|
H: ProgressiveList<ProgressiveVarTestStruct>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Decode, Encode, TreeHash)]
|
||||||
|
#[ssz(enum_behaviour = "compatible_union")]
|
||||||
|
#[tree_hash(enum_behaviour = "compatible_union")]
|
||||||
|
#[context_deserialize(ForkName)]
|
||||||
|
enum CompatibleUnionA {
|
||||||
|
#[ssz(selector = "1")]
|
||||||
|
ProgressiveSingleFieldContainerTestStruct(ProgressiveSingleFieldContainerTestStruct),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_compatible_union_deserialize!(CompatibleUnionA, {
|
||||||
|
1 => ProgressiveSingleFieldContainerTestStruct(ProgressiveSingleFieldContainerTestStruct),
|
||||||
|
});
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Decode, Encode, TreeHash)]
|
||||||
|
#[ssz(enum_behaviour = "compatible_union")]
|
||||||
|
#[tree_hash(enum_behaviour = "compatible_union")]
|
||||||
|
#[context_deserialize(ForkName)]
|
||||||
|
enum CompatibleUnionBC {
|
||||||
|
#[ssz(selector = "2")]
|
||||||
|
ProgressiveSingleListContainerTestStruct(ProgressiveSingleListContainerTestStruct),
|
||||||
|
#[ssz(selector = "3")]
|
||||||
|
ProgressiveVarTestStruct(ProgressiveVarTestStruct),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_compatible_union_deserialize!(CompatibleUnionBC, {
|
||||||
|
2 => ProgressiveSingleListContainerTestStruct(ProgressiveSingleListContainerTestStruct),
|
||||||
|
3 => ProgressiveVarTestStruct(ProgressiveVarTestStruct),
|
||||||
|
});
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Decode, Encode, TreeHash)]
|
||||||
|
#[ssz(enum_behaviour = "compatible_union")]
|
||||||
|
#[tree_hash(enum_behaviour = "compatible_union")]
|
||||||
|
#[context_deserialize(ForkName)]
|
||||||
|
enum CompatibleUnionABCA {
|
||||||
|
#[ssz(selector = "1")]
|
||||||
|
A1(ProgressiveSingleFieldContainerTestStruct),
|
||||||
|
#[ssz(selector = "2")]
|
||||||
|
B1(ProgressiveSingleListContainerTestStruct),
|
||||||
|
#[ssz(selector = "3")]
|
||||||
|
C1(ProgressiveVarTestStruct),
|
||||||
|
#[ssz(selector = "4")]
|
||||||
|
A2(ProgressiveSingleFieldContainerTestStruct),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl_compatible_union_deserialize!(CompatibleUnionABCA, {
|
||||||
|
1 => A1(ProgressiveSingleFieldContainerTestStruct),
|
||||||
|
2 => B1(ProgressiveSingleListContainerTestStruct),
|
||||||
|
3 => C1(ProgressiveVarTestStruct),
|
||||||
|
4 => A2(ProgressiveSingleFieldContainerTestStruct),
|
||||||
|
});
|
||||||
|
|
||||||
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>
|
||||||
|
|||||||
@@ -1182,13 +1182,21 @@ impl<H: TypeName> Handler for SszGenericHandler<H> {
|
|||||||
// Supported SSZ generic handlers
|
// Supported SSZ generic handlers
|
||||||
pub struct BasicVector;
|
pub struct BasicVector;
|
||||||
type_name!(BasicVector, "basic_vector");
|
type_name!(BasicVector, "basic_vector");
|
||||||
|
pub struct BasicProgressiveList;
|
||||||
|
type_name!(BasicProgressiveList, "basic_progressive_list");
|
||||||
pub struct Bitlist;
|
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");
|
||||||
|
pub struct CompatibleUnions;
|
||||||
|
type_name!(CompatibleUnions, "compatible_unions");
|
||||||
|
|||||||
@@ -851,6 +851,14 @@ fn ssz_generic() {
|
|||||||
SszGenericHandler::<Containers>::default().run();
|
SszGenericHandler::<Containers>::default().run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ssz_generic_progressive() {
|
||||||
|
SszGenericHandler::<BasicProgressiveList>::default().run();
|
||||||
|
SszGenericHandler::<ProgressiveBitlist>::default().run();
|
||||||
|
SszGenericHandler::<ProgressiveContainers>::default().run();
|
||||||
|
SszGenericHandler::<CompatibleUnions>::default().run();
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn epoch_processing_justification_and_finalization() {
|
fn epoch_processing_justification_and_finalization() {
|
||||||
EpochProcessingHandler::<MinimalEthSpec, JustificationAndFinalization>::default().run();
|
EpochProcessingHandler::<MinimalEthSpec, JustificationAndFinalization>::default().run();
|
||||||
|
|||||||
Reference in New Issue
Block a user