Fix Arbitrary implementations (#3867)

* Fix Arbitrary implementations

* Remove remaining vestiges of arbitrary-fuzz

* Remove FIXME

* Clippy
This commit is contained in:
Michael Sproul 2023-01-12 15:17:03 +11:00 committed by GitHub
parent 52c1055fdc
commit 56e6b3557a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
71 changed files with 610 additions and 194 deletions

62
Cargo.lock generated
View File

@ -156,9 +156,8 @@ checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6"
[[package]] [[package]]
name = "arbitrary" name = "arbitrary"
version = "1.2.0" version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/michaelsproul/arbitrary?rev=a572fd8743012a4f1ada5ee5968b1b3619c427ba#a572fd8743012a4f1ada5ee5968b1b3619c427ba"
checksum = "29d47fbf90d5149a107494b15a7dc8d69b351be2db3bb9691740e88ec17fd880"
dependencies = [ dependencies = [
"derive_arbitrary", "derive_arbitrary",
] ]
@ -1231,8 +1230,18 @@ version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c"
dependencies = [ dependencies = [
"darling_core", "darling_core 0.13.4",
"darling_macro", "darling_macro 0.13.4",
]
[[package]]
name = "darling"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0dd3cd20dc6b5a876612a6e5accfe7f3dd883db6d07acfbf14c128f61550dfa"
dependencies = [
"darling_core 0.14.2",
"darling_macro 0.14.2",
] ]
[[package]] [[package]]
@ -1249,13 +1258,38 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "darling_core"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a784d2ccaf7c98501746bf0be29b2022ba41fd62a2e622af997a03e9f972859f"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim 0.10.0",
"syn",
]
[[package]] [[package]]
name = "darling_macro" name = "darling_macro"
version = "0.13.4" version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835"
dependencies = [ dependencies = [
"darling_core", "darling_core 0.13.4",
"quote",
"syn",
]
[[package]]
name = "darling_macro"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7618812407e9402654622dd402b0a89dff9ba93badd6540781526117b92aab7e"
dependencies = [
"darling_core 0.14.2",
"quote", "quote",
"syn", "syn",
] ]
@ -1357,10 +1391,10 @@ dependencies = [
[[package]] [[package]]
name = "derive_arbitrary" name = "derive_arbitrary"
version = "1.2.0" version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/michaelsproul/arbitrary?rev=a572fd8743012a4f1ada5ee5968b1b3619c427ba#a572fd8743012a4f1ada5ee5968b1b3619c427ba"
checksum = "4903dff04948f22033ca30232ab8eca2c3fc4c913a8b6a34ee5199699814817f"
dependencies = [ dependencies = [
"darling 0.14.2",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn",
@ -1856,7 +1890,7 @@ dependencies = [
name = "eth2_ssz_derive" name = "eth2_ssz_derive"
version = "0.3.1" version = "0.3.1"
dependencies = [ dependencies = [
"darling", "darling 0.13.4",
"eth2_ssz", "eth2_ssz",
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -5791,7 +5825,7 @@ version = "1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082"
dependencies = [ dependencies = [
"darling", "darling 0.13.4",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn",
@ -6353,7 +6387,7 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95a99807a055ff4ff5d249bb84c80d9eabb55ca3c452187daae43fd5b51ef695" checksum = "95a99807a055ff4ff5d249bb84c80d9eabb55ca3c452187daae43fd5b51ef695"
dependencies = [ dependencies = [
"darling", "darling 0.13.4",
"itertools", "itertools",
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -6367,7 +6401,7 @@ version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75b9e5728aa1a87141cefd4e7509903fc01fa0dcb108022b1e841a67c5159fc5" checksum = "75b9e5728aa1a87141cefd4e7509903fc01fa0dcb108022b1e841a67c5159fc5"
dependencies = [ dependencies = [
"darling", "darling 0.13.4",
"itertools", "itertools",
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -6991,7 +7025,7 @@ dependencies = [
name = "tree_hash_derive" name = "tree_hash_derive"
version = "0.4.0" version = "0.4.0"
dependencies = [ dependencies = [
"darling", "darling 0.13.4",
"quote", "quote",
"syn", "syn",
] ]

View File

@ -100,6 +100,7 @@ eth2_hashing = { path = "crypto/eth2_hashing" }
tree_hash = { path = "consensus/tree_hash" } tree_hash = { path = "consensus/tree_hash" }
tree_hash_derive = { path = "consensus/tree_hash_derive" } tree_hash_derive = { path = "consensus/tree_hash_derive" }
eth2_serde_utils = { path = "consensus/serde_utils" } eth2_serde_utils = { path = "consensus/serde_utils" }
arbitrary = { git = "https://github.com/michaelsproul/arbitrary", rev="a572fd8743012a4f1ada5ee5968b1b3619c427ba" }
[profile.maxperf] [profile.maxperf]
inherits = "release" inherits = "release"

View File

@ -660,7 +660,7 @@ impl<N: 'static + Unsigned> arbitrary::Arbitrary<'_> for Bitfield<Fixed<N>> {
let size = N::to_usize(); let size = N::to_usize();
let mut vec = smallvec![0u8; size]; let mut vec = smallvec![0u8; size];
u.fill_buffer(&mut vec)?; u.fill_buffer(&mut vec)?;
Ok(Self::from_bytes(vec).map_err(|_| arbitrary::Error::IncorrectFormat)?) Self::from_bytes(vec).map_err(|_| arbitrary::Error::IncorrectFormat)
} }
} }
@ -672,7 +672,7 @@ impl<N: 'static + Unsigned> arbitrary::Arbitrary<'_> for Bitfield<Variable<N>> {
let size = std::cmp::min(rand, max_size); let size = std::cmp::min(rand, max_size);
let mut vec = smallvec![0u8; size]; let mut vec = smallvec![0u8; size];
u.fill_buffer(&mut vec)?; u.fill_buffer(&mut vec)?;
Ok(Self::from_bytes(vec).map_err(|_| arbitrary::Error::IncorrectFormat)?) Self::from_bytes(vec).map_err(|_| arbitrary::Error::IncorrectFormat)
} }
} }

View File

@ -291,7 +291,7 @@ impl<'a, T: arbitrary::Arbitrary<'a>, N: 'static + Unsigned> arbitrary::Arbitrar
for _ in 0..size { for _ in 0..size {
vec.push(<T>::arbitrary(u)?); vec.push(<T>::arbitrary(u)?);
} }
Ok(Self::new(vec).map_err(|_| arbitrary::Error::IncorrectFormat)?) Self::new(vec).map_err(|_| arbitrary::Error::IncorrectFormat)
} }
} }

View File

@ -273,7 +273,7 @@ impl<'a, T: arbitrary::Arbitrary<'a>, N: 'static + Unsigned> arbitrary::Arbitrar
for _ in 0..size { for _ in 0..size {
vec.push(<T>::arbitrary(u)?); vec.push(<T>::arbitrary(u)?);
} }
Ok(Self::new(vec).map_err(|_| arbitrary::Error::IncorrectFormat)?) Self::new(vec).map_err(|_| arbitrary::Error::IncorrectFormat)
} }
} }

View File

@ -11,11 +11,11 @@ harness = false
[dependencies] [dependencies]
serde-big-array = {version = "0.3.2", features = ["const-generics"]} serde-big-array = {version = "0.3.2", features = ["const-generics"]}
merkle_proof = { path = "../../consensus/merkle_proof" } merkle_proof = { path = "../../consensus/merkle_proof" }
bls = { path = "../../crypto/bls" } bls = { path = "../../crypto/bls", features = ["arbitrary"] }
compare_fields = { path = "../../common/compare_fields" } compare_fields = { path = "../../common/compare_fields" }
compare_fields_derive = { path = "../../common/compare_fields_derive" } compare_fields_derive = { path = "../../common/compare_fields_derive" }
eth2_interop_keypairs = { path = "../../common/eth2_interop_keypairs" } eth2_interop_keypairs = { path = "../../common/eth2_interop_keypairs" }
ethereum-types = "0.12.1" ethereum-types = { version = "0.12.1", features = ["arbitrary"] }
eth2_hashing = "0.3.0" eth2_hashing = "0.3.0"
hex = "0.4.2" hex = "0.4.2"
int_to_bytes = { path = "../int_to_bytes" } int_to_bytes = { path = "../int_to_bytes" }
@ -26,12 +26,12 @@ safe_arith = { path = "../safe_arith" }
serde = {version = "1.0.116" , features = ["rc"] } serde = {version = "1.0.116" , features = ["rc"] }
serde_derive = "1.0.116" serde_derive = "1.0.116"
slog = "2.5.2" slog = "2.5.2"
eth2_ssz = "0.4.1" eth2_ssz = { version = "0.4.1", features = ["arbitrary"] }
eth2_ssz_derive = "0.3.1" eth2_ssz_derive = "0.3.1"
eth2_ssz_types = "0.2.2" eth2_ssz_types = { version = "0.2.2", features = ["arbitrary"] }
swap_or_not_shuffle = { path = "../swap_or_not_shuffle" } swap_or_not_shuffle = { path = "../swap_or_not_shuffle", features = ["arbitrary"] }
test_random_derive = { path = "../../common/test_random_derive" } test_random_derive = { path = "../../common/test_random_derive" }
tree_hash = "0.4.1" tree_hash = { version = "0.4.1", features = ["arbitrary"] }
tree_hash_derive = "0.4.0" tree_hash_derive = "0.4.0"
rand_xorshift = "0.3.0" rand_xorshift = "0.3.0"
cached_tree_hash = { path = "../cached_tree_hash" } cached_tree_hash = { path = "../cached_tree_hash" }
@ -39,7 +39,9 @@ serde_yaml = "0.8.13"
tempfile = "3.1.0" tempfile = "3.1.0"
derivative = "2.1.1" derivative = "2.1.1"
rusqlite = { version = "0.25.3", features = ["bundled"], optional = true } rusqlite = { version = "0.25.3", features = ["bundled"], optional = true }
arbitrary = { version = "1.0", features = ["derive"], optional = true } # The arbitrary dependency is enabled by default since Capella to avoid complexity introduced by
# `AbstractExecPayload`
arbitrary = { version = "1.0", features = ["derive"] }
eth2_serde_utils = "0.1.1" eth2_serde_utils = "0.1.1"
regex = "1.5.5" regex = "1.5.5"
lazy_static = "1.4.0" lazy_static = "1.4.0"
@ -63,12 +65,6 @@ default = ["sqlite", "legacy-arith"]
# Allow saturating arithmetic on slots and epochs. Enabled by default, but deprecated. # Allow saturating arithmetic on slots and epochs. Enabled by default, but deprecated.
legacy-arith = [] legacy-arith = []
sqlite = ["rusqlite"] sqlite = ["rusqlite"]
arbitrary-fuzz = [ # The `arbitrary-fuzz` feature is a no-op provided for backwards compatibility.
"arbitrary", # For simplicity `Arbitrary` is now derived regardless of the feature's presence.
"ethereum-types/arbitrary", arbitrary-fuzz = []
"bls/arbitrary",
"eth2_ssz/arbitrary",
"eth2_ssz_types/arbitrary",
"swap_or_not_shuffle/arbitrary",
"tree_hash/arbitrary",
]

View File

@ -11,9 +11,20 @@ use tree_hash_derive::TreeHash;
/// A Validators aggregate attestation and selection proof. /// A Validators aggregate attestation and selection proof.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TestRandom, TreeHash)] arbitrary::Arbitrary,
Debug,
Clone,
PartialEq,
Serialize,
Deserialize,
Encode,
Decode,
TestRandom,
TreeHash,
)]
#[serde(bound = "T: EthSpec")] #[serde(bound = "T: EthSpec")]
#[arbitrary(bound = "T: EthSpec")]
pub struct AggregateAndProof<T: EthSpec> { pub struct AggregateAndProof<T: EthSpec> {
/// The index of the validator that created the attestation. /// The index of the validator that created the attestation.
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "eth2_serde_utils::quoted_u64")]

View File

@ -23,12 +23,21 @@ pub enum Error {
/// Details an attestation that can be slashable. /// Details an attestation that can be slashable.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, Derivative, arbitrary::Arbitrary,
Debug,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
Derivative,
)] )]
#[derivative(PartialEq, Hash(bound = "T: EthSpec"))] #[derivative(PartialEq, Hash(bound = "T: EthSpec"))]
#[serde(bound = "T: EthSpec")] #[serde(bound = "T: EthSpec")]
#[arbitrary(bound = "T: EthSpec")]
pub struct Attestation<T: EthSpec> { pub struct Attestation<T: EthSpec> {
pub aggregation_bits: BitList<T::MaxValidatorsPerCommittee>, pub aggregation_bits: BitList<T::MaxValidatorsPerCommittee>,
pub data: AttestationData, pub data: AttestationData,

View File

@ -10,8 +10,8 @@ use tree_hash_derive::TreeHash;
/// The data upon which an attestation is based. /// The data upon which an attestation is based.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
arbitrary::Arbitrary,
Debug, Debug,
Clone, Clone,
PartialEq, PartialEq,

View File

@ -1,8 +1,7 @@
use crate::*; use crate::*;
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(arbitrary::Arbitrary, Debug, PartialEq, Clone, Copy, Default, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Clone, Copy, Default, Serialize, Deserialize)]
pub struct AttestationDuty { pub struct AttestationDuty {
/// The slot during which the attester must attest. /// The slot during which the attester must attest.
pub slot: Slot, pub slot: Slot,

View File

@ -9,12 +9,21 @@ use tree_hash_derive::TreeHash;
/// Two conflicting attestations. /// Two conflicting attestations.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
Derivative, Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, Derivative,
Debug,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
arbitrary::Arbitrary,
)] )]
#[derivative(PartialEq, Eq, Hash(bound = "T: EthSpec"))] #[derivative(PartialEq, Eq, Hash(bound = "T: EthSpec"))]
#[serde(bound = "T: EthSpec")] #[serde(bound = "T: EthSpec")]
#[arbitrary(bound = "T: EthSpec")]
pub struct AttesterSlashing<T: EthSpec> { pub struct AttesterSlashing<T: EthSpec> {
pub attestation_1: IndexedAttestation<T>, pub attestation_1: IndexedAttestation<T>,
pub attestation_2: IndexedAttestation<T>, pub attestation_2: IndexedAttestation<T>,

View File

@ -29,10 +29,14 @@ use tree_hash_derive::TreeHash;
TreeHash, TreeHash,
TestRandom, TestRandom,
Derivative, Derivative,
arbitrary::Arbitrary
), ),
derivative(PartialEq, Hash(bound = "T: EthSpec, Payload: ExecPayload<T>")), derivative(PartialEq, Hash(bound = "T: EthSpec, Payload: AbstractExecPayload<T>")),
serde(bound = "T: EthSpec, Payload: ExecPayload<T>", deny_unknown_fields), serde(
cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary)), bound = "T: EthSpec, Payload: AbstractExecPayload<T>",
deny_unknown_fields
),
arbitrary(bound = "T: EthSpec, Payload: AbstractExecPayload<T>"),
), ),
ref_attributes( ref_attributes(
derive(Debug, PartialEq, TreeHash), derive(Debug, PartialEq, TreeHash),
@ -41,11 +45,13 @@ use tree_hash_derive::TreeHash;
map_ref_into(BeaconBlockBodyRef, BeaconBlock), map_ref_into(BeaconBlockBodyRef, BeaconBlock),
map_ref_mut_into(BeaconBlockBodyRefMut) map_ref_mut_into(BeaconBlockBodyRefMut)
)] )]
#[derive(Debug, Clone, Serialize, Deserialize, Encode, TreeHash, Derivative)] #[derive(
Debug, Clone, Serialize, Deserialize, Encode, TreeHash, Derivative, arbitrary::Arbitrary,
)]
#[derivative(PartialEq, Hash(bound = "T: EthSpec"))] #[derivative(PartialEq, Hash(bound = "T: EthSpec"))]
#[serde(untagged)] #[serde(untagged)]
#[serde(bound = "T: EthSpec, Payload: ExecPayload<T>")] #[serde(bound = "T: EthSpec, Payload: AbstractExecPayload<T>")]
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[arbitrary(bound = "T: EthSpec, Payload: AbstractExecPayload<T>")]
#[tree_hash(enum_behaviour = "transparent")] #[tree_hash(enum_behaviour = "transparent")]
#[ssz(enum_behaviour = "transparent")] #[ssz(enum_behaviour = "transparent")]
pub struct BeaconBlock<T: EthSpec, Payload: AbstractExecPayload<T> = FullPayload<T>> { pub struct BeaconBlock<T: EthSpec, Payload: AbstractExecPayload<T> = FullPayload<T>> {

View File

@ -26,19 +26,23 @@ use tree_hash_derive::TreeHash;
TreeHash, TreeHash,
TestRandom, TestRandom,
Derivative, Derivative,
arbitrary::Arbitrary
), ),
derivative(PartialEq, Hash(bound = "T: EthSpec, Payload: ExecPayload<T>")), derivative(PartialEq, Hash(bound = "T: EthSpec, Payload: AbstractExecPayload<T>")),
serde(bound = "T: EthSpec, Payload: ExecPayload<T>", deny_unknown_fields), serde(
cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary)) bound = "T: EthSpec, Payload: AbstractExecPayload<T>",
deny_unknown_fields
),
arbitrary(bound = "T: EthSpec, Payload: AbstractExecPayload<T>"),
), ),
cast_error(ty = "Error", expr = "Error::IncorrectStateVariant"), cast_error(ty = "Error", expr = "Error::IncorrectStateVariant"),
partial_getter_error(ty = "Error", expr = "Error::IncorrectStateVariant") partial_getter_error(ty = "Error", expr = "Error::IncorrectStateVariant")
)] )]
#[derive(Debug, Clone, Serialize, Deserialize, Derivative)] #[derive(Debug, Clone, Serialize, Deserialize, Derivative, arbitrary::Arbitrary)]
#[derivative(PartialEq, Hash(bound = "T: EthSpec"))] #[derivative(PartialEq, Hash(bound = "T: EthSpec"))]
#[serde(untagged)] #[serde(untagged)]
#[serde(bound = "T: EthSpec, Payload: ExecPayload<T>")] #[serde(bound = "T: EthSpec, Payload: AbstractExecPayload<T>")]
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[arbitrary(bound = "T: EthSpec, Payload: AbstractExecPayload<T>")]
pub struct BeaconBlockBody<T: EthSpec, Payload: AbstractExecPayload<T> = FullPayload<T>> { pub struct BeaconBlockBody<T: EthSpec, Payload: AbstractExecPayload<T> = FullPayload<T>> {
pub randao_reveal: Signature, pub randao_reveal: Signature,
pub eth1_data: Eth1Data, pub eth1_data: Eth1Data,
@ -71,6 +75,7 @@ pub struct BeaconBlockBody<T: EthSpec, Payload: AbstractExecPayload<T> = FullPay
#[ssz(skip_serializing, skip_deserializing)] #[ssz(skip_serializing, skip_deserializing)]
#[tree_hash(skip_hashing)] #[tree_hash(skip_hashing)]
#[serde(skip)] #[serde(skip)]
#[arbitrary(default)]
pub _phantom: PhantomData<Payload>, pub _phantom: PhantomData<Payload>,
} }

View File

@ -10,9 +10,19 @@ use tree_hash_derive::TreeHash;
/// A header of a `BeaconBlock`. /// A header of a `BeaconBlock`.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, arbitrary::Arbitrary,
Debug,
PartialEq,
Eq,
Hash,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
)] )]
pub struct BeaconBlockHeader { pub struct BeaconBlockHeader {
pub slot: Slot, pub slot: Slot,

View File

@ -17,8 +17,7 @@ impl<'a> BeaconCommittee<'a> {
} }
} }
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(arbitrary::Arbitrary, Default, Clone, Debug, PartialEq)]
#[derive(Default, Clone, Debug, PartialEq)]
pub struct OwnedBeaconCommittee { pub struct OwnedBeaconCommittee {
pub slot: Slot, pub slot: Slot,
pub index: CommitteeIndex, pub index: CommitteeIndex,

View File

@ -147,8 +147,7 @@ impl AllowNextEpoch {
} }
} }
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(PartialEq, Eq, Hash, Clone, Copy, arbitrary::Arbitrary)]
#[derive(PartialEq, Eq, Hash, Clone, Copy)]
pub struct BeaconStateHash(Hash256); pub struct BeaconStateHash(Hash256);
impl fmt::Debug for BeaconStateHash { impl fmt::Debug for BeaconStateHash {
@ -190,18 +189,19 @@ impl From<BeaconStateHash> for Hash256 {
TreeHash, TreeHash,
TestRandom, TestRandom,
CompareFields, CompareFields,
arbitrary::Arbitrary
), ),
serde(bound = "T: EthSpec", deny_unknown_fields), serde(bound = "T: EthSpec", deny_unknown_fields),
arbitrary(bound = "T: EthSpec"),
derivative(Clone), derivative(Clone),
cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))
), ),
cast_error(ty = "Error", expr = "Error::IncorrectStateVariant"), cast_error(ty = "Error", expr = "Error::IncorrectStateVariant"),
partial_getter_error(ty = "Error", expr = "Error::IncorrectStateVariant") partial_getter_error(ty = "Error", expr = "Error::IncorrectStateVariant")
)] )]
#[derive(Debug, PartialEq, Serialize, Deserialize, Encode, TreeHash)] #[derive(Debug, PartialEq, Serialize, Deserialize, Encode, TreeHash, arbitrary::Arbitrary)]
#[serde(untagged)] #[serde(untagged)]
#[serde(bound = "T: EthSpec")] #[serde(bound = "T: EthSpec")]
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[arbitrary(bound = "T: EthSpec")]
#[tree_hash(enum_behaviour = "transparent")] #[tree_hash(enum_behaviour = "transparent")]
#[ssz(enum_behaviour = "transparent")] #[ssz(enum_behaviour = "transparent")]
pub struct BeaconState<T> pub struct BeaconState<T>

View File

@ -336,7 +336,6 @@ pub fn get_active_validator_indices(validators: &[Validator], epoch: Epoch) -> V
active active
} }
#[cfg(feature = "arbitrary-fuzz")]
impl arbitrary::Arbitrary<'_> for CommitteeCache { impl arbitrary::Arbitrary<'_> for CommitteeCache {
fn arbitrary(_u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> { fn arbitrary(_u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
Ok(Self::default()) Ok(Self::default())

View File

@ -61,7 +61,6 @@ impl ExitCache {
} }
} }
#[cfg(feature = "arbitrary-fuzz")]
impl arbitrary::Arbitrary<'_> for ExitCache { impl arbitrary::Arbitrary<'_> for ExitCache {
fn arbitrary(_u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> { fn arbitrary(_u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
Ok(Self::default()) Ok(Self::default())

View File

@ -42,7 +42,6 @@ impl PubkeyCache {
} }
} }
#[cfg(feature = "arbitrary-fuzz")]
impl arbitrary::Arbitrary<'_> for PubkeyCache { impl arbitrary::Arbitrary<'_> for PubkeyCache {
fn arbitrary(_u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> { fn arbitrary(_u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
Ok(Self::default()) Ok(Self::default())

View File

@ -600,7 +600,6 @@ impl OptionalTreeHashCacheInner {
} }
} }
#[cfg(feature = "arbitrary-fuzz")]
impl<T: EthSpec> arbitrary::Arbitrary<'_> for BeaconTreeHashCache<T> { impl<T: EthSpec> arbitrary::Arbitrary<'_> for BeaconTreeHashCache<T> {
fn arbitrary(_u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> { fn arbitrary(_u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
Ok(Self::default()) Ok(Self::default())

View File

@ -6,9 +6,20 @@ use ssz_derive::{Decode, Encode};
use ssz_types::VariableList; use ssz_types::VariableList;
use tree_hash_derive::TreeHash; use tree_hash_derive::TreeHash;
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, PartialEq, Default)] Debug,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
PartialEq,
Default,
arbitrary::Arbitrary,
)]
#[serde(bound = "T: EthSpec")] #[serde(bound = "T: EthSpec")]
#[arbitrary(bound = "T: EthSpec")]
pub struct BlobsSidecar<T: EthSpec> { pub struct BlobsSidecar<T: EthSpec> {
pub beacon_block_root: Hash256, pub beacon_block_root: Hash256,
pub beacon_block_slot: Slot, pub beacon_block_slot: Slot,

View File

@ -6,9 +6,18 @@ use ssz_derive::{Decode, Encode};
use test_random_derive::TestRandom; use test_random_derive::TestRandom;
use tree_hash_derive::TreeHash; use tree_hash_derive::TreeHash;
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
Debug, PartialEq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, arbitrary::Arbitrary,
Debug,
PartialEq,
Hash,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
)] )]
pub struct BlsToExecutionChange { pub struct BlsToExecutionChange {
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "eth2_serde_utils::quoted_u64")]

View File

@ -29,8 +29,7 @@ pub enum Domain {
/// Lighthouse's internal configuration struct. /// Lighthouse's internal configuration struct.
/// ///
/// Contains a mixture of "preset" and "config" values w.r.t to the EF definitions. /// Contains a mixture of "preset" and "config" values w.r.t to the EF definitions.
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(arbitrary::Arbitrary, PartialEq, Debug, Clone)]
#[derive(PartialEq, Debug, Clone)]
pub struct ChainSpec { pub struct ChainSpec {
/* /*
* Config name * Config name

View File

@ -8,8 +8,8 @@ use tree_hash_derive::TreeHash;
/// Casper FFG checkpoint, used in attestations. /// Casper FFG checkpoint, used in attestations.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
arbitrary::Arbitrary,
Debug, Debug,
Clone, Clone,
Copy, Copy,

View File

@ -9,9 +9,20 @@ use test_random_derive::TestRandom;
use tree_hash_derive::TreeHash; use tree_hash_derive::TreeHash;
/// A Validators aggregate sync committee contribution and selection proof. /// A Validators aggregate sync committee contribution and selection proof.
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TestRandom, TreeHash)] Debug,
Clone,
PartialEq,
Serialize,
Deserialize,
Encode,
Decode,
TestRandom,
TreeHash,
arbitrary::Arbitrary,
)]
#[serde(bound = "T: EthSpec")] #[serde(bound = "T: EthSpec")]
#[arbitrary(bound = "T: EthSpec")]
pub struct ContributionAndProof<T: EthSpec> { pub struct ContributionAndProof<T: EthSpec> {
/// The index of the validator that created the sync contribution. /// The index of the validator that created the sync contribution.
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "eth2_serde_utils::quoted_u64")]

View File

@ -11,9 +11,18 @@ pub const DEPOSIT_TREE_DEPTH: usize = 32;
/// A deposit to potentially become a beacon chain validator. /// A deposit to potentially become a beacon chain validator.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
Debug, PartialEq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, arbitrary::Arbitrary,
Debug,
PartialEq,
Hash,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
)] )]
pub struct Deposit { pub struct Deposit {
pub proof: FixedVector<Hash256, U33>, pub proof: FixedVector<Hash256, U33>,

View File

@ -10,9 +10,18 @@ use tree_hash_derive::TreeHash;
/// The data supplied by the user to the deposit contract. /// The data supplied by the user to the deposit contract.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
Debug, PartialEq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, arbitrary::Arbitrary,
Debug,
PartialEq,
Hash,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
)] )]
pub struct DepositData { pub struct DepositData {
pub pubkey: PublicKeyBytes, pub pubkey: PublicKeyBytes,

View File

@ -10,8 +10,18 @@ use tree_hash_derive::TreeHash;
/// The data supplied by the user to the deposit contract. /// The data supplied by the user to the deposit contract.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom)] arbitrary::Arbitrary,
Debug,
PartialEq,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
)]
pub struct DepositMessage { pub struct DepositMessage {
pub pubkey: PublicKeyBytes, pub pubkey: PublicKeyBytes,
pub withdrawal_credentials: Hash256, pub withdrawal_credentials: Hash256,

View File

@ -10,9 +10,18 @@ use tree_hash_derive::TreeHash;
/// a nodes local ENR. /// a nodes local ENR.
/// ///
/// Spec v0.11 /// Spec v0.11
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
Debug, Clone, PartialEq, Default, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, arbitrary::Arbitrary,
Debug,
Clone,
PartialEq,
Default,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
)] )]
pub struct EnrForkId { pub struct EnrForkId {
#[serde(with = "eth2_serde_utils::bytes_4_hex")] #[serde(with = "eth2_serde_utils::bytes_4_hex")]

View File

@ -9,8 +9,8 @@ use tree_hash_derive::TreeHash;
/// Contains data obtained from the Eth1 chain. /// Contains data obtained from the Eth1 chain.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
arbitrary::Arbitrary,
Debug, Debug,
PartialEq, PartialEq,
Clone, Clone,

View File

@ -48,7 +48,9 @@ impl fmt::Display for EthSpecId {
} }
} }
pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq + Eq { pub trait EthSpec:
'static + Default + Sync + Send + Clone + Debug + PartialEq + Eq + for<'a> arbitrary::Arbitrary<'a>
{
/* /*
* Constants * Constants
*/ */
@ -258,8 +260,7 @@ macro_rules! params_from_eth_spec {
} }
/// Ethereum Foundation specifications. /// Ethereum Foundation specifications.
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize, arbitrary::Arbitrary)]
#[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize)]
pub struct MainnetEthSpec; pub struct MainnetEthSpec;
impl EthSpec for MainnetEthSpec { impl EthSpec for MainnetEthSpec {
@ -305,8 +306,7 @@ impl EthSpec for MainnetEthSpec {
} }
/// Ethereum Foundation minimal spec, as defined in the eth2.0-specs repo. /// Ethereum Foundation minimal spec, as defined in the eth2.0-specs repo.
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize, arbitrary::Arbitrary)]
#[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize)]
pub struct MinimalEthSpec; pub struct MinimalEthSpec;
impl EthSpec for MinimalEthSpec { impl EthSpec for MinimalEthSpec {
@ -355,8 +355,7 @@ impl EthSpec for MinimalEthSpec {
} }
/// Gnosis Beacon Chain specifications. /// Gnosis Beacon Chain specifications.
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize, arbitrary::Arbitrary)]
#[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize)]
pub struct GnosisEthSpec; pub struct GnosisEthSpec;
impl EthSpec for GnosisEthSpec { impl EthSpec for GnosisEthSpec {

View File

@ -6,8 +6,18 @@ use serde_derive::{Deserialize, Serialize};
use ssz::{Decode, DecodeError, Encode}; use ssz::{Decode, DecodeError, Encode};
use std::fmt; use std::fmt;
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Default, Clone, Copy, Serialize, Deserialize, Eq, PartialEq, Hash, Derivative)] arbitrary::Arbitrary,
Default,
Clone,
Copy,
Serialize,
Deserialize,
Eq,
PartialEq,
Hash,
Derivative,
)]
#[derivative(Debug = "transparent")] #[derivative(Debug = "transparent")]
#[serde(transparent)] #[serde(transparent)]
pub struct ExecutionBlockHash(Hash256); pub struct ExecutionBlockHash(Hash256);

View File

@ -28,20 +28,23 @@ pub type Withdrawals<T> = VariableList<Withdrawal, <T as EthSpec>::MaxWithdrawal
TreeHash, TreeHash,
TestRandom, TestRandom,
Derivative, Derivative,
arbitrary::Arbitrary
), ),
derivative(PartialEq, Hash(bound = "T: EthSpec")), derivative(PartialEq, Hash(bound = "T: EthSpec")),
serde(bound = "T: EthSpec", deny_unknown_fields), serde(bound = "T: EthSpec", deny_unknown_fields),
cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary)) arbitrary(bound = "T: EthSpec")
), ),
cast_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"), cast_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"),
partial_getter_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant") partial_getter_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant")
)] )]
#[derive(Debug, Clone, Serialize, Encode, Deserialize, TreeHash, Derivative)] #[derive(
Debug, Clone, Serialize, Encode, Deserialize, TreeHash, Derivative, arbitrary::Arbitrary,
)]
#[derivative(PartialEq, Hash(bound = "T: EthSpec"))] #[derivative(PartialEq, Hash(bound = "T: EthSpec"))]
#[serde(bound = "T: EthSpec", untagged)] #[serde(bound = "T: EthSpec", untagged)]
#[arbitrary(bound = "T: EthSpec")]
#[ssz(enum_behaviour = "transparent")] #[ssz(enum_behaviour = "transparent")]
#[tree_hash(enum_behaviour = "transparent")] #[tree_hash(enum_behaviour = "transparent")]
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
pub struct ExecutionPayload<T: EthSpec> { pub struct ExecutionPayload<T: EthSpec> {
#[superstruct(getter(copy))] #[superstruct(getter(copy))]
pub parent_hash: ExecutionBlockHash, pub parent_hash: ExecutionBlockHash,

View File

@ -22,21 +22,24 @@ use BeaconStateError;
TreeHash, TreeHash,
TestRandom, TestRandom,
Derivative, Derivative,
arbitrary::Arbitrary
), ),
derivative(PartialEq, Hash(bound = "T: EthSpec")), derivative(PartialEq, Hash(bound = "T: EthSpec")),
serde(bound = "T: EthSpec", deny_unknown_fields), serde(bound = "T: EthSpec", deny_unknown_fields),
cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary)) arbitrary(bound = "T: EthSpec")
), ),
ref_attributes(derive(PartialEq, TreeHash), tree_hash(enum_behaviour = "transparent")), ref_attributes(derive(PartialEq, TreeHash), tree_hash(enum_behaviour = "transparent")),
cast_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"), cast_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"),
partial_getter_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant") partial_getter_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant")
)] )]
#[derive(Debug, Clone, Serialize, Deserialize, Encode, TreeHash, Derivative)] #[derive(
Debug, Clone, Serialize, Deserialize, Encode, TreeHash, Derivative, arbitrary::Arbitrary,
)]
#[derivative(PartialEq, Hash(bound = "T: EthSpec"))] #[derivative(PartialEq, Hash(bound = "T: EthSpec"))]
#[serde(bound = "T: EthSpec", untagged)] #[serde(bound = "T: EthSpec", untagged)]
#[arbitrary(bound = "T: EthSpec")]
#[tree_hash(enum_behaviour = "transparent")] #[tree_hash(enum_behaviour = "transparent")]
#[ssz(enum_behaviour = "transparent")] #[ssz(enum_behaviour = "transparent")]
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
pub struct ExecutionPayloadHeader<T: EthSpec> { pub struct ExecutionPayloadHeader<T: EthSpec> {
#[superstruct(getter(copy))] #[superstruct(getter(copy))]
pub parent_hash: ExecutionBlockHash, pub parent_hash: ExecutionBlockHash,

View File

@ -9,8 +9,8 @@ use tree_hash_derive::TreeHash;
/// Specifies a fork of the `BeaconChain`, to prevent replay attacks. /// Specifies a fork of the `BeaconChain`, to prevent replay attacks.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
arbitrary::Arbitrary,
Debug, Debug,
Clone, Clone,
Copy, Copy,

View File

@ -9,9 +9,18 @@ use tree_hash_derive::TreeHash;
/// Specifies a fork of the `BeaconChain`, to prevent replay attacks. /// Specifies a fork of the `BeaconChain`, to prevent replay attacks.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
Debug, Clone, PartialEq, Default, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, arbitrary::Arbitrary,
Debug,
Clone,
PartialEq,
Default,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
)] )]
pub struct ForkData { pub struct ForkData {
#[serde(with = "eth2_serde_utils::bytes_4_hex")] #[serde(with = "eth2_serde_utils::bytes_4_hex")]

View File

@ -4,8 +4,7 @@
use super::{AttestationData, Signature}; use super::{AttestationData, Signature};
use serde_derive::Serialize; use serde_derive::Serialize;
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(arbitrary::Arbitrary, Debug, Clone, PartialEq, Serialize)]
#[derive(Debug, Clone, PartialEq, Serialize)]
pub struct FreeAttestation { pub struct FreeAttestation {
pub data: AttestationData, pub data: AttestationData,
pub signature: Signature, pub signature: Signature,

View File

@ -14,7 +14,7 @@ pub const GRAFFITI_BYTES_LEN: usize = 32;
/// The 32-byte `graffiti` field on a beacon block. /// The 32-byte `graffiti` field on a beacon block.
#[derive(Default, Debug, PartialEq, Hash, Clone, Copy, Serialize, Deserialize)] #[derive(Default, Debug, PartialEq, Hash, Clone, Copy, Serialize, Deserialize)]
#[serde(transparent)] #[serde(transparent)]
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(arbitrary::Arbitrary)]
pub struct Graffiti(#[serde(with = "serde_graffiti")] pub [u8; GRAFFITI_BYTES_LEN]); pub struct Graffiti(#[serde(with = "serde_graffiti")] pub [u8; GRAFFITI_BYTES_LEN]);
impl Graffiti { impl Graffiti {

View File

@ -10,8 +10,19 @@ use tree_hash_derive::TreeHash;
/// Historical block and state roots. /// Historical block and state roots.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom)] Debug,
Clone,
PartialEq,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
arbitrary::Arbitrary,
)]
#[arbitrary(bound = "T: EthSpec")]
pub struct HistoricalBatch<T: EthSpec> { pub struct HistoricalBatch<T: EthSpec> {
pub block_roots: FixedVector<Hash256, T::SlotsPerHistoricalRoot>, pub block_roots: FixedVector<Hash256, T::SlotsPerHistoricalRoot>,
pub state_roots: FixedVector<Hash256, T::SlotsPerHistoricalRoot>, pub state_roots: FixedVector<Hash256, T::SlotsPerHistoricalRoot>,

View File

@ -12,12 +12,21 @@ use tree_hash_derive::TreeHash;
/// To be included in an `AttesterSlashing`. /// To be included in an `AttesterSlashing`.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
Derivative, Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, Derivative,
Debug,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
arbitrary::Arbitrary,
)] )]
#[derivative(PartialEq, Eq)] // to satisfy Clippy's lint about `Hash` #[derivative(PartialEq, Eq)] // to satisfy Clippy's lint about `Hash`
#[serde(bound = "T: EthSpec")] #[serde(bound = "T: EthSpec")]
#[arbitrary(bound = "T: EthSpec")]
pub struct IndexedAttestation<T: EthSpec> { pub struct IndexedAttestation<T: EthSpec> {
/// Lists validator registry indices, not committee indices. /// Lists validator registry indices, not committee indices.
#[serde(with = "quoted_variable_list_u64")] #[serde(with = "quoted_variable_list_u64")]

View File

@ -7,7 +7,9 @@ use std::fmt;
use std::fmt::{Display, Formatter}; use std::fmt::{Display, Formatter};
use tree_hash::{PackedEncoding, TreeHash}; use tree_hash::{PackedEncoding, TreeHash};
#[derive(Derivative, Debug, Clone, Encode, Decode, Serialize, Deserialize)] #[derive(
Derivative, Debug, Clone, Encode, Decode, Serialize, Deserialize, arbitrary::Arbitrary,
)]
#[derivative(PartialEq, Eq, Hash)] #[derivative(PartialEq, Eq, Hash)]
#[ssz(struct_behaviour = "transparent")] #[ssz(struct_behaviour = "transparent")]
pub struct KzgCommitment(#[serde(with = "BigArray")] pub [u8; 48]); pub struct KzgCommitment(#[serde(with = "BigArray")] pub [u8; 48]);

View File

@ -7,7 +7,18 @@ use tree_hash::{PackedEncoding, TreeHash};
const KZG_PROOF_BYTES_LEN: usize = 48; const KZG_PROOF_BYTES_LEN: usize = 48;
#[derive(Debug, PartialEq, Hash, Clone, Copy, Encode, Decode, Serialize, Deserialize)] #[derive(
Debug,
PartialEq,
Hash,
Clone,
Copy,
Encode,
Decode,
Serialize,
Deserialize,
arbitrary::Arbitrary,
)]
#[serde(transparent)] #[serde(transparent)]
#[ssz(struct_behaviour = "transparent")] #[ssz(struct_behaviour = "transparent")]
pub struct KzgProof(#[serde(with = "BigArray")] pub [u8; KZG_PROOF_BYTES_LEN]); pub struct KzgProof(#[serde(with = "BigArray")] pub [u8; KZG_PROOF_BYTES_LEN]);

View File

@ -8,9 +8,19 @@ use tree_hash::TreeHash;
/// A LightClientBootstrap is the initializer we send over to lightclient nodes /// A LightClientBootstrap is the initializer we send over to lightclient nodes
/// that are trying to generate their basic storage when booting up. /// that are trying to generate their basic storage when booting up.
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TestRandom)] Debug,
Clone,
PartialEq,
Serialize,
Deserialize,
Encode,
Decode,
TestRandom,
arbitrary::Arbitrary,
)]
#[serde(bound = "T: EthSpec")] #[serde(bound = "T: EthSpec")]
#[arbitrary(bound = "T: EthSpec")]
pub struct LightClientBootstrap<T: EthSpec> { pub struct LightClientBootstrap<T: EthSpec> {
/// Requested beacon block header. /// Requested beacon block header.
pub header: BeaconBlockHeader, pub header: BeaconBlockHeader,

View File

@ -10,9 +10,19 @@ use tree_hash::TreeHash;
/// A LightClientFinalityUpdate is the update lightclient request or received by a gossip that /// A LightClientFinalityUpdate is the update lightclient request or received by a gossip that
/// signal a new finalized beacon block header for the light client sync protocol. /// signal a new finalized beacon block header for the light client sync protocol.
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TestRandom)] Debug,
Clone,
PartialEq,
Serialize,
Deserialize,
Encode,
Decode,
TestRandom,
arbitrary::Arbitrary,
)]
#[serde(bound = "T: EthSpec")] #[serde(bound = "T: EthSpec")]
#[arbitrary(bound = "T: EthSpec")]
pub struct LightClientFinalityUpdate<T: EthSpec> { pub struct LightClientFinalityUpdate<T: EthSpec> {
/// The last `BeaconBlockHeader` from the last attested block by the sync committee. /// The last `BeaconBlockHeader` from the last attested block by the sync committee.
pub attested_header: BeaconBlockHeader, pub attested_header: BeaconBlockHeader,

View File

@ -9,9 +9,19 @@ use tree_hash::TreeHash;
/// A LightClientOptimisticUpdate is the update we send on each slot, /// A LightClientOptimisticUpdate is the update we send on each slot,
/// it is based off the current unfinalized epoch is verified only against BLS signature. /// it is based off the current unfinalized epoch is verified only against BLS signature.
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TestRandom)] Debug,
Clone,
PartialEq,
Serialize,
Deserialize,
Encode,
Decode,
TestRandom,
arbitrary::Arbitrary,
)]
#[serde(bound = "T: EthSpec")] #[serde(bound = "T: EthSpec")]
#[arbitrary(bound = "T: EthSpec")]
pub struct LightClientOptimisticUpdate<T: EthSpec> { pub struct LightClientOptimisticUpdate<T: EthSpec> {
/// The last `BeaconBlockHeader` from the last attested block by the sync committee. /// The last `BeaconBlockHeader` from the last attested block by the sync committee.
pub attested_header: BeaconBlockHeader, pub attested_header: BeaconBlockHeader,

View File

@ -52,9 +52,19 @@ impl From<ArithError> for Error {
/// A LightClientUpdate is the update we request solely to either complete the bootstraping process, /// A LightClientUpdate is the update we request solely to either complete the bootstraping process,
/// or to sync up to the last committee period, we need to have one ready for each ALTAIR period /// or to sync up to the last committee period, we need to have one ready for each ALTAIR period
/// we go over, note: there is no need to keep all of the updates from [ALTAIR_PERIOD, CURRENT_PERIOD]. /// we go over, note: there is no need to keep all of the updates from [ALTAIR_PERIOD, CURRENT_PERIOD].
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TestRandom)] Debug,
Clone,
PartialEq,
Serialize,
Deserialize,
Encode,
Decode,
TestRandom,
arbitrary::Arbitrary,
)]
#[serde(bound = "T: EthSpec")] #[serde(bound = "T: EthSpec")]
#[arbitrary(bound = "T: EthSpec")]
pub struct LightClientUpdate<T: EthSpec> { pub struct LightClientUpdate<T: EthSpec> {
/// The last `BeaconBlockHeader` from the last attested block by the sync committee. /// The last `BeaconBlockHeader` from the last attested block by the sync committee.
pub attested_header: BeaconBlockHeader, pub attested_header: BeaconBlockHeader,

View File

@ -7,7 +7,7 @@ use tree_hash::{PackedEncoding, TreeHash, TreeHashType};
#[derive(Debug, Default, Clone, Copy, PartialEq, Deserialize, Serialize, TestRandom)] #[derive(Debug, Default, Clone, Copy, PartialEq, Deserialize, Serialize, TestRandom)]
#[serde(transparent)] #[serde(transparent)]
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(arbitrary::Arbitrary)]
pub struct ParticipationFlags { pub struct ParticipationFlags {
#[serde(with = "eth2_serde_utils::quoted_u8")] #[serde(with = "eth2_serde_utils::quoted_u8")]
bits: u8, bits: u8,

View File

@ -48,7 +48,15 @@ pub trait ExecPayload<T: EthSpec>: Debug + Clone + PartialEq + Hash + TreeHash +
/// `ExecPayload` functionality the requires ownership. /// `ExecPayload` functionality the requires ownership.
pub trait OwnedExecPayload<T: EthSpec>: pub trait OwnedExecPayload<T: EthSpec>:
ExecPayload<T> + Default + Serialize + DeserializeOwned + Encode + Decode + TestRandom + 'static ExecPayload<T>
+ Default
+ Serialize
+ DeserializeOwned
+ Encode
+ Decode
+ TestRandom
+ for<'a> arbitrary::Arbitrary<'a>
+ 'static
{ {
} }
@ -60,6 +68,7 @@ impl<T: EthSpec, P> OwnedExecPayload<T> for P where
+ Encode + Encode
+ Decode + Decode
+ TestRandom + TestRandom
+ for<'a> arbitrary::Arbitrary<'a>
+ 'static + 'static
{ {
} }
@ -108,10 +117,11 @@ pub trait AbstractExecPayload<T: EthSpec>:
TestRandom, TestRandom,
TreeHash, TreeHash,
Derivative, Derivative,
arbitrary::Arbitrary,
), ),
derivative(PartialEq, Hash(bound = "T: EthSpec")), derivative(PartialEq, Hash(bound = "T: EthSpec")),
serde(bound = "T: EthSpec", deny_unknown_fields), serde(bound = "T: EthSpec", deny_unknown_fields),
cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary)), arbitrary(bound = "T: EthSpec"),
ssz(struct_behaviour = "transparent"), ssz(struct_behaviour = "transparent"),
), ),
ref_attributes( ref_attributes(
@ -123,9 +133,10 @@ pub trait AbstractExecPayload<T: EthSpec>:
cast_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"), cast_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"),
partial_getter_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant") partial_getter_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant")
)] )]
#[derive(Debug, Clone, Serialize, Deserialize, TreeHash, Derivative)] #[derive(Debug, Clone, Serialize, Deserialize, TreeHash, Derivative, arbitrary::Arbitrary)]
#[derivative(PartialEq, Hash(bound = "T: EthSpec"))] #[derivative(PartialEq, Hash(bound = "T: EthSpec"))]
#[serde(bound = "T: EthSpec")] #[serde(bound = "T: EthSpec")]
#[arbitrary(bound = "T: EthSpec")]
#[tree_hash(enum_behaviour = "transparent")] #[tree_hash(enum_behaviour = "transparent")]
pub struct FullPayload<T: EthSpec> { pub struct FullPayload<T: EthSpec> {
#[superstruct(only(Merge), partial_getter(rename = "execution_payload_merge"))] #[superstruct(only(Merge), partial_getter(rename = "execution_payload_merge"))]
@ -418,10 +429,11 @@ impl<T: EthSpec> TryFrom<ExecutionPayloadHeader<T>> for FullPayload<T> {
TestRandom, TestRandom,
TreeHash, TreeHash,
Derivative, Derivative,
arbitrary::Arbitrary
), ),
derivative(PartialEq, Hash(bound = "T: EthSpec")), derivative(PartialEq, Hash(bound = "T: EthSpec")),
serde(bound = "T: EthSpec", deny_unknown_fields), serde(bound = "T: EthSpec", deny_unknown_fields),
cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary)), arbitrary(bound = "T: EthSpec"),
ssz(struct_behaviour = "transparent"), ssz(struct_behaviour = "transparent"),
), ),
ref_attributes( ref_attributes(
@ -433,9 +445,10 @@ impl<T: EthSpec> TryFrom<ExecutionPayloadHeader<T>> for FullPayload<T> {
cast_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"), cast_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"),
partial_getter_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant") partial_getter_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant")
)] )]
#[derive(Debug, Clone, Serialize, Deserialize, TreeHash, Derivative)] #[derive(Debug, Clone, Serialize, Deserialize, TreeHash, Derivative, arbitrary::Arbitrary)]
#[derivative(PartialEq, Hash(bound = "T: EthSpec"))] #[derivative(PartialEq, Hash(bound = "T: EthSpec"))]
#[serde(bound = "T: EthSpec")] #[serde(bound = "T: EthSpec")]
#[arbitrary(bound = "T: EthSpec")]
#[tree_hash(enum_behaviour = "transparent")] #[tree_hash(enum_behaviour = "transparent")]
pub struct BlindedPayload<T: EthSpec> { pub struct BlindedPayload<T: EthSpec> {
#[superstruct(only(Merge), partial_getter(rename = "execution_payload_merge"))] #[superstruct(only(Merge), partial_getter(rename = "execution_payload_merge"))]

View File

@ -9,7 +9,19 @@ use tree_hash_derive::TreeHash;
/// An attestation that has been included in the state but not yet fully processed. /// An attestation that has been included in the state but not yet fully processed.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom)] #[derive(
Debug,
Clone,
PartialEq,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
arbitrary::Arbitrary,
)]
#[arbitrary(bound = "T: EthSpec")]
pub struct PendingAttestation<T: EthSpec> { pub struct PendingAttestation<T: EthSpec> {
pub aggregation_bits: BitList<T::MaxValidatorsPerCommittee>, pub aggregation_bits: BitList<T::MaxValidatorsPerCommittee>,
pub data: AttestationData, pub data: AttestationData,
@ -19,18 +31,6 @@ pub struct PendingAttestation<T: EthSpec> {
pub proposer_index: u64, pub proposer_index: u64,
} }
#[cfg(feature = "arbitrary-fuzz")]
impl<T: EthSpec> arbitrary::Arbitrary<'_> for PendingAttestation<T> {
fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
Ok(Self {
aggregation_bits: <BitList<T::MaxValidatorsPerCommittee>>::arbitrary(u)?,
data: AttestationData::arbitrary(u)?,
inclusion_delay: u64::arbitrary(u)?,
proposer_index: u64::arbitrary(u)?,
})
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;

View File

@ -9,9 +9,19 @@ use tree_hash_derive::TreeHash;
/// Two conflicting proposals from the same proposer (validator). /// Two conflicting proposals from the same proposer (validator).
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, arbitrary::Arbitrary,
Debug,
PartialEq,
Eq,
Hash,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
)] )]
pub struct ProposerSlashing { pub struct ProposerSlashing {
pub signed_header_1: SignedBeaconBlockHeader, pub signed_header_1: SignedBeaconBlockHeader,

View File

@ -14,15 +14,11 @@ impl From<ArithError> for Error {
} }
} }
#[cfg(feature = "arbitrary-fuzz")]
use arbitrary::Arbitrary;
/// Defines the epochs relative to some epoch. Most useful when referring to the committees prior /// Defines the epochs relative to some epoch. Most useful when referring to the committees prior
/// to and following some epoch. /// to and following some epoch.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(Arbitrary))] #[derive(Debug, PartialEq, Clone, Copy, arbitrary::Arbitrary)]
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum RelativeEpoch { pub enum RelativeEpoch {
/// The prior epoch. /// The prior epoch.
Previous, Previous,

View File

@ -7,8 +7,7 @@ use ssz::Encode;
use std::cmp; use std::cmp;
use std::convert::TryInto; use std::convert::TryInto;
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(arbitrary::Arbitrary, PartialEq, Debug, Clone)]
#[derive(PartialEq, Debug, Clone)]
pub struct SelectionProof(Signature); pub struct SelectionProof(Signature);
impl SelectionProof { impl SelectionProof {

View File

@ -12,9 +12,20 @@ use tree_hash_derive::TreeHash;
/// gossipsub topic. /// gossipsub topic.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TestRandom, TreeHash)] Debug,
Clone,
PartialEq,
Serialize,
Deserialize,
Encode,
Decode,
TestRandom,
TreeHash,
arbitrary::Arbitrary,
)]
#[serde(bound = "T: EthSpec")] #[serde(bound = "T: EthSpec")]
#[arbitrary(bound = "T: EthSpec")]
pub struct SignedAggregateAndProof<T: EthSpec> { pub struct SignedAggregateAndProof<T: EthSpec> {
/// The `AggregateAndProof` that was signed. /// The `AggregateAndProof` that was signed.
pub message: AggregateAndProof<T>, pub message: AggregateAndProof<T>,

View File

@ -8,8 +8,7 @@ use superstruct::superstruct;
use tree_hash::TreeHash; use tree_hash::TreeHash;
use tree_hash_derive::TreeHash; use tree_hash_derive::TreeHash;
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(arbitrary::Arbitrary, PartialEq, Eq, Hash, Clone, Copy)]
#[derive(PartialEq, Eq, Hash, Clone, Copy)]
pub struct SignedBeaconBlockHash(Hash256); pub struct SignedBeaconBlockHash(Hash256);
impl fmt::Debug for SignedBeaconBlockHash { impl fmt::Debug for SignedBeaconBlockHash {
@ -49,20 +48,23 @@ impl From<SignedBeaconBlockHash> for Hash256 {
Decode, Decode,
TreeHash, TreeHash,
Derivative, Derivative,
arbitrary::Arbitrary
), ),
derivative(PartialEq, Hash(bound = "E: EthSpec")), derivative(PartialEq, Hash(bound = "E: EthSpec")),
cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary)), serde(bound = "E: EthSpec, Payload: AbstractExecPayload<E>"),
serde(bound = "E: EthSpec, Payload: ExecPayload<E>"), arbitrary(bound = "E: EthSpec, Payload: AbstractExecPayload<E>"),
), ),
map_into(BeaconBlock), map_into(BeaconBlock),
map_ref_into(BeaconBlockRef), map_ref_into(BeaconBlockRef),
map_ref_mut_into(BeaconBlockRefMut) map_ref_mut_into(BeaconBlockRefMut)
)] )]
#[derive(Debug, Clone, Serialize, Deserialize, Encode, TreeHash, Derivative)] #[derive(
Debug, Clone, Serialize, Deserialize, Encode, TreeHash, Derivative, arbitrary::Arbitrary,
)]
#[derivative(PartialEq, Hash(bound = "E: EthSpec"))] #[derivative(PartialEq, Hash(bound = "E: EthSpec"))]
#[serde(untagged)] #[serde(untagged)]
#[serde(bound = "E: EthSpec, Payload: ExecPayload<E>")] #[serde(bound = "E: EthSpec, Payload: AbstractExecPayload<E>")]
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[arbitrary(bound = "E: EthSpec, Payload: AbstractExecPayload<E>")]
#[tree_hash(enum_behaviour = "transparent")] #[tree_hash(enum_behaviour = "transparent")]
#[ssz(enum_behaviour = "transparent")] #[ssz(enum_behaviour = "transparent")]
pub struct SignedBeaconBlock<E: EthSpec, Payload: AbstractExecPayload<E> = FullPayload<E>> { pub struct SignedBeaconBlock<E: EthSpec, Payload: AbstractExecPayload<E> = FullPayload<E>> {

View File

@ -10,9 +10,19 @@ use tree_hash_derive::TreeHash;
/// A signed header of a `BeaconBlock`. /// A signed header of a `BeaconBlock`.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, arbitrary::Arbitrary,
Debug,
Clone,
PartialEq,
Eq,
Hash,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
)] )]
pub struct SignedBeaconBlockHeader { pub struct SignedBeaconBlockHeader {
pub message: BeaconBlockHeader, pub message: BeaconBlockHeader,

View File

@ -6,9 +6,18 @@ use ssz_derive::{Decode, Encode};
use test_random_derive::TestRandom; use test_random_derive::TestRandom;
use tree_hash_derive::TreeHash; use tree_hash_derive::TreeHash;
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
Debug, PartialEq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, arbitrary::Arbitrary,
Debug,
PartialEq,
Hash,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
)] )]
pub struct SignedBlsToExecutionChange { pub struct SignedBlsToExecutionChange {
pub message: BlsToExecutionChange, pub message: BlsToExecutionChange,

View File

@ -10,9 +10,20 @@ use tree_hash_derive::TreeHash;
/// A Validators signed contribution proof to publish on the `sync_committee_contribution_and_proof` /// A Validators signed contribution proof to publish on the `sync_committee_contribution_and_proof`
/// gossipsub topic. /// gossipsub topic.
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TestRandom, TreeHash)] Debug,
Clone,
PartialEq,
Serialize,
Deserialize,
Encode,
Decode,
TestRandom,
TreeHash,
arbitrary::Arbitrary,
)]
#[serde(bound = "T: EthSpec")] #[serde(bound = "T: EthSpec")]
#[arbitrary(bound = "T: EthSpec")]
pub struct SignedContributionAndProof<T: EthSpec> { pub struct SignedContributionAndProof<T: EthSpec> {
/// The `ContributionAndProof` that was signed. /// The `ContributionAndProof` that was signed.
pub message: ContributionAndProof<T>, pub message: ContributionAndProof<T>,

View File

@ -9,9 +9,18 @@ use tree_hash_derive::TreeHash;
/// An exit voluntarily submitted a validator who wishes to withdraw. /// An exit voluntarily submitted a validator who wishes to withdraw.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
Debug, PartialEq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, arbitrary::Arbitrary,
Debug,
PartialEq,
Hash,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
)] )]
pub struct SignedVoluntaryExit { pub struct SignedVoluntaryExit {
pub message: VoluntaryExit, pub message: VoluntaryExit,

View File

@ -7,8 +7,18 @@ use test_random_derive::TestRandom;
use tree_hash::TreeHash; use tree_hash::TreeHash;
use tree_hash_derive::TreeHash; use tree_hash_derive::TreeHash;
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom)] arbitrary::Arbitrary,
Debug,
PartialEq,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
)]
pub struct SigningData { pub struct SigningData {
pub object_root: Hash256, pub object_root: Hash256,
pub domain: Hash256, pub domain: Hash256,

View File

@ -24,13 +24,35 @@ use std::iter::Iterator;
#[cfg(feature = "legacy-arith")] #[cfg(feature = "legacy-arith")]
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, Sub, SubAssign}; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, Sub, SubAssign};
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] arbitrary::Arbitrary,
Clone,
Copy,
Default,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Serialize,
Deserialize,
)]
#[serde(transparent)] #[serde(transparent)]
pub struct Slot(#[serde(with = "eth2_serde_utils::quoted_u64")] u64); pub struct Slot(#[serde(with = "eth2_serde_utils::quoted_u64")] u64);
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] arbitrary::Arbitrary,
Clone,
Copy,
Default,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Serialize,
Deserialize,
)]
#[serde(transparent)] #[serde(transparent)]
pub struct Epoch(#[serde(with = "eth2_serde_utils::quoted_u64")] u64); pub struct Epoch(#[serde(with = "eth2_serde_utils::quoted_u64")] u64);

View File

@ -18,8 +18,7 @@ lazy_static! {
}; };
} }
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(arbitrary::Arbitrary, Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(transparent)] #[serde(transparent)]
pub struct SubnetId(#[serde(with = "eth2_serde_utils::quoted_u64")] u64); pub struct SubnetId(#[serde(with = "eth2_serde_utils::quoted_u64")] u64);

View File

@ -20,12 +20,21 @@ impl From<ArithError> for Error {
} }
} }
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, Derivative, Debug,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
Derivative,
arbitrary::Arbitrary,
)] )]
#[derivative(PartialEq, Hash(bound = "T: EthSpec"))] #[derivative(PartialEq, Hash(bound = "T: EthSpec"))]
#[serde(bound = "T: EthSpec")] #[serde(bound = "T: EthSpec")]
#[arbitrary(bound = "T: EthSpec")]
pub struct SyncAggregate<T: EthSpec> { pub struct SyncAggregate<T: EthSpec> {
pub sync_committee_bits: BitVector<T::SyncCommitteeSize>, pub sync_committee_bits: BitVector<T::SyncCommitteeSize>,
pub sync_committee_signature: AggregateSignature, pub sync_committee_signature: AggregateSignature,

View File

@ -6,9 +6,18 @@ use ssz_derive::{Decode, Encode};
use test_random_derive::TestRandom; use test_random_derive::TestRandom;
use tree_hash_derive::TreeHash; use tree_hash_derive::TreeHash;
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
Debug, PartialEq, Clone, Serialize, Deserialize, Hash, Encode, Decode, TreeHash, TestRandom, arbitrary::Arbitrary,
Debug,
PartialEq,
Clone,
Serialize,
Deserialize,
Hash,
Encode,
Decode,
TreeHash,
TestRandom,
)] )]
pub struct SyncAggregatorSelectionData { pub struct SyncAggregatorSelectionData {
pub slot: Slot, pub slot: Slot,

View File

@ -25,9 +25,20 @@ impl From<ArithError> for Error {
} }
} }
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom)] Debug,
PartialEq,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
arbitrary::Arbitrary,
)]
#[serde(bound = "T: EthSpec")] #[serde(bound = "T: EthSpec")]
#[arbitrary(bound = "T: EthSpec")]
pub struct SyncCommittee<T: EthSpec> { pub struct SyncCommittee<T: EthSpec> {
pub pubkeys: FixedVector<PublicKeyBytes, T::SyncCommitteeSize>, pub pubkeys: FixedVector<PublicKeyBytes, T::SyncCommitteeSize>,
pub aggregate_pubkey: PublicKeyBytes, pub aggregate_pubkey: PublicKeyBytes,

View File

@ -15,9 +15,20 @@ pub enum Error {
} }
/// An aggregation of `SyncCommitteeMessage`s, used in creating a `SignedContributionAndProof`. /// An aggregation of `SyncCommitteeMessage`s, used in creating a `SignedContributionAndProof`.
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom)] Debug,
Clone,
PartialEq,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
arbitrary::Arbitrary,
)]
#[serde(bound = "T: EthSpec")] #[serde(bound = "T: EthSpec")]
#[arbitrary(bound = "T: EthSpec")]
pub struct SyncCommitteeContribution<T: EthSpec> { pub struct SyncCommitteeContribution<T: EthSpec> {
pub slot: Slot, pub slot: Slot,
pub beacon_block_root: Hash256, pub beacon_block_root: Hash256,

View File

@ -8,8 +8,18 @@ use test_random_derive::TestRandom;
use tree_hash_derive::TreeHash; use tree_hash_derive::TreeHash;
/// The data upon which a `SyncCommitteeContribution` is based. /// The data upon which a `SyncCommitteeContribution` is based.
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom)] arbitrary::Arbitrary,
Debug,
Clone,
PartialEq,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
)]
pub struct SyncCommitteeMessage { pub struct SyncCommitteeMessage {
pub slot: Slot, pub slot: Slot,
pub beacon_block_root: Hash256, pub beacon_block_root: Hash256,

View File

@ -12,8 +12,7 @@ use ssz_types::typenum::Unsigned;
use std::cmp; use std::cmp;
use std::convert::TryInto; use std::convert::TryInto;
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(arbitrary::Arbitrary, PartialEq, Debug, Clone)]
#[derive(PartialEq, Debug, Clone)]
pub struct SyncSelectionProof(Signature); pub struct SyncSelectionProof(Signature);
impl SyncSelectionProof { impl SyncSelectionProof {

View File

@ -19,8 +19,7 @@ lazy_static! {
}; };
} }
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(arbitrary::Arbitrary, Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(transparent)] #[serde(transparent)]
pub struct SyncSubnetId(#[serde(with = "eth2_serde_utils::quoted_u64")] u64); pub struct SyncSubnetId(#[serde(with = "eth2_serde_utils::quoted_u64")] u64);

View File

@ -10,8 +10,18 @@ use tree_hash_derive::TreeHash;
/// Information about a `BeaconChain` validator. /// Information about a `BeaconChain` validator.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))] #[derive(
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TestRandom, TreeHash)] arbitrary::Arbitrary,
Debug,
Clone,
PartialEq,
Serialize,
Deserialize,
Encode,
Decode,
TestRandom,
TreeHash,
)]
pub struct Validator { pub struct Validator {
pub pubkey: PublicKeyBytes, pub pubkey: PublicKeyBytes,
pub withdrawal_credentials: Hash256, pub withdrawal_credentials: Hash256,

View File

@ -11,9 +11,18 @@ use tree_hash_derive::TreeHash;
/// An exit voluntarily submitted a validator who wishes to withdraw. /// An exit voluntarily submitted a validator who wishes to withdraw.
/// ///
/// Spec v0.12.1 /// Spec v0.12.1
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
Debug, PartialEq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, arbitrary::Arbitrary,
Debug,
PartialEq,
Hash,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
)] )]
pub struct VoluntaryExit { pub struct VoluntaryExit {
/// Earliest epoch when voluntary exit can be processed. /// Earliest epoch when voluntary exit can be processed.

View File

@ -5,9 +5,19 @@ use ssz_derive::{Decode, Encode};
use test_random_derive::TestRandom; use test_random_derive::TestRandom;
use tree_hash_derive::TreeHash; use tree_hash_derive::TreeHash;
#[cfg_attr(feature = "arbitrary-fuzz", derive(arbitrary::Arbitrary))]
#[derive( #[derive(
Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, arbitrary::Arbitrary,
Debug,
PartialEq,
Eq,
Hash,
Clone,
Serialize,
Deserialize,
Encode,
Decode,
TreeHash,
TestRandom,
)] )]
pub struct Withdrawal { pub struct Withdrawal {
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "eth2_serde_utils::quoted_u64")]