Feature-gate all uses of arbitrary (#8867)

Feature gate all uses of `arbitrary` so it is not compiled during release builds.


Co-Authored-By: Mac L <mjladson@pm.me>
This commit is contained in:
Mac L
2026-02-19 23:32:46 +04:00
committed by GitHub
parent 2d91009ab4
commit 9cb72100d4
9 changed files with 22 additions and 10 deletions

View File

@@ -8,6 +8,8 @@ edition = { workspace = true }
default = []
fake_crypto = ["bls/fake_crypto"]
arbitrary-fuzz = [
"dep:arbitrary",
"smallvec/arbitrary",
"types/arbitrary-fuzz",
"merkle_proof/arbitrary",
"ethereum_ssz/arbitrary",
@@ -17,7 +19,7 @@ arbitrary-fuzz = [
portable = ["bls/supranational-portable"]
[dependencies]
arbitrary = { workspace = true }
arbitrary = { workspace = true, optional = true }
bls = { workspace = true }
educe = { workspace = true }
ethereum_hashing = { workspace = true }

View File

@@ -7,6 +7,7 @@ use crate::per_block_processing::{
verify_attester_slashing, verify_bls_to_execution_change, verify_exit,
verify_proposer_slashing,
};
#[cfg(feature = "arbitrary-fuzz")]
use arbitrary::Arbitrary;
use educe::Educe;
use smallvec::{SmallVec, smallvec};
@@ -39,13 +40,17 @@ pub trait TransformPersist {
///
/// The inner `op` field is private, meaning instances of this type can only be constructed
/// by calling `validate`.
#[derive(Educe, Debug, Clone, Arbitrary)]
#[derive(Educe, Debug, Clone)]
#[cfg_attr(feature = "arbitrary-fuzz", derive(Arbitrary))]
#[educe(
PartialEq,
Eq,
Hash(bound(T: TransformPersist + std::hash::Hash, E: EthSpec))
)]
#[arbitrary(bound = "T: TransformPersist + Arbitrary<'arbitrary>, E: EthSpec")]
#[cfg_attr(
feature = "arbitrary-fuzz",
arbitrary(bound = "T: TransformPersist + Arbitrary<'arbitrary>, E: EthSpec")
)]
pub struct SigVerifiedOp<T: TransformPersist, E: EthSpec> {
op: T,
verified_against: VerifiedAgainst,
@@ -133,7 +138,8 @@ struct SigVerifiedOpDecode<P: Decode> {
///
/// We need to store multiple `ForkVersion`s because attester slashings contain two indexed
/// attestations which may be signed using different versions.
#[derive(Debug, PartialEq, Eq, Clone, Hash, Encode, Decode, TestRandom, Arbitrary)]
#[derive(Debug, PartialEq, Eq, Clone, Hash, Encode, Decode, TestRandom)]
#[cfg_attr(feature = "arbitrary-fuzz", derive(Arbitrary))]
pub struct VerifiedAgainst {
fork_versions: SmallVec<[ForkVersion; MAX_FORKS_VERIFIED_AGAINST]>,
}