mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
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:
@@ -240,7 +240,7 @@ signing_method = { path = "validator_client/signing_method" }
|
|||||||
slasher = { path = "slasher", default-features = false }
|
slasher = { path = "slasher", default-features = false }
|
||||||
slashing_protection = { path = "validator_client/slashing_protection" }
|
slashing_protection = { path = "validator_client/slashing_protection" }
|
||||||
slot_clock = { path = "common/slot_clock" }
|
slot_clock = { path = "common/slot_clock" }
|
||||||
smallvec = { version = "1.11.2", features = ["arbitrary"] }
|
smallvec = "1"
|
||||||
snap = "1"
|
snap = "1"
|
||||||
ssz_types = { version = "0.14.0", features = ["context_deserialize", "runtime_types"] }
|
ssz_types = { version = "0.14.0", features = ["context_deserialize", "runtime_types"] }
|
||||||
state_processing = { path = "consensus/state_processing" }
|
state_processing = { path = "consensus/state_processing" }
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ edition = { workspace = true }
|
|||||||
default = []
|
default = []
|
||||||
fake_crypto = ["bls/fake_crypto"]
|
fake_crypto = ["bls/fake_crypto"]
|
||||||
arbitrary-fuzz = [
|
arbitrary-fuzz = [
|
||||||
|
"dep:arbitrary",
|
||||||
|
"smallvec/arbitrary",
|
||||||
"types/arbitrary-fuzz",
|
"types/arbitrary-fuzz",
|
||||||
"merkle_proof/arbitrary",
|
"merkle_proof/arbitrary",
|
||||||
"ethereum_ssz/arbitrary",
|
"ethereum_ssz/arbitrary",
|
||||||
@@ -17,7 +19,7 @@ arbitrary-fuzz = [
|
|||||||
portable = ["bls/supranational-portable"]
|
portable = ["bls/supranational-portable"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
arbitrary = { workspace = true }
|
arbitrary = { workspace = true, optional = true }
|
||||||
bls = { workspace = true }
|
bls = { workspace = true }
|
||||||
educe = { workspace = true }
|
educe = { workspace = true }
|
||||||
ethereum_hashing = { workspace = true }
|
ethereum_hashing = { workspace = true }
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use crate::per_block_processing::{
|
|||||||
verify_attester_slashing, verify_bls_to_execution_change, verify_exit,
|
verify_attester_slashing, verify_bls_to_execution_change, verify_exit,
|
||||||
verify_proposer_slashing,
|
verify_proposer_slashing,
|
||||||
};
|
};
|
||||||
|
#[cfg(feature = "arbitrary-fuzz")]
|
||||||
use arbitrary::Arbitrary;
|
use arbitrary::Arbitrary;
|
||||||
use educe::Educe;
|
use educe::Educe;
|
||||||
use smallvec::{SmallVec, smallvec};
|
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
|
/// The inner `op` field is private, meaning instances of this type can only be constructed
|
||||||
/// by calling `validate`.
|
/// by calling `validate`.
|
||||||
#[derive(Educe, Debug, Clone, Arbitrary)]
|
#[derive(Educe, Debug, Clone)]
|
||||||
|
#[cfg_attr(feature = "arbitrary-fuzz", derive(Arbitrary))]
|
||||||
#[educe(
|
#[educe(
|
||||||
PartialEq,
|
PartialEq,
|
||||||
Eq,
|
Eq,
|
||||||
Hash(bound(T: TransformPersist + std::hash::Hash, E: EthSpec))
|
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> {
|
pub struct SigVerifiedOp<T: TransformPersist, E: EthSpec> {
|
||||||
op: T,
|
op: T,
|
||||||
verified_against: VerifiedAgainst,
|
verified_against: VerifiedAgainst,
|
||||||
@@ -133,7 +138,8 @@ struct SigVerifiedOpDecode<P: Decode> {
|
|||||||
///
|
///
|
||||||
/// We need to store multiple `ForkVersion`s because attester slashings contain two indexed
|
/// We need to store multiple `ForkVersion`s because attester slashings contain two indexed
|
||||||
/// attestations which may be signed using different versions.
|
/// 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 {
|
pub struct VerifiedAgainst {
|
||||||
fork_versions: SmallVec<[ForkVersion; MAX_FORKS_VERIFIED_AGAINST]>,
|
fork_versions: SmallVec<[ForkVersion; MAX_FORKS_VERIFIED_AGAINST]>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ sqlite = ["dep:rusqlite"]
|
|||||||
arbitrary = [
|
arbitrary = [
|
||||||
"dep:arbitrary",
|
"dep:arbitrary",
|
||||||
"bls/arbitrary",
|
"bls/arbitrary",
|
||||||
|
"kzg/arbitrary",
|
||||||
"ethereum_ssz/arbitrary",
|
"ethereum_ssz/arbitrary",
|
||||||
"milhouse/arbitrary",
|
"milhouse/arbitrary",
|
||||||
"ssz_types/arbitrary",
|
"ssz_types/arbitrary",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ authors = ["Paul Hauner <paul@paulhauner.com>"]
|
|||||||
edition = { workspace = true }
|
edition = { workspace = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
arbitrary = []
|
arbitrary = ["dep:arbitrary"]
|
||||||
default = ["supranational"]
|
default = ["supranational"]
|
||||||
fake_crypto = []
|
fake_crypto = []
|
||||||
supranational = ["blst"]
|
supranational = ["blst"]
|
||||||
@@ -14,7 +14,7 @@ supranational-force-adx = ["supranational", "blst/force-adx"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
alloy-primitives = { workspace = true }
|
alloy-primitives = { workspace = true }
|
||||||
arbitrary = { workspace = true }
|
arbitrary = { workspace = true, optional = true }
|
||||||
blst = { version = "0.3.3", optional = true }
|
blst = { version = "0.3.3", optional = true }
|
||||||
ethereum_hashing = { workspace = true }
|
ethereum_hashing = { workspace = true }
|
||||||
ethereum_serde_utils = { workspace = true }
|
ethereum_serde_utils = { workspace = true }
|
||||||
|
|||||||
@@ -7,10 +7,11 @@ edition = "2021"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
arbitrary = ["dep:arbitrary"]
|
||||||
fake_crypto = []
|
fake_crypto = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
arbitrary = { workspace = true }
|
arbitrary = { workspace = true, optional = true }
|
||||||
c-kzg = { workspace = true }
|
c-kzg = { workspace = true }
|
||||||
educe = { workspace = true }
|
educe = { workspace = true }
|
||||||
ethereum_hashing = { workspace = true }
|
ethereum_hashing = { workspace = true }
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ impl Debug for KzgCommitment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "arbitrary")]
|
||||||
impl arbitrary::Arbitrary<'_> for KzgCommitment {
|
impl arbitrary::Arbitrary<'_> for KzgCommitment {
|
||||||
fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
|
fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
|
||||||
let mut bytes = [0u8; BYTES_PER_COMMITMENT];
|
let mut bytes = [0u8; BYTES_PER_COMMITMENT];
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ impl Debug for KzgProof {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "arbitrary")]
|
||||||
impl arbitrary::Arbitrary<'_> for KzgProof {
|
impl arbitrary::Arbitrary<'_> for KzgProof {
|
||||||
fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
|
fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
|
||||||
let mut bytes = [0u8; BYTES_PER_PROOF];
|
let mut bytes = [0u8; BYTES_PER_PROOF];
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ edition = { workspace = true }
|
|||||||
autotests = false
|
autotests = false
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
arbitrary-fuzz = ["types/arbitrary-fuzz", "eip_3076/arbitrary-fuzz"]
|
arbitrary-fuzz = ["dep:arbitrary", "types/arbitrary-fuzz", "eip_3076/arbitrary-fuzz"]
|
||||||
portable = ["types/portable"]
|
portable = ["types/portable"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
arbitrary = { workspace = true, features = ["derive"] }
|
arbitrary = { workspace = true, features = ["derive"], optional = true }
|
||||||
bls = { workspace = true }
|
bls = { workspace = true }
|
||||||
eip_3076 = { workspace = true, features = ["json"] }
|
eip_3076 = { workspace = true, features = ["json"] }
|
||||||
ethereum_serde_utils = { workspace = true }
|
ethereum_serde_utils = { workspace = true }
|
||||||
|
|||||||
Reference in New Issue
Block a user