diff --git a/Cargo.lock b/Cargo.lock index af5d63e97f4..3786392feb6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6016,9 +6016,9 @@ dependencies = [ [[package]] name = "milhouse" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdc758ed0c2597254f45baa97c8aa35f44ae0c8b04ddc355f135ced531f316d6" +checksum = "2bdb104e38d3a8c5ffb7e9d2c43c522e6bcc34070edbadba565e722f0dee56c7" dependencies = [ "alloy-primitives", "arbitrary", diff --git a/Cargo.toml b/Cargo.toml index 817c2f2d802..d2a9184ac82 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -184,7 +184,7 @@ malloc_utils = { path = "common/malloc_utils" } maplit = "1" merkle_proof = { path = "consensus/merkle_proof" } metrics = { path = "common/metrics" } -milhouse = "0.6" +milhouse = { version = "0.7", default-features = false } mockall = "0.13" mockall_double = "0.3" mockito = "1.5.0" diff --git a/Dockerfile b/Dockerfile index 437c864c303..f925836e48e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.84.0-bullseye AS builder +FROM rust:1.88.0-bullseye AS builder RUN apt-get update && apt-get -y upgrade && apt-get install -y cmake libclang-dev COPY . lighthouse ARG FEATURES diff --git a/consensus/types/Cargo.toml b/consensus/types/Cargo.toml index ec6835defca..50ca1835d0b 100644 --- a/consensus/types/Cargo.toml +++ b/consensus/types/Cargo.toml @@ -9,18 +9,22 @@ default = ["sqlite", "legacy-arith"] # Allow saturating arithmetic on slots and epochs. Enabled by default, but deprecated. legacy-arith = [] sqlite = ["dep:rusqlite"] -# The `arbitrary-fuzz` feature is a no-op provided for backwards compatibility. -# For simplicity `Arbitrary` is now derived regardless of the feature's presence. -arbitrary-fuzz = [] +arbitrary = [ + "dep:arbitrary", + "bls/arbitrary", + "ethereum_ssz/arbitrary", + "milhouse/arbitrary", + "ssz_types/arbitrary", + "swap_or_not_shuffle/arbitrary", +] +arbitrary-fuzz = ["arbitrary"] portable = ["bls/supranational-portable"] [dependencies] alloy-primitives = { workspace = true } alloy-rlp = { version = "0.3.4", features = ["derive"] } -# The arbitrary dependency is enabled by default since Capella to avoid complexity introduced by -# `AbstractExecPayload` -arbitrary = { workspace = true, features = ["derive"] } -bls = { workspace = true, features = ["arbitrary"] } +arbitrary = { workspace = true, features = ["derive"], optional = true } +bls = { workspace = true } compare_fields = { workspace = true } compare_fields_derive = { workspace = true } context_deserialize = { workspace = true } @@ -29,7 +33,7 @@ derivative = { workspace = true } eth2_interop_keypairs = { path = "../../common/eth2_interop_keypairs" } ethereum_hashing = { workspace = true } ethereum_serde_utils = { workspace = true } -ethereum_ssz = { workspace = true, features = ["arbitrary"] } +ethereum_ssz = { workspace = true } ethereum_ssz_derive = { workspace = true } fixed_bytes = { workspace = true } hex = { workspace = true } @@ -52,9 +56,9 @@ serde = { workspace = true, features = ["rc"] } serde_json = { workspace = true } serde_yaml = { workspace = true } smallvec = { workspace = true } -ssz_types = { workspace = true, features = ["arbitrary"] } +ssz_types = { workspace = true } superstruct = { workspace = true } -swap_or_not_shuffle = { workspace = true, features = ["arbitrary"] } +swap_or_not_shuffle = { workspace = true } tempfile = { workspace = true } test_random_derive = { path = "../../common/test_random_derive" } tracing = { workspace = true } diff --git a/consensus/types/src/activation_queue.rs b/consensus/types/src/activation_queue.rs index 09ffa5b85e7..dd3ce5f88cb 100644 --- a/consensus/types/src/activation_queue.rs +++ b/consensus/types/src/activation_queue.rs @@ -2,7 +2,8 @@ use crate::{ChainSpec, Epoch, Validator}; use std::collections::BTreeSet; /// Activation queue computed during epoch processing for use in the *next* epoch. -#[derive(Debug, PartialEq, Eq, Default, Clone, arbitrary::Arbitrary)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Debug, PartialEq, Eq, Default, Clone)] pub struct ActivationQueue { /// Validators represented by `(activation_eligibility_epoch, index)` in sorted order. /// diff --git a/consensus/types/src/aggregate_and_proof.rs b/consensus/types/src/aggregate_and_proof.rs index a280afeaae3..374fd3f0ffc 100644 --- a/consensus/types/src/aggregate_and_proof.rs +++ b/consensus/types/src/aggregate_and_proof.rs @@ -16,7 +16,6 @@ use tree_hash_derive::TreeHash; variants(Base, Electra), variant_attributes( derive( - arbitrary::Arbitrary, Debug, Clone, PartialEq, @@ -29,23 +28,29 @@ use tree_hash_derive::TreeHash; ), context_deserialize(ForkName), serde(bound = "E: EthSpec"), - arbitrary(bound = "E: EthSpec"), + cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec"), + ), ), ref_attributes( - derive(Debug, PartialEq, TreeHash, Serialize,), + derive(Debug, PartialEq, TreeHash, Serialize), serde(untagged, bound = "E: EthSpec"), tree_hash(enum_behaviour = "transparent") ), map_ref_into(AttestationRef) )] -#[derive( - arbitrary::Arbitrary, Debug, Clone, PartialEq, Serialize, Deserialize, Encode, TreeHash, +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") )] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, TreeHash)] #[serde(untagged)] #[tree_hash(enum_behaviour = "transparent")] #[ssz(enum_behaviour = "transparent")] #[serde(bound = "E: EthSpec", deny_unknown_fields)] -#[arbitrary(bound = "E: EthSpec")] pub struct AggregateAndProof { /// The index of the validator that created the attestation. #[serde(with = "serde_utils::quoted_u64")] diff --git a/consensus/types/src/attestation.rs b/consensus/types/src/attestation.rs index de0e86489da..85d442bff1e 100644 --- a/consensus/types/src/attestation.rs +++ b/consensus/types/src/attestation.rs @@ -46,34 +46,31 @@ impl From for Error { Encode, TestRandom, Derivative, - arbitrary::Arbitrary, TreeHash, ), context_deserialize(ForkName), derivative(PartialEq, Hash(bound = "E: EthSpec")), serde(bound = "E: EthSpec", deny_unknown_fields), - arbitrary(bound = "E: EthSpec"), + cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") + ) ), ref_attributes(derive(TreeHash), tree_hash(enum_behaviour = "transparent")), cast_error(ty = "Error", expr = "Error::IncorrectStateVariant"), partial_getter_error(ty = "Error", expr = "Error::IncorrectStateVariant") )] -#[derive( - Debug, - Clone, - Serialize, - TreeHash, - Encode, - Derivative, - Deserialize, - arbitrary::Arbitrary, - PartialEq, +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") )] +#[derive(Debug, Clone, Serialize, TreeHash, Encode, Derivative, Deserialize, PartialEq)] #[serde(untagged)] #[tree_hash(enum_behaviour = "transparent")] #[ssz(enum_behaviour = "transparent")] #[serde(bound = "E: EthSpec", deny_unknown_fields)] -#[arbitrary(bound = "E: EthSpec")] pub struct Attestation { #[superstruct(only(Base), partial_getter(rename = "aggregation_bits_base"))] pub aggregation_bits: BitList, @@ -601,6 +598,7 @@ impl<'de, E: EthSpec> ContextDeserialize<'de, ForkName> for Vec> } */ +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, Clone, @@ -610,7 +608,6 @@ impl<'de, E: EthSpec> ContextDeserialize<'de, ForkName> for Vec> Encode, TestRandom, Derivative, - arbitrary::Arbitrary, TreeHash, PartialEq, )] diff --git a/consensus/types/src/attestation_data.rs b/consensus/types/src/attestation_data.rs index d0d4dcc5538..26ca5f1aec9 100644 --- a/consensus/types/src/attestation_data.rs +++ b/consensus/types/src/attestation_data.rs @@ -9,8 +9,8 @@ use tree_hash_derive::TreeHash; /// The data upon which an attestation is based. /// /// Spec v0.12.1 +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, Debug, Clone, PartialEq, diff --git a/consensus/types/src/attestation_duty.rs b/consensus/types/src/attestation_duty.rs index 22b03dda61f..70c7c5c170f 100644 --- a/consensus/types/src/attestation_duty.rs +++ b/consensus/types/src/attestation_duty.rs @@ -1,7 +1,8 @@ use crate::*; use serde::{Deserialize, Serialize}; -#[derive(arbitrary::Arbitrary, Debug, PartialEq, Clone, Copy, Default, Serialize, Deserialize)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Debug, PartialEq, Clone, Copy, Default, Serialize, Deserialize)] pub struct AttestationDuty { /// The slot during which the attester must attest. pub slot: Slot, diff --git a/consensus/types/src/attester_slashing.rs b/consensus/types/src/attester_slashing.rs index f671a43c9c2..82611b6c7b6 100644 --- a/consensus/types/src/attester_slashing.rs +++ b/consensus/types/src/attester_slashing.rs @@ -25,21 +25,26 @@ use tree_hash_derive::TreeHash; Decode, TreeHash, TestRandom, - arbitrary::Arbitrary ), context_deserialize(ForkName), derivative(PartialEq, Eq, Hash(bound = "E: EthSpec")), serde(bound = "E: EthSpec"), - arbitrary(bound = "E: EthSpec") + cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") + ), ), ref_attributes(derive(Debug)) )] -#[derive( - Debug, Clone, Serialize, Encode, Deserialize, TreeHash, Derivative, arbitrary::Arbitrary, +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") )] +#[derive(Debug, Clone, Serialize, Encode, Deserialize, TreeHash, Derivative)] #[derivative(PartialEq, Eq, Hash(bound = "E: EthSpec"))] #[serde(bound = "E: EthSpec", untagged)] -#[arbitrary(bound = "E: EthSpec")] #[ssz(enum_behaviour = "transparent")] #[tree_hash(enum_behaviour = "transparent")] pub struct AttesterSlashing { diff --git a/consensus/types/src/beacon_block.rs b/consensus/types/src/beacon_block.rs index 9168a3feee0..6a2bb88d04b 100644 --- a/consensus/types/src/beacon_block.rs +++ b/consensus/types/src/beacon_block.rs @@ -28,14 +28,17 @@ use self::indexed_attestation::IndexedAttestationBase; TreeHash, TestRandom, Derivative, - arbitrary::Arbitrary ), derivative(PartialEq, Hash(bound = "E: EthSpec, Payload: AbstractExecPayload")), serde( bound = "E: EthSpec, Payload: AbstractExecPayload", deny_unknown_fields ), - arbitrary(bound = "E: EthSpec, Payload: AbstractExecPayload"), + cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec, Payload: AbstractExecPayload") + ) ), ref_attributes( derive(Debug, PartialEq, TreeHash), @@ -44,13 +47,15 @@ use self::indexed_attestation::IndexedAttestationBase; map_ref_into(BeaconBlockBodyRef, BeaconBlock), map_ref_mut_into(BeaconBlockBodyRefMut) )] -#[derive( - Debug, Clone, Serialize, Deserialize, Encode, TreeHash, Derivative, arbitrary::Arbitrary, +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec, Payload: AbstractExecPayload") )] +#[derive(Debug, Clone, Serialize, Deserialize, Encode, TreeHash, Derivative)] #[derivative(PartialEq, Hash(bound = "E: EthSpec"))] #[serde(untagged)] #[serde(bound = "E: EthSpec, Payload: AbstractExecPayload")] -#[arbitrary(bound = "E: EthSpec, Payload: AbstractExecPayload")] #[tree_hash(enum_behaviour = "transparent")] #[ssz(enum_behaviour = "transparent")] pub struct BeaconBlock = FullPayload> { diff --git a/consensus/types/src/beacon_block_body.rs b/consensus/types/src/beacon_block_body.rs index 4440c5cf256..dca9aa14c3c 100644 --- a/consensus/types/src/beacon_block_body.rs +++ b/consensus/types/src/beacon_block_body.rs @@ -40,14 +40,17 @@ pub const BLOB_KZG_COMMITMENTS_INDEX: usize = 11; TreeHash, TestRandom, Derivative, - arbitrary::Arbitrary ), derivative(PartialEq, Hash(bound = "E: EthSpec, Payload: AbstractExecPayload")), serde( bound = "E: EthSpec, Payload: AbstractExecPayload", deny_unknown_fields ), - arbitrary(bound = "E: EthSpec, Payload: AbstractExecPayload"), + cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec, Payload: AbstractExecPayload"), + ), context_deserialize(ForkName), ), specific_variant_attributes( @@ -62,12 +65,16 @@ pub const BLOB_KZG_COMMITMENTS_INDEX: usize = 11; cast_error(ty = "Error", expr = "Error::IncorrectStateVariant"), partial_getter_error(ty = "Error", expr = "Error::IncorrectStateVariant") )] -#[derive(Debug, Clone, Serialize, Deserialize, Derivative, TreeHash, arbitrary::Arbitrary)] +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec, Payload: AbstractExecPayload") +)] +#[derive(Debug, Clone, Serialize, Deserialize, Derivative, TreeHash)] #[derivative(PartialEq, Hash(bound = "E: EthSpec"))] #[serde(untagged)] #[serde(bound = "E: EthSpec, Payload: AbstractExecPayload")] #[tree_hash(enum_behaviour = "transparent")] -#[arbitrary(bound = "E: EthSpec, Payload: AbstractExecPayload")] pub struct BeaconBlockBody = FullPayload> { pub randao_reveal: Signature, pub eth1_data: Eth1Data, @@ -128,7 +135,7 @@ pub struct BeaconBlockBody = FullPay #[ssz(skip_serializing, skip_deserializing)] #[tree_hash(skip_hashing)] #[serde(skip)] - #[arbitrary(default)] + #[cfg_attr(feature = "arbitrary", arbitrary(default))] pub _phantom: PhantomData, } diff --git a/consensus/types/src/beacon_block_header.rs b/consensus/types/src/beacon_block_header.rs index 8416f975db2..7cdbd2eee18 100644 --- a/consensus/types/src/beacon_block_header.rs +++ b/consensus/types/src/beacon_block_header.rs @@ -11,19 +11,9 @@ use tree_hash_derive::TreeHash; /// A header of a `BeaconBlock`. /// /// Spec v0.12.1 +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - PartialEq, - Eq, - Hash, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] #[context_deserialize(ForkName)] pub struct BeaconBlockHeader { diff --git a/consensus/types/src/beacon_committee.rs b/consensus/types/src/beacon_committee.rs index bdb91cd6e68..04fe763a11b 100644 --- a/consensus/types/src/beacon_committee.rs +++ b/consensus/types/src/beacon_committee.rs @@ -17,7 +17,8 @@ impl BeaconCommittee<'_> { } } -#[derive(arbitrary::Arbitrary, Default, Clone, Debug, PartialEq)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Default, Clone, Debug, PartialEq)] pub struct OwnedBeaconCommittee { pub slot: Slot, pub index: CommitteeIndex, diff --git a/consensus/types/src/beacon_state.rs b/consensus/types/src/beacon_state.rs index 31bc9495831..bddfb6445af 100644 --- a/consensus/types/src/beacon_state.rs +++ b/consensus/types/src/beacon_state.rs @@ -191,7 +191,8 @@ impl AllowNextEpoch { } } -#[derive(PartialEq, Eq, Hash, Clone, Copy, arbitrary::Arbitrary)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(PartialEq, Eq, Hash, Clone, Copy)] pub struct BeaconStateHash(Hash256); impl fmt::Debug for BeaconStateHash { @@ -240,10 +241,13 @@ impl From for Hash256 { TreeHash, TestRandom, CompareFields, - arbitrary::Arbitrary, ), serde(bound = "E: EthSpec", deny_unknown_fields), - arbitrary(bound = "E: EthSpec"), + cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") + ), derivative(Clone), ), specific_variant_attributes( @@ -350,10 +354,14 @@ impl From for Hash256 { partial_getter_error(ty = "Error", expr = "Error::IncorrectStateVariant"), map_ref_mut_into(BeaconStateRef) )] -#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Encode, arbitrary::Arbitrary)] +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") +)] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Encode)] #[serde(untagged)] #[serde(bound = "E: EthSpec")] -#[arbitrary(bound = "E: EthSpec")] #[ssz(enum_behaviour = "transparent")] pub struct BeaconState where diff --git a/consensus/types/src/beacon_state/balance.rs b/consensus/types/src/beacon_state/balance.rs index e537a5b9842..cd449bdb828 100644 --- a/consensus/types/src/beacon_state/balance.rs +++ b/consensus/types/src/beacon_state/balance.rs @@ -1,10 +1,12 @@ +#[cfg(feature = "arbitrary")] use arbitrary::Arbitrary; use safe_arith::{ArithError, SafeArith}; /// A balance which will never be below the specified `minimum`. /// /// This is an effort to ensure the `EFFECTIVE_BALANCE_INCREMENT` minimum is always respected. -#[derive(PartialEq, Debug, Clone, Copy, Arbitrary)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(PartialEq, Debug, Clone, Copy)] pub struct Balance { raw: u64, minimum: u64, diff --git a/consensus/types/src/beacon_state/committee_cache.rs b/consensus/types/src/beacon_state/committee_cache.rs index e3fb339c877..513e538526b 100644 --- a/consensus/types/src/beacon_state/committee_cache.rs +++ b/consensus/types/src/beacon_state/committee_cache.rs @@ -374,6 +374,7 @@ where active } +#[cfg(feature = "arbitrary")] impl arbitrary::Arbitrary<'_> for CommitteeCache { fn arbitrary(_u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result { Ok(Self::default()) diff --git a/consensus/types/src/beacon_state/exit_cache.rs b/consensus/types/src/beacon_state/exit_cache.rs index 0bb984b6676..2828a6138c6 100644 --- a/consensus/types/src/beacon_state/exit_cache.rs +++ b/consensus/types/src/beacon_state/exit_cache.rs @@ -86,6 +86,7 @@ impl ExitCache { } } +#[cfg(feature = "arbitrary")] impl arbitrary::Arbitrary<'_> for ExitCache { fn arbitrary(_u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result { Ok(Self::default()) diff --git a/consensus/types/src/beacon_state/progressive_balances_cache.rs b/consensus/types/src/beacon_state/progressive_balances_cache.rs index 8e8a1a6aa94..019bf1c3d35 100644 --- a/consensus/types/src/beacon_state/progressive_balances_cache.rs +++ b/consensus/types/src/beacon_state/progressive_balances_cache.rs @@ -6,6 +6,7 @@ use crate::{ }, BeaconState, BeaconStateError, ChainSpec, Epoch, EthSpec, ParticipationFlags, }; +#[cfg(feature = "arbitrary")] use arbitrary::Arbitrary; use safe_arith::SafeArith; @@ -13,12 +14,14 @@ use safe_arith::SafeArith; /// epochs. The cached values can be utilised by fork choice to calculate unrealized justification /// and finalization instead of converting epoch participation arrays to balances for each block we /// process. -#[derive(Default, Debug, PartialEq, Arbitrary, Clone)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Default, Debug, PartialEq, Clone)] pub struct ProgressiveBalancesCache { inner: Option, } -#[derive(Debug, PartialEq, Arbitrary, Clone)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Debug, PartialEq, Clone)] struct Inner { pub current_epoch: Epoch, pub previous_epoch_cache: EpochTotalBalances, @@ -26,7 +29,8 @@ struct Inner { } /// Caches the participation values for one epoch (either the previous or current). -#[derive(PartialEq, Debug, Clone, Arbitrary)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(PartialEq, Debug, Clone)] pub struct EpochTotalBalances { /// Stores the sum of the balances for all validators in `self.unslashed_participating_indices` /// for all flags in `NUM_FLAG_INDICES`. diff --git a/consensus/types/src/beacon_state/pubkey_cache.rs b/consensus/types/src/beacon_state/pubkey_cache.rs index d58dd7bc1dd..85ed00340d7 100644 --- a/consensus/types/src/beacon_state/pubkey_cache.rs +++ b/consensus/types/src/beacon_state/pubkey_cache.rs @@ -43,6 +43,7 @@ impl PubkeyCache { } } +#[cfg(feature = "arbitrary")] impl arbitrary::Arbitrary<'_> for PubkeyCache { fn arbitrary(_u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result { Ok(Self::default()) diff --git a/consensus/types/src/beacon_state/slashings_cache.rs b/consensus/types/src/beacon_state/slashings_cache.rs index 45d8f7e2129..6530f795e9f 100644 --- a/consensus/types/src/beacon_state/slashings_cache.rs +++ b/consensus/types/src/beacon_state/slashings_cache.rs @@ -1,12 +1,14 @@ use crate::{BeaconStateError, Slot, Validator}; +#[cfg(feature = "arbitrary")] use arbitrary::Arbitrary; use rpds::HashTrieSetSync as HashTrieSet; /// Persistent (cheap to clone) cache of all slashed validator indices. -#[derive(Debug, Default, Clone, PartialEq, Arbitrary)] +#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] +#[derive(Debug, Default, Clone, PartialEq)] pub struct SlashingsCache { latest_block_slot: Option, - #[arbitrary(default)] + #[cfg_attr(feature = "arbitrary", arbitrary(default))] slashed_validators: HashTrieSet, } diff --git a/consensus/types/src/blob_sidecar.rs b/consensus/types/src/blob_sidecar.rs index f7a5725c5a0..dbe4360901f 100644 --- a/consensus/types/src/blob_sidecar.rs +++ b/consensus/types/src/blob_sidecar.rs @@ -44,21 +44,16 @@ impl Ord for BlobIdentifier { } } +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") +)] #[derive( - Debug, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, - Derivative, - arbitrary::Arbitrary, + Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, Derivative, )] #[context_deserialize(ForkName)] #[serde(bound = "E: EthSpec")] -#[arbitrary(bound = "E: EthSpec")] #[derivative(PartialEq, Eq, Hash(bound = "E: EthSpec"))] pub struct BlobSidecar { #[serde(with = "serde_utils::quoted_u64")] diff --git a/consensus/types/src/bls_to_execution_change.rs b/consensus/types/src/bls_to_execution_change.rs index b333862220d..72d737ac714 100644 --- a/consensus/types/src/bls_to_execution_change.rs +++ b/consensus/types/src/bls_to_execution_change.rs @@ -5,19 +5,9 @@ use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash_derive::TreeHash; +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - PartialEq, - Eq, - Hash, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] #[context_deserialize(ForkName)] pub struct BlsToExecutionChange { diff --git a/consensus/types/src/chain_spec.rs b/consensus/types/src/chain_spec.rs index 49537073b44..b6dafaeb00d 100644 --- a/consensus/types/src/chain_spec.rs +++ b/consensus/types/src/chain_spec.rs @@ -33,7 +33,8 @@ pub enum Domain { /// Lighthouse's internal configuration struct. /// /// Contains a mixture of "preset" and "config" values w.r.t to the EF definitions. -#[derive(arbitrary::Arbitrary, PartialEq, Debug, Clone)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(PartialEq, Debug, Clone)] pub struct ChainSpec { /* * Config name @@ -1459,7 +1460,8 @@ impl Default for ChainSpec { } } -#[derive(arbitrary::Arbitrary, Serialize, Deserialize, Debug, PartialEq, Clone)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] #[serde(rename_all = "UPPERCASE")] pub struct BlobParameters { pub epoch: Epoch, @@ -1469,7 +1471,8 @@ pub struct BlobParameters { // A wrapper around a vector of BlobParameters to ensure that the vector is reverse // sorted by epoch. -#[derive(arbitrary::Arbitrary, Debug, PartialEq, Clone)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Debug, PartialEq, Clone)] pub struct BlobSchedule(Vec); impl<'de> Deserialize<'de> for BlobSchedule { diff --git a/consensus/types/src/checkpoint.rs b/consensus/types/src/checkpoint.rs index c3cb1d5c36d..2bb1df51c01 100644 --- a/consensus/types/src/checkpoint.rs +++ b/consensus/types/src/checkpoint.rs @@ -9,8 +9,8 @@ use tree_hash_derive::TreeHash; /// Casper FFG checkpoint, used in attestations. /// /// Spec v0.12.1 +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, Debug, Clone, Copy, diff --git a/consensus/types/src/consolidation_request.rs b/consensus/types/src/consolidation_request.rs index c7375dab844..87098beaee1 100644 --- a/consensus/types/src/consolidation_request.rs +++ b/consensus/types/src/consolidation_request.rs @@ -6,19 +6,9 @@ use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash_derive::TreeHash; +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - PartialEq, - Eq, - Hash, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] #[context_deserialize(ForkName)] pub struct ConsolidationRequest { diff --git a/consensus/types/src/contribution_and_proof.rs b/consensus/types/src/contribution_and_proof.rs index e918beacb00..85c9ac15fb8 100644 --- a/consensus/types/src/contribution_and_proof.rs +++ b/consensus/types/src/contribution_and_proof.rs @@ -10,20 +10,14 @@ use test_random_derive::TestRandom; use tree_hash_derive::TreeHash; /// A Validators aggregate sync committee contribution and selection proof. -#[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - Decode, - TestRandom, - TreeHash, - arbitrary::Arbitrary, + +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") )] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TestRandom, TreeHash)] #[serde(bound = "E: EthSpec")] -#[arbitrary(bound = "E: EthSpec")] #[context_deserialize(ForkName)] pub struct ContributionAndProof { /// The index of the validator that created the sync contribution. diff --git a/consensus/types/src/data_column_sidecar.rs b/consensus/types/src/data_column_sidecar.rs index 612ddb6eb8d..14019563311 100644 --- a/consensus/types/src/data_column_sidecar.rs +++ b/consensus/types/src/data_column_sidecar.rs @@ -95,20 +95,15 @@ impl RuntimeVariableList { pub type DataColumnSidecarList = Vec>>; +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") +)] #[derive( - Debug, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, - Derivative, - arbitrary::Arbitrary, + Debug, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, Derivative, )] #[serde(bound = "E: EthSpec")] -#[arbitrary(bound = "E: EthSpec")] #[derivative(PartialEq, Eq, Hash(bound = "E: EthSpec"))] #[context_deserialize(ForkName)] pub struct DataColumnSidecar { diff --git a/consensus/types/src/data_column_subnet_id.rs b/consensus/types/src/data_column_subnet_id.rs index 5b3eef24ccc..3c3a1310e47 100644 --- a/consensus/types/src/data_column_subnet_id.rs +++ b/consensus/types/src/data_column_subnet_id.rs @@ -6,7 +6,8 @@ use serde::{Deserialize, Serialize}; use std::fmt::{self, Display}; use std::ops::{Deref, DerefMut}; -#[derive(arbitrary::Arbitrary, Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(transparent)] pub struct DataColumnSubnetId(#[serde(with = "serde_utils::quoted_u64")] u64); diff --git a/consensus/types/src/deposit.rs b/consensus/types/src/deposit.rs index 8b4b6af95dd..724f3de2f07 100644 --- a/consensus/types/src/deposit.rs +++ b/consensus/types/src/deposit.rs @@ -12,18 +12,9 @@ pub const DEPOSIT_TREE_DEPTH: usize = 32; /// A deposit to potentially become a beacon chain validator. /// /// Spec v0.12.1 +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - PartialEq, - Hash, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, PartialEq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] #[context_deserialize(ForkName)] pub struct Deposit { diff --git a/consensus/types/src/deposit_data.rs b/consensus/types/src/deposit_data.rs index d29e8c8d14a..3d9ae128088 100644 --- a/consensus/types/src/deposit_data.rs +++ b/consensus/types/src/deposit_data.rs @@ -8,18 +8,9 @@ use tree_hash_derive::TreeHash; /// The data supplied by the user to the deposit contract. /// /// Spec v0.12.1 +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - PartialEq, - Hash, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, PartialEq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] #[context_deserialize(ForkName)] pub struct DepositData { diff --git a/consensus/types/src/deposit_message.rs b/consensus/types/src/deposit_message.rs index 5c2a0b7c2bd..9fe3b878858 100644 --- a/consensus/types/src/deposit_message.rs +++ b/consensus/types/src/deposit_message.rs @@ -9,18 +9,8 @@ use tree_hash_derive::TreeHash; /// The data supplied by the user to the deposit contract. /// /// Spec v0.12.1 -#[derive( - arbitrary::Arbitrary, - Debug, - PartialEq, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, -)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom)] #[context_deserialize(ForkName)] pub struct DepositMessage { pub pubkey: PublicKeyBytes, diff --git a/consensus/types/src/deposit_request.rs b/consensus/types/src/deposit_request.rs index 141258b5ab6..16acfb3b443 100644 --- a/consensus/types/src/deposit_request.rs +++ b/consensus/types/src/deposit_request.rs @@ -8,18 +8,9 @@ use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash_derive::TreeHash; +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - PartialEq, - Hash, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, PartialEq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] #[context_deserialize(ForkName)] pub struct DepositRequest { diff --git a/consensus/types/src/enr_fork_id.rs b/consensus/types/src/enr_fork_id.rs index e3742cb96c1..40718380a5c 100644 --- a/consensus/types/src/enr_fork_id.rs +++ b/consensus/types/src/enr_fork_id.rs @@ -10,18 +10,9 @@ use tree_hash_derive::TreeHash; /// a nodes local ENR. /// /// Spec v0.11 +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - Clone, - PartialEq, - Default, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, Clone, PartialEq, Default, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] pub struct EnrForkId { /// Fork digest of the current fork computed from [`ChainSpec::compute_fork_digest`]. diff --git a/consensus/types/src/epoch_cache.rs b/consensus/types/src/epoch_cache.rs index b447e9b71e0..ef91c20d753 100644 --- a/consensus/types/src/epoch_cache.rs +++ b/consensus/types/src/epoch_cache.rs @@ -8,12 +8,14 @@ use std::sync::Arc; /// to as the "decision block". This cache is very similar to the `BeaconProposerCache` in that /// beacon proposers are determined at exactly the same time as the values in this cache, so /// the keys for the two caches are identical. -#[derive(Debug, PartialEq, Eq, Clone, Default, arbitrary::Arbitrary)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Debug, PartialEq, Eq, Clone, Default)] pub struct EpochCache { inner: Option>, } -#[derive(Debug, PartialEq, Eq, Clone, arbitrary::Arbitrary)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Debug, PartialEq, Eq, Clone)] struct Inner { /// Unique identifier for this cache, which can be used to check its validity before use /// with any `BeaconState`. @@ -30,7 +32,8 @@ struct Inner { effective_balance_increment: u64, } -#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, arbitrary::Arbitrary)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)] pub struct EpochCacheKey { pub epoch: Epoch, pub decision_block_root: Hash256, diff --git a/consensus/types/src/eth1_data.rs b/consensus/types/src/eth1_data.rs index 7bd0d3228d7..42de3ed806e 100644 --- a/consensus/types/src/eth1_data.rs +++ b/consensus/types/src/eth1_data.rs @@ -10,8 +10,8 @@ use tree_hash_derive::TreeHash; /// Contains data obtained from the Eth1 chain. /// /// Spec v0.12.1 +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, Debug, PartialEq, Clone, diff --git a/consensus/types/src/eth_spec.rs b/consensus/types/src/eth_spec.rs index bc87a4bd806..40006caf1ef 100644 --- a/consensus/types/src/eth_spec.rs +++ b/consensus/types/src/eth_spec.rs @@ -49,9 +49,7 @@ impl fmt::Display for EthSpecId { } } -pub trait EthSpec: - 'static + Default + Sync + Send + Clone + Debug + PartialEq + Eq + for<'a> arbitrary::Arbitrary<'a> -{ +pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq + Eq { /* * Constants */ @@ -394,7 +392,8 @@ macro_rules! params_from_eth_spec { } /// Ethereum Foundation specifications. -#[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize, arbitrary::Arbitrary)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize)] pub struct MainnetEthSpec; impl EthSpec for MainnetEthSpec { @@ -460,7 +459,8 @@ impl EthSpec for MainnetEthSpec { } /// Ethereum Foundation minimal spec, as defined in the eth2.0-specs repo. -#[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize, arbitrary::Arbitrary)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize)] pub struct MinimalEthSpec; impl EthSpec for MinimalEthSpec { @@ -529,7 +529,8 @@ impl EthSpec for MinimalEthSpec { } /// Gnosis Beacon Chain specifications. -#[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize, arbitrary::Arbitrary)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize)] pub struct GnosisEthSpec; impl EthSpec for GnosisEthSpec { diff --git a/consensus/types/src/execution_block_hash.rs b/consensus/types/src/execution_block_hash.rs index 6c031f68999..c1223a64f08 100644 --- a/consensus/types/src/execution_block_hash.rs +++ b/consensus/types/src/execution_block_hash.rs @@ -7,18 +7,8 @@ use serde::{Deserialize, Serialize}; use ssz::{Decode, DecodeError, Encode}; use std::fmt; -#[derive( - arbitrary::Arbitrary, - Default, - Clone, - Copy, - Serialize, - Deserialize, - Eq, - PartialEq, - Hash, - Derivative, -)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Default, Clone, Copy, Serialize, Deserialize, Eq, PartialEq, Hash, Derivative)] #[derivative(Debug = "transparent")] #[serde(transparent)] pub struct ExecutionBlockHash(#[serde(with = "serde_utils::b256_hex")] pub Hash256); diff --git a/consensus/types/src/execution_payload.rs b/consensus/types/src/execution_payload.rs index b4b06081505..17e3a49496e 100644 --- a/consensus/types/src/execution_payload.rs +++ b/consensus/types/src/execution_payload.rs @@ -28,24 +28,29 @@ pub type Withdrawals = VariableList::MaxWithdrawal TreeHash, TestRandom, Derivative, - arbitrary::Arbitrary ), context_deserialize(ForkName), derivative(PartialEq, Hash(bound = "E: EthSpec")), serde(bound = "E: EthSpec", deny_unknown_fields), - arbitrary(bound = "E: EthSpec") + cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec"), + ), ), cast_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"), partial_getter_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"), map_into(FullPayload, BlindedPayload), map_ref_into(ExecutionPayloadHeader) )] -#[derive( - Debug, Clone, Serialize, Deserialize, Encode, TreeHash, Derivative, arbitrary::Arbitrary, +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") )] +#[derive(Debug, Clone, Serialize, Deserialize, Encode, TreeHash, Derivative)] #[derivative(PartialEq, Hash(bound = "E: EthSpec"))] #[serde(bound = "E: EthSpec", untagged)] -#[arbitrary(bound = "E: EthSpec")] #[ssz(enum_behaviour = "transparent")] #[tree_hash(enum_behaviour = "transparent")] pub struct ExecutionPayload { diff --git a/consensus/types/src/execution_payload_header.rs b/consensus/types/src/execution_payload_header.rs index a16f29819d9..9abc6e9e32c 100644 --- a/consensus/types/src/execution_payload_header.rs +++ b/consensus/types/src/execution_payload_header.rs @@ -21,11 +21,14 @@ use tree_hash_derive::TreeHash; TreeHash, TestRandom, Derivative, - arbitrary::Arbitrary ), derivative(PartialEq, Hash(bound = "E: EthSpec")), serde(bound = "E: EthSpec", deny_unknown_fields), - arbitrary(bound = "E: EthSpec"), + cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec"), + ), context_deserialize(ForkName), ), ref_attributes( @@ -36,12 +39,14 @@ use tree_hash_derive::TreeHash; partial_getter_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"), map_ref_into(ExecutionPayloadHeader) )] -#[derive( - Debug, Clone, Serialize, Deserialize, Encode, TreeHash, Derivative, arbitrary::Arbitrary, +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") )] +#[derive(Debug, Clone, Serialize, Deserialize, Encode, TreeHash, Derivative)] #[derivative(PartialEq, Hash(bound = "E: EthSpec"))] #[serde(bound = "E: EthSpec", untagged)] -#[arbitrary(bound = "E: EthSpec")] #[tree_hash(enum_behaviour = "transparent")] #[ssz(enum_behaviour = "transparent")] pub struct ExecutionPayloadHeader { diff --git a/consensus/types/src/execution_requests.rs b/consensus/types/src/execution_requests.rs index 2fec3b5f665..592dda5d5e1 100644 --- a/consensus/types/src/execution_requests.rs +++ b/consensus/types/src/execution_requests.rs @@ -18,21 +18,15 @@ pub type WithdrawalRequests = pub type ConsolidationRequests = VariableList::MaxConsolidationRequestsPerPayload>; +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") +)] #[derive( - arbitrary::Arbitrary, - Debug, - Derivative, - Default, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, Derivative, Default, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] #[serde(bound = "E: EthSpec")] -#[arbitrary(bound = "E: EthSpec")] #[derivative(PartialEq, Eq, Hash(bound = "E: EthSpec"))] #[context_deserialize(ForkName)] pub struct ExecutionRequests { diff --git a/consensus/types/src/fork.rs b/consensus/types/src/fork.rs index 239ffe33c0e..19a137b1080 100644 --- a/consensus/types/src/fork.rs +++ b/consensus/types/src/fork.rs @@ -10,8 +10,8 @@ use tree_hash_derive::TreeHash; /// Specifies a fork of the `BeaconChain`, to prevent replay attacks. /// /// Spec v0.12.1 +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, Debug, Clone, Copy, diff --git a/consensus/types/src/fork_data.rs b/consensus/types/src/fork_data.rs index 1ac91084d22..7a4c07528a1 100644 --- a/consensus/types/src/fork_data.rs +++ b/consensus/types/src/fork_data.rs @@ -10,18 +10,9 @@ use tree_hash_derive::TreeHash; /// Specifies a fork of the `BeaconChain`, to prevent replay attacks. /// /// Spec v0.12.1 +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - Clone, - PartialEq, - Default, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, Clone, PartialEq, Default, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] #[context_deserialize(ForkName)] pub struct ForkData { diff --git a/consensus/types/src/graffiti.rs b/consensus/types/src/graffiti.rs index f781aacabdf..ae9fff50925 100644 --- a/consensus/types/src/graffiti.rs +++ b/consensus/types/src/graffiti.rs @@ -12,9 +12,9 @@ use tree_hash::{PackedEncoding, TreeHash}; pub const GRAFFITI_BYTES_LEN: usize = 32; /// The 32-byte `graffiti` field on a beacon block. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Default, Debug, PartialEq, Hash, Clone, Copy, Serialize, Deserialize)] #[serde(transparent)] -#[derive(arbitrary::Arbitrary)] pub struct Graffiti(#[serde(with = "serde_graffiti")] pub [u8; GRAFFITI_BYTES_LEN]); impl Graffiti { diff --git a/consensus/types/src/historical_batch.rs b/consensus/types/src/historical_batch.rs index 3a02810bba3..55377f24894 100644 --- a/consensus/types/src/historical_batch.rs +++ b/consensus/types/src/historical_batch.rs @@ -9,19 +9,12 @@ use tree_hash_derive::TreeHash; /// Historical block and state roots. /// /// Spec v0.12.1 -#[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, - arbitrary::Arbitrary, +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") )] -#[arbitrary(bound = "E: EthSpec")] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom)] #[context_deserialize(ForkName)] pub struct HistoricalBatch { #[test_random(default)] diff --git a/consensus/types/src/historical_summary.rs b/consensus/types/src/historical_summary.rs index 7ad423dadec..0aad2d903d7 100644 --- a/consensus/types/src/historical_summary.rs +++ b/consensus/types/src/historical_summary.rs @@ -13,6 +13,7 @@ use tree_hash_derive::TreeHash; /// in the Capella hard fork. /// /// https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#historicalsummary +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( Debug, PartialEq, @@ -27,7 +28,6 @@ use tree_hash_derive::TreeHash; Clone, Copy, Default, - arbitrary::Arbitrary, )] #[context_deserialize(ForkName)] pub struct HistoricalSummary { diff --git a/consensus/types/src/indexed_attestation.rs b/consensus/types/src/indexed_attestation.rs index ea65d785041..4526b165c81 100644 --- a/consensus/types/src/indexed_attestation.rs +++ b/consensus/types/src/indexed_attestation.rs @@ -29,31 +29,28 @@ use tree_hash_derive::TreeHash; Encode, TestRandom, Derivative, - arbitrary::Arbitrary, TreeHash, ), context_deserialize(ForkName), derivative(PartialEq, Hash(bound = "E: EthSpec")), serde(bound = "E: EthSpec", deny_unknown_fields), - arbitrary(bound = "E: EthSpec"), + cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec"), + ), ) )] -#[derive( - Debug, - Clone, - Serialize, - TreeHash, - Encode, - Derivative, - Deserialize, - arbitrary::Arbitrary, - PartialEq, +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") )] +#[derive(Debug, Clone, Serialize, TreeHash, Encode, Derivative, Deserialize, PartialEq)] #[serde(untagged)] #[tree_hash(enum_behaviour = "transparent")] #[ssz(enum_behaviour = "transparent")] #[serde(bound = "E: EthSpec", deny_unknown_fields)] -#[arbitrary(bound = "E: EthSpec")] pub struct IndexedAttestation { /// Lists validator registry indices, not committee indices. #[superstruct(only(Base), partial_getter(rename = "attesting_indices_base"))] diff --git a/consensus/types/src/light_client_bootstrap.rs b/consensus/types/src/light_client_bootstrap.rs index e82b34cc8cd..7e170365b2c 100644 --- a/consensus/types/src/light_client_bootstrap.rs +++ b/consensus/types/src/light_client_bootstrap.rs @@ -29,22 +29,27 @@ use tree_hash_derive::TreeHash; Decode, Encode, TestRandom, - arbitrary::Arbitrary, TreeHash, ), serde(bound = "E: EthSpec", deny_unknown_fields), - arbitrary(bound = "E: EthSpec"), + cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec"), + ), context_deserialize(ForkName), ) )] -#[derive( - Debug, Clone, Serialize, TreeHash, Encode, Deserialize, arbitrary::Arbitrary, PartialEq, +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") )] +#[derive(Debug, Clone, Serialize, TreeHash, Encode, Deserialize, PartialEq)] #[serde(untagged)] #[tree_hash(enum_behaviour = "transparent")] #[ssz(enum_behaviour = "transparent")] #[serde(bound = "E: EthSpec", deny_unknown_fields)] -#[arbitrary(bound = "E: EthSpec")] pub struct LightClientBootstrap { /// The requested beacon block header. #[superstruct(only(Altair), partial_getter(rename = "header_altair"))] diff --git a/consensus/types/src/light_client_finality_update.rs b/consensus/types/src/light_client_finality_update.rs index 2125b4668b4..0f572a856fc 100644 --- a/consensus/types/src/light_client_finality_update.rs +++ b/consensus/types/src/light_client_finality_update.rs @@ -28,20 +28,27 @@ use tree_hash_derive::TreeHash; Decode, Encode, TestRandom, - arbitrary::Arbitrary, TreeHash, ), serde(bound = "E: EthSpec", deny_unknown_fields), - arbitrary(bound = "E: EthSpec"), + cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec"), + ), context_deserialize(ForkName), ) )] -#[derive(Debug, Clone, Serialize, Encode, TreeHash, arbitrary::Arbitrary, PartialEq)] +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") +)] +#[derive(Debug, Clone, Serialize, Encode, TreeHash, PartialEq)] #[serde(untagged)] #[tree_hash(enum_behaviour = "transparent")] #[ssz(enum_behaviour = "transparent")] #[serde(bound = "E: EthSpec", deny_unknown_fields)] -#[arbitrary(bound = "E: EthSpec")] pub struct LightClientFinalityUpdate { /// The last `BeaconBlockHeader` from the last attested block by the sync committee. #[superstruct(only(Altair), partial_getter(rename = "attested_header_altair"))] diff --git a/consensus/types/src/light_client_header.rs b/consensus/types/src/light_client_header.rs index 36f2932ecd5..c36a1c2111d 100644 --- a/consensus/types/src/light_client_header.rs +++ b/consensus/types/src/light_client_header.rs @@ -30,20 +30,27 @@ use tree_hash_derive::TreeHash; Decode, Encode, TestRandom, - arbitrary::Arbitrary, TreeHash, ), serde(bound = "E: EthSpec", deny_unknown_fields), - arbitrary(bound = "E: EthSpec"), + cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec"), + ), context_deserialize(ForkName), ) )] -#[derive(Debug, Clone, Serialize, TreeHash, Encode, arbitrary::Arbitrary, PartialEq)] +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") +)] +#[derive(Debug, Clone, Serialize, TreeHash, Encode, PartialEq)] #[serde(untagged)] #[tree_hash(enum_behaviour = "transparent")] #[ssz(enum_behaviour = "transparent")] #[serde(bound = "E: EthSpec", deny_unknown_fields)] -#[arbitrary(bound = "E: EthSpec")] pub struct LightClientHeader { pub beacon: BeaconBlockHeader, @@ -68,7 +75,7 @@ pub struct LightClientHeader { #[ssz(skip_serializing, skip_deserializing)] #[tree_hash(skip_hashing)] #[serde(skip)] - #[arbitrary(default)] + #[cfg_attr(feature = "arbitrary", arbitrary(default))] pub _phantom_data: PhantomData, } diff --git a/consensus/types/src/light_client_optimistic_update.rs b/consensus/types/src/light_client_optimistic_update.rs index 13e308cd278..1bff0df0614 100644 --- a/consensus/types/src/light_client_optimistic_update.rs +++ b/consensus/types/src/light_client_optimistic_update.rs @@ -31,20 +31,27 @@ use tree_hash_derive::TreeHash; Decode, Encode, TestRandom, - arbitrary::Arbitrary, TreeHash, ), serde(bound = "E: EthSpec", deny_unknown_fields), - arbitrary(bound = "E: EthSpec"), + cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec"), + ), context_deserialize(ForkName), ) )] -#[derive(Debug, Clone, Serialize, Encode, TreeHash, arbitrary::Arbitrary, PartialEq)] +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") +)] +#[derive(Debug, Clone, Serialize, Encode, TreeHash, PartialEq)] #[serde(untagged)] #[tree_hash(enum_behaviour = "transparent")] #[ssz(enum_behaviour = "transparent")] #[serde(bound = "E: EthSpec", deny_unknown_fields)] -#[arbitrary(bound = "E: EthSpec")] pub struct LightClientOptimisticUpdate { /// The last `BeaconBlockHeader` from the last attested block by the sync committee. #[superstruct(only(Altair), partial_getter(rename = "attested_header_altair"))] diff --git a/consensus/types/src/light_client_update.rs b/consensus/types/src/light_client_update.rs index 92aeeb33bb9..87976dbedb5 100644 --- a/consensus/types/src/light_client_update.rs +++ b/consensus/types/src/light_client_update.rs @@ -112,20 +112,27 @@ impl From for Error { Decode, Encode, TestRandom, - arbitrary::Arbitrary, TreeHash, ), serde(bound = "E: EthSpec", deny_unknown_fields), - arbitrary(bound = "E: EthSpec"), + cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec"), + ), context_deserialize(ForkName), ) )] -#[derive(Debug, Clone, Serialize, Encode, TreeHash, arbitrary::Arbitrary, PartialEq)] +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") +)] +#[derive(Debug, Clone, Serialize, Encode, TreeHash, PartialEq)] #[serde(untagged)] #[tree_hash(enum_behaviour = "transparent")] #[ssz(enum_behaviour = "transparent")] #[serde(bound = "E: EthSpec", deny_unknown_fields)] -#[arbitrary(bound = "E: EthSpec")] pub struct LightClientUpdate { /// The last `BeaconBlockHeader` from the last attested block by the sync committee. #[superstruct(only(Altair), partial_getter(rename = "attested_header_altair"))] diff --git a/consensus/types/src/participation_flags.rs b/consensus/types/src/participation_flags.rs index e94e56f0cde..3e29ca83e80 100644 --- a/consensus/types/src/participation_flags.rs +++ b/consensus/types/src/participation_flags.rs @@ -7,7 +7,7 @@ use tree_hash::{PackedEncoding, TreeHash, TreeHashType}; #[derive(Debug, Default, Clone, Copy, PartialEq, Deserialize, Serialize, TestRandom)] #[serde(transparent)] -#[derive(arbitrary::Arbitrary)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub struct ParticipationFlags { #[serde(with = "serde_utils::quoted_u8")] bits: u8, diff --git a/consensus/types/src/payload.rs b/consensus/types/src/payload.rs index c0262a2cf84..1f7edfcacaa 100644 --- a/consensus/types/src/payload.rs +++ b/consensus/types/src/payload.rs @@ -49,6 +49,7 @@ pub trait ExecPayload: Debug + Clone + PartialEq + Hash + TreeHash + } /// `ExecPayload` functionality the requires ownership. +#[cfg(feature = "arbitrary")] pub trait OwnedExecPayload: ExecPayload + Default @@ -61,7 +62,7 @@ pub trait OwnedExecPayload: + 'static { } - +#[cfg(feature = "arbitrary")] impl OwnedExecPayload for P where P: ExecPayload + Default @@ -75,6 +76,25 @@ impl OwnedExecPayload for P where { } +/// `ExecPayload` functionality the requires ownership. +#[cfg(not(feature = "arbitrary"))] +pub trait OwnedExecPayload: + ExecPayload + Default + Serialize + DeserializeOwned + Encode + Decode + TestRandom + 'static +{ +} +#[cfg(not(feature = "arbitrary"))] +impl OwnedExecPayload for P where + P: ExecPayload + + Default + + Serialize + + DeserializeOwned + + Encode + + Decode + + TestRandom + + 'static +{ +} + pub trait AbstractExecPayload: ExecPayload + Sized @@ -135,11 +155,14 @@ pub trait AbstractExecPayload: TestRandom, TreeHash, Derivative, - arbitrary::Arbitrary, ), derivative(PartialEq, Hash(bound = "E: EthSpec")), serde(bound = "E: EthSpec", deny_unknown_fields), - arbitrary(bound = "E: EthSpec"), + cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec"), + ), ssz(struct_behaviour = "transparent"), ), ref_attributes( @@ -152,10 +175,14 @@ pub trait AbstractExecPayload: cast_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"), partial_getter_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant") )] -#[derive(Debug, Clone, Serialize, Deserialize, TreeHash, Derivative, arbitrary::Arbitrary)] +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") +)] +#[derive(Debug, Clone, Serialize, Deserialize, TreeHash, Derivative)] #[derivative(PartialEq, Hash(bound = "E: EthSpec"))] #[serde(bound = "E: EthSpec")] -#[arbitrary(bound = "E: EthSpec")] #[tree_hash(enum_behaviour = "transparent")] pub struct FullPayload { #[superstruct( @@ -496,11 +523,14 @@ impl TryFrom> for FullPayload { TestRandom, TreeHash, Derivative, - arbitrary::Arbitrary ), derivative(PartialEq, Hash(bound = "E: EthSpec")), serde(bound = "E: EthSpec", deny_unknown_fields), - arbitrary(bound = "E: EthSpec"), + cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec"), + ), ssz(struct_behaviour = "transparent"), ), ref_attributes( @@ -512,10 +542,14 @@ impl TryFrom> for FullPayload { cast_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant"), partial_getter_error(ty = "Error", expr = "BeaconStateError::IncorrectStateVariant") )] -#[derive(Debug, Clone, Serialize, Deserialize, TreeHash, Derivative, arbitrary::Arbitrary)] +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") +)] +#[derive(Debug, Clone, Serialize, Deserialize, TreeHash, Derivative)] #[derivative(PartialEq, Hash(bound = "E: EthSpec"))] #[serde(bound = "E: EthSpec")] -#[arbitrary(bound = "E: EthSpec")] #[tree_hash(enum_behaviour = "transparent")] pub struct BlindedPayload { #[superstruct( diff --git a/consensus/types/src/pending_attestation.rs b/consensus/types/src/pending_attestation.rs index b7b4a19f4bb..4a00a0495ac 100644 --- a/consensus/types/src/pending_attestation.rs +++ b/consensus/types/src/pending_attestation.rs @@ -9,19 +9,12 @@ use tree_hash_derive::TreeHash; /// An attestation that has been included in the state but not yet fully processed. /// /// Spec v0.12.1 -#[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, - arbitrary::Arbitrary, +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") )] -#[arbitrary(bound = "E: EthSpec")] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom)] #[context_deserialize(ForkName)] pub struct PendingAttestation { pub aggregation_bits: BitList, diff --git a/consensus/types/src/pending_consolidation.rs b/consensus/types/src/pending_consolidation.rs index 9a513f2744a..4072c155645 100644 --- a/consensus/types/src/pending_consolidation.rs +++ b/consensus/types/src/pending_consolidation.rs @@ -6,19 +6,9 @@ use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash_derive::TreeHash; +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - PartialEq, - Eq, - Hash, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] #[context_deserialize(ForkName)] pub struct PendingConsolidation { diff --git a/consensus/types/src/pending_deposit.rs b/consensus/types/src/pending_deposit.rs index 970c3264677..4a921edd549 100644 --- a/consensus/types/src/pending_deposit.rs +++ b/consensus/types/src/pending_deposit.rs @@ -5,18 +5,9 @@ use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash_derive::TreeHash; +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - PartialEq, - Hash, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, PartialEq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] #[context_deserialize(ForkName)] pub struct PendingDeposit { diff --git a/consensus/types/src/pending_partial_withdrawal.rs b/consensus/types/src/pending_partial_withdrawal.rs index ca490328592..e9b10f79b5f 100644 --- a/consensus/types/src/pending_partial_withdrawal.rs +++ b/consensus/types/src/pending_partial_withdrawal.rs @@ -6,19 +6,9 @@ use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash_derive::TreeHash; +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - PartialEq, - Eq, - Hash, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] #[context_deserialize(ForkName)] pub struct PendingPartialWithdrawal { diff --git a/consensus/types/src/proposer_slashing.rs b/consensus/types/src/proposer_slashing.rs index 7b03dbb83ed..f4d914c1e59 100644 --- a/consensus/types/src/proposer_slashing.rs +++ b/consensus/types/src/proposer_slashing.rs @@ -10,19 +10,9 @@ use tree_hash_derive::TreeHash; /// Two conflicting proposals from the same proposer (validator). /// /// Spec v0.12.1 +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - PartialEq, - Eq, - Hash, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] #[context_deserialize(ForkName)] pub struct ProposerSlashing { diff --git a/consensus/types/src/relative_epoch.rs b/consensus/types/src/relative_epoch.rs index 77a46b56e86..2fa0ae41bda 100644 --- a/consensus/types/src/relative_epoch.rs +++ b/consensus/types/src/relative_epoch.rs @@ -18,7 +18,8 @@ impl From for Error { /// to and following some epoch. /// /// Spec v0.12.1 -#[derive(Debug, PartialEq, Clone, Copy, arbitrary::Arbitrary)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Debug, PartialEq, Clone, Copy)] pub enum RelativeEpoch { /// The prior epoch. Previous, diff --git a/consensus/types/src/selection_proof.rs b/consensus/types/src/selection_proof.rs index c80a00c3d1f..e471457c250 100644 --- a/consensus/types/src/selection_proof.rs +++ b/consensus/types/src/selection_proof.rs @@ -6,7 +6,8 @@ use safe_arith::{ArithError, SafeArith}; use ssz::Encode; use std::cmp; -#[derive(arbitrary::Arbitrary, PartialEq, Debug, Clone)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(PartialEq, Debug, Clone)] pub struct SelectionProof(Signature); impl SelectionProof { diff --git a/consensus/types/src/signed_aggregate_and_proof.rs b/consensus/types/src/signed_aggregate_and_proof.rs index 7b1f97e5218..758ac2734b7 100644 --- a/consensus/types/src/signed_aggregate_and_proof.rs +++ b/consensus/types/src/signed_aggregate_and_proof.rs @@ -21,7 +21,6 @@ use tree_hash_derive::TreeHash; variants(Base, Electra), variant_attributes( derive( - arbitrary::Arbitrary, Debug, Clone, PartialEq, @@ -34,19 +33,25 @@ use tree_hash_derive::TreeHash; ), context_deserialize(ForkName), serde(bound = "E: EthSpec"), - arbitrary(bound = "E: EthSpec"), + cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec"), + ), ), map_into(Attestation), map_ref_into(AggregateAndProofRef) )] -#[derive( - arbitrary::Arbitrary, Debug, Clone, PartialEq, Serialize, Deserialize, Encode, TreeHash, +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") )] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, TreeHash)] #[serde(untagged)] #[tree_hash(enum_behaviour = "transparent")] #[ssz(enum_behaviour = "transparent")] #[serde(bound = "E: EthSpec", deny_unknown_fields)] -#[arbitrary(bound = "E: EthSpec")] pub struct SignedAggregateAndProof { /// The `AggregateAndProof` that was signed. #[superstruct(flatten)] diff --git a/consensus/types/src/signed_beacon_block.rs b/consensus/types/src/signed_beacon_block.rs index 64dce93aefb..4a0a8c6ead0 100644 --- a/consensus/types/src/signed_beacon_block.rs +++ b/consensus/types/src/signed_beacon_block.rs @@ -11,7 +11,8 @@ use test_random_derive::TestRandom; use tree_hash::TreeHash; use tree_hash_derive::TreeHash; -#[derive(arbitrary::Arbitrary, PartialEq, Eq, Hash, Clone, Copy)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(PartialEq, Eq, Hash, Clone, Copy)] pub struct SignedBeaconBlockHash(Hash256); impl fmt::Debug for SignedBeaconBlockHash { @@ -51,24 +52,29 @@ impl From for Hash256 { Decode, TreeHash, Derivative, - arbitrary::Arbitrary, TestRandom ), derivative(PartialEq, Hash(bound = "E: EthSpec")), serde(bound = "E: EthSpec, Payload: AbstractExecPayload"), - arbitrary(bound = "E: EthSpec, Payload: AbstractExecPayload"), + cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec, Payload: AbstractExecPayload"), + ), ), map_into(BeaconBlock), map_ref_into(BeaconBlockRef), map_ref_mut_into(BeaconBlockRefMut) )] -#[derive( - Debug, Clone, Serialize, Deserialize, Encode, TreeHash, Derivative, arbitrary::Arbitrary, +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec, Payload: AbstractExecPayload") )] +#[derive(Debug, Clone, Serialize, Deserialize, Encode, TreeHash, Derivative)] #[derivative(PartialEq, Hash(bound = "E: EthSpec"))] #[serde(untagged)] #[serde(bound = "E: EthSpec, Payload: AbstractExecPayload")] -#[arbitrary(bound = "E: EthSpec, Payload: AbstractExecPayload")] #[tree_hash(enum_behaviour = "transparent")] #[ssz(enum_behaviour = "transparent")] pub struct SignedBeaconBlock = FullPayload> { diff --git a/consensus/types/src/signed_beacon_block_header.rs b/consensus/types/src/signed_beacon_block_header.rs index 9106fa83724..77ca96b2a72 100644 --- a/consensus/types/src/signed_beacon_block_header.rs +++ b/consensus/types/src/signed_beacon_block_header.rs @@ -11,19 +11,9 @@ use tree_hash_derive::TreeHash; /// A signed header of a `BeaconBlock`. /// /// Spec v0.12.1 +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - Clone, - PartialEq, - Eq, - Hash, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] #[context_deserialize(ForkName)] pub struct SignedBeaconBlockHeader { diff --git a/consensus/types/src/signed_bls_to_execution_change.rs b/consensus/types/src/signed_bls_to_execution_change.rs index 383663e36b8..910c4c7d7ef 100644 --- a/consensus/types/src/signed_bls_to_execution_change.rs +++ b/consensus/types/src/signed_bls_to_execution_change.rs @@ -5,19 +5,9 @@ use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash_derive::TreeHash; +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - PartialEq, - Eq, - Hash, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] #[context_deserialize(ForkName)] pub struct SignedBlsToExecutionChange { diff --git a/consensus/types/src/signed_contribution_and_proof.rs b/consensus/types/src/signed_contribution_and_proof.rs index 42115bfbc06..51c453d32ff 100644 --- a/consensus/types/src/signed_contribution_and_proof.rs +++ b/consensus/types/src/signed_contribution_and_proof.rs @@ -11,20 +11,13 @@ use tree_hash_derive::TreeHash; /// A Validators signed contribution proof to publish on the `sync_committee_contribution_and_proof` /// gossipsub topic. -#[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - Decode, - TestRandom, - TreeHash, - arbitrary::Arbitrary, +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") )] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TestRandom, TreeHash)] #[serde(bound = "E: EthSpec")] -#[arbitrary(bound = "E: EthSpec")] #[context_deserialize(ForkName)] pub struct SignedContributionAndProof { /// The `ContributionAndProof` that was signed. diff --git a/consensus/types/src/signed_voluntary_exit.rs b/consensus/types/src/signed_voluntary_exit.rs index b6451d3ab5e..02213ed3117 100644 --- a/consensus/types/src/signed_voluntary_exit.rs +++ b/consensus/types/src/signed_voluntary_exit.rs @@ -10,18 +10,9 @@ use tree_hash_derive::TreeHash; /// An exit voluntarily submitted a validator who wishes to withdraw. /// /// Spec v0.12.1 +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - PartialEq, - Hash, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, PartialEq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] #[context_deserialize(ForkName)] pub struct SignedVoluntaryExit { diff --git a/consensus/types/src/signing_data.rs b/consensus/types/src/signing_data.rs index aa25ecffd92..69b7dabfe5a 100644 --- a/consensus/types/src/signing_data.rs +++ b/consensus/types/src/signing_data.rs @@ -8,18 +8,8 @@ use test_random_derive::TestRandom; use tree_hash::TreeHash; use tree_hash_derive::TreeHash; -#[derive( - arbitrary::Arbitrary, - Debug, - PartialEq, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, -)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom)] #[context_deserialize(ForkName)] pub struct SigningData { pub object_root: Hash256, diff --git a/consensus/types/src/slot_epoch.rs b/consensus/types/src/slot_epoch.rs index 66790a9641f..857044f9816 100644 --- a/consensus/types/src/slot_epoch.rs +++ b/consensus/types/src/slot_epoch.rs @@ -23,35 +23,13 @@ use std::hash::Hash; #[cfg(feature = "legacy-arith")] use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, Sub, SubAssign}; -#[derive( - arbitrary::Arbitrary, - Clone, - Copy, - Default, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - Serialize, - Deserialize, -)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[serde(transparent)] pub struct Slot(#[serde(with = "serde_utils::quoted_u64")] u64); -#[derive( - arbitrary::Arbitrary, - Clone, - Copy, - Default, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - Serialize, - Deserialize, -)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[serde(transparent)] pub struct Epoch(#[serde(with = "serde_utils::quoted_u64")] u64); diff --git a/consensus/types/src/subnet_id.rs b/consensus/types/src/subnet_id.rs index 7a5357c6cc5..7289a817a34 100644 --- a/consensus/types/src/subnet_id.rs +++ b/consensus/types/src/subnet_id.rs @@ -22,7 +22,8 @@ static SUBNET_ID_TO_STRING: LazyLock> = LazyLock::new(|| { v }); -#[derive(arbitrary::Arbitrary, Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(transparent)] pub struct SubnetId(#[serde(with = "serde_utils::quoted_u64")] u64); diff --git a/consensus/types/src/sync_aggregate.rs b/consensus/types/src/sync_aggregate.rs index 4f810db22ae..7a4ef8f026a 100644 --- a/consensus/types/src/sync_aggregate.rs +++ b/consensus/types/src/sync_aggregate.rs @@ -21,22 +21,16 @@ impl From for Error { Error::ArithError(e) } } - +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") +)] #[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 = "E: EthSpec"))] #[serde(bound = "E: EthSpec")] -#[arbitrary(bound = "E: EthSpec")] #[context_deserialize(ForkName)] pub struct SyncAggregate { pub sync_committee_bits: BitVector, diff --git a/consensus/types/src/sync_aggregator_selection_data.rs b/consensus/types/src/sync_aggregator_selection_data.rs index a61cd47d04a..a280369fea3 100644 --- a/consensus/types/src/sync_aggregator_selection_data.rs +++ b/consensus/types/src/sync_aggregator_selection_data.rs @@ -6,18 +6,9 @@ use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash_derive::TreeHash; +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - PartialEq, - Clone, - Serialize, - Deserialize, - Hash, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, PartialEq, Clone, Serialize, Deserialize, Hash, Encode, Decode, TreeHash, TestRandom, )] #[context_deserialize(ForkName)] pub struct SyncAggregatorSelectionData { diff --git a/consensus/types/src/sync_committee.rs b/consensus/types/src/sync_committee.rs index c7ec7bdcc3f..a9fde425540 100644 --- a/consensus/types/src/sync_committee.rs +++ b/consensus/types/src/sync_committee.rs @@ -25,20 +25,13 @@ impl From for Error { } } -#[derive( - Debug, - PartialEq, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, - arbitrary::Arbitrary, +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") )] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom)] #[serde(bound = "E: EthSpec")] -#[arbitrary(bound = "E: EthSpec")] #[context_deserialize(ForkName)] pub struct SyncCommittee { pub pubkeys: FixedVector, diff --git a/consensus/types/src/sync_committee_contribution.rs b/consensus/types/src/sync_committee_contribution.rs index e2ac414cfa7..bad7797e301 100644 --- a/consensus/types/src/sync_committee_contribution.rs +++ b/consensus/types/src/sync_committee_contribution.rs @@ -15,20 +15,13 @@ pub enum Error { } /// An aggregation of `SyncCommitteeMessage`s, used in creating a `SignedContributionAndProof`. -#[derive( - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, - arbitrary::Arbitrary, +#[cfg_attr( + feature = "arbitrary", + derive(arbitrary::Arbitrary), + arbitrary(bound = "E: EthSpec") )] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom)] #[serde(bound = "E: EthSpec")] -#[arbitrary(bound = "E: EthSpec")] #[context_deserialize(ForkName)] pub struct SyncCommitteeContribution { pub slot: Slot, diff --git a/consensus/types/src/sync_committee_message.rs b/consensus/types/src/sync_committee_message.rs index 4b442b30539..d5bb7250bb4 100644 --- a/consensus/types/src/sync_committee_message.rs +++ b/consensus/types/src/sync_committee_message.rs @@ -10,18 +10,8 @@ use test_random_derive::TestRandom; use tree_hash_derive::TreeHash; /// The data upon which a `SyncCommitteeContribution` is based. -#[derive( - arbitrary::Arbitrary, - Debug, - Clone, - PartialEq, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, -)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom)] #[context_deserialize(ForkName)] pub struct SyncCommitteeMessage { pub slot: Slot, diff --git a/consensus/types/src/sync_selection_proof.rs b/consensus/types/src/sync_selection_proof.rs index 4adb90b26e2..6387212d94f 100644 --- a/consensus/types/src/sync_selection_proof.rs +++ b/consensus/types/src/sync_selection_proof.rs @@ -11,7 +11,8 @@ use ssz::Encode; use ssz_types::typenum::Unsigned; use std::cmp; -#[derive(arbitrary::Arbitrary, PartialEq, Debug, Clone)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(PartialEq, Debug, Clone)] pub struct SyncSelectionProof(Signature); impl SyncSelectionProof { diff --git a/consensus/types/src/sync_subnet_id.rs b/consensus/types/src/sync_subnet_id.rs index 245ac5a6c4b..1ce7d0c13f3 100644 --- a/consensus/types/src/sync_subnet_id.rs +++ b/consensus/types/src/sync_subnet_id.rs @@ -18,7 +18,8 @@ static SYNC_SUBNET_ID_TO_STRING: LazyLock> = LazyLock::new(|| { v }); -#[derive(arbitrary::Arbitrary, Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(transparent)] pub struct SyncSubnetId(#[serde(with = "serde_utils::quoted_u64")] u64); diff --git a/consensus/types/src/validator.rs b/consensus/types/src/validator.rs index 165f477ff46..dc97c8821b4 100644 --- a/consensus/types/src/validator.rs +++ b/consensus/types/src/validator.rs @@ -11,18 +11,9 @@ use tree_hash_derive::TreeHash; /// Information about a `BeaconChain` validator. /// /// Spec v0.12.1 +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - Clone, - PartialEq, - Eq, - Serialize, - Deserialize, - Encode, - Decode, - TestRandom, - TreeHash, + Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Encode, Decode, TestRandom, TreeHash, )] #[context_deserialize(ForkName)] pub struct Validator { diff --git a/consensus/types/src/voluntary_exit.rs b/consensus/types/src/voluntary_exit.rs index 75260add4b5..60900350385 100644 --- a/consensus/types/src/voluntary_exit.rs +++ b/consensus/types/src/voluntary_exit.rs @@ -12,18 +12,9 @@ use tree_hash_derive::TreeHash; /// An exit voluntarily submitted a validator who wishes to withdraw. /// /// Spec v0.12.1 +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - PartialEq, - Hash, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, PartialEq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] #[context_deserialize(ForkName)] pub struct VoluntaryExit { diff --git a/consensus/types/src/withdrawal.rs b/consensus/types/src/withdrawal.rs index 9ca50fccfbd..ef4a1f285d3 100644 --- a/consensus/types/src/withdrawal.rs +++ b/consensus/types/src/withdrawal.rs @@ -5,19 +5,9 @@ use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash_derive::TreeHash; +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - PartialEq, - Eq, - Hash, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] #[context_deserialize(ForkName)] pub struct Withdrawal { diff --git a/consensus/types/src/withdrawal_request.rs b/consensus/types/src/withdrawal_request.rs index 57c6e798eb4..c08921a68c4 100644 --- a/consensus/types/src/withdrawal_request.rs +++ b/consensus/types/src/withdrawal_request.rs @@ -7,19 +7,9 @@ use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash_derive::TreeHash; +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive( - arbitrary::Arbitrary, - Debug, - PartialEq, - Eq, - Hash, - Clone, - Serialize, - Deserialize, - Encode, - Decode, - TreeHash, - TestRandom, + Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, Encode, Decode, TreeHash, TestRandom, )] #[context_deserialize(ForkName)] pub struct WithdrawalRequest { diff --git a/lighthouse/Cargo.toml b/lighthouse/Cargo.toml index 6a8fa00c1e0..1283396af32 100644 --- a/lighthouse/Cargo.toml +++ b/lighthouse/Cargo.toml @@ -4,7 +4,7 @@ version = "7.1.0" authors = ["Sigma Prime "] edition = { workspace = true } autotests = false -rust-version = "1.83.0" +rust-version = "1.87.0" # Prevent cargo-udeps from flagging the dummy package `target_check`, which exists only # to assert properties of the compilation target.