Skip to content

Commit

Permalink
chore: remove proptest in all crates and Arbitrary derives (alloy-rs#966
Browse files Browse the repository at this point in the history
)

* chore: remove proptest in most crates and Arbitrary derives

* cargo fmt

rewriting static

* remove other proptest derive

* remove the rest of the proptest impls

* make arbitraryvalue not pub

* remove proptest derive from auth list
  • Loading branch information
Rjected authored and ben186 committed Jul 27, 2024
1 parent 9ce6ab9 commit 1b4bf03
Show file tree
Hide file tree
Showing 19 changed files with 15 additions and 167 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ serde_with = "3.3.0"
## misc-testing
arbitrary = "1.3"
assert_matches = "1.5"
proptest = { version = "1.4", default-features = false, features = ["alloc"] }
proptest-derive = { version = "0.4", default-features = false }
serial_test = "3.0"
similar-asserts = "1.5"
tempfile = "3.10"
6 changes: 0 additions & 6 deletions crates/consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ c-kzg = { workspace = true, features = ["serde"], optional = true }

# arbitrary
arbitrary = { workspace = true, features = ["derive"], optional = true }
proptest = { workspace = true, optional = true }
proptest-derive = { workspace = true, optional = true }

# serde
serde = { workspace = true, features = ["derive"], optional = true }
Expand All @@ -41,8 +39,6 @@ alloy-eips = { workspace = true, features = ["arbitrary"] }
alloy-signer.workspace = true

arbitrary = { workspace = true, features = ["derive"] }
proptest = { workspace = true }
proptest-derive = { workspace = true }
k256.workspace = true
tokio = { workspace = true, features = ["macros"] }
serde_json.workspace = true
Expand All @@ -55,8 +51,6 @@ kzg = ["dep:c-kzg", "alloy-eips/kzg", "std"]
arbitrary = [
"std",
"dep:arbitrary",
"dep:proptest-derive",
"dep:proptest",
"alloy-eips/arbitrary",
]
serde = [
Expand Down
7 changes: 1 addition & 6 deletions crates/consensus/src/request.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(unknown_lints, non_local_definitions)] // TODO: remove when proptest-derive updates

use alloy_eips::{
eip6110::DepositRequest,
eip7002::WithdrawalRequest,
Expand All @@ -13,10 +11,7 @@ use alloy_rlp::{Decodable, Encodable};
/// See also [EIP-7685](https://eips.ethereum.org/EIPS/eip-7685).
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[non_exhaustive]
#[cfg_attr(
any(test, feature = "arbitrary"),
derive(proptest_derive::Arbitrary, arbitrary::Arbitrary)
)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(untagged))]
pub enum Request {
Expand Down
6 changes: 0 additions & 6 deletions crates/eips/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ ethereum_ssz = { workspace = true, optional = true }

# arbitrary
arbitrary = { workspace = true, features = ["derive"], optional = true }
proptest = { workspace = true, optional = true }
proptest-derive = { workspace = true, optional = true }

[dev-dependencies]
alloy-primitives = { workspace = true, features = [
Expand All @@ -48,8 +46,6 @@ alloy-primitives = { workspace = true, features = [
"arbitrary",
] }
arbitrary = { workspace = true, features = ["derive"] }
proptest.workspace = true
proptest-derive.workspace = true
serde_json.workspace = true

[features]
Expand Down Expand Up @@ -81,8 +77,6 @@ arbitrary = [
"std",
"kzg-sidecar",
"dep:arbitrary",
"dep:proptest-derive",
"dep:proptest",
"alloy-primitives/arbitrary",
"alloy-serde?/arbitrary",
]
7 changes: 1 addition & 6 deletions crates/eips/src/eip1898.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! [EIP-1898]: https://eips.ethereum.org/EIPS/eip-1898
#![allow(unknown_lints, non_local_definitions)] // TODO: remove when proptest-derive updates

use alloy_primitives::{hex::FromHexError, ruint::ParseError, BlockHash, BlockNumber, B256, U64};
use alloy_rlp::{bytes, Decodable, Encodable, Error as RlpError};
use core::{
Expand Down Expand Up @@ -616,10 +614,7 @@ impl From<(BlockHash, BlockNumber)> for BlockNumHash {
/// Either a block hash _or_ a block number
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
any(test, feature = "arbitrary"),
derive(proptest_derive::Arbitrary, arbitrary::Arbitrary)
)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
pub enum BlockHashOrNumber {
/// A block hash
Hash(B256),
Expand Down
28 changes: 3 additions & 25 deletions crates/eips/src/eip2930.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
//!
//! [EIP-2930]: https://eips.ethereum.org/EIPS/eip-2930
#![allow(unknown_lints, non_local_definitions)] // TODO: remove when proptest-derive updates

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

Expand All @@ -14,22 +12,13 @@ use core::{mem, ops::Deref};
/// A list of addresses and storage keys that the transaction plans to access.
/// Accesses outside the list are possible, but become more expensive.
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, RlpDecodable, RlpEncodable)]
#[cfg_attr(
any(test, feature = "arbitrary"),
derive(proptest_derive::Arbitrary, arbitrary::Arbitrary)
)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct AccessListItem {
/// Account addresses that would be loaded at the start of execution
pub address: Address,
/// Keys of storage that would be loaded at the start of execution
#[cfg_attr(
any(test, feature = "arbitrary"),
proptest(
strategy = "proptest::collection::vec(proptest::arbitrary::any::<B256>(), 0..=20)"
)
)]
// In JSON, we have to accept `null` for storage key, which is interpreted as an empty array.
#[cfg_attr(feature = "serde", serde(deserialize_with = "alloy_serde::null_as_default"))]
pub storage_keys: Vec<B256>,
Expand All @@ -45,20 +34,9 @@ impl AccessListItem {

/// AccessList as defined in EIP-2930
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, RlpDecodableWrapper, RlpEncodableWrapper)]
#[cfg_attr(
any(test, feature = "arbitrary"),
derive(proptest_derive::Arbitrary, arbitrary::Arbitrary)
)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AccessList(
#[cfg_attr(
any(test, feature = "arbitrary"),
proptest(
strategy = "proptest::collection::vec(proptest::arbitrary::any::<AccessListItem>(), 0..=20)"
)
)]
pub Vec<AccessListItem>,
);
pub struct AccessList(pub Vec<AccessListItem>);

impl From<Vec<AccessListItem>> for AccessList {
fn from(list: Vec<AccessListItem>) -> Self {
Expand Down
3 changes: 0 additions & 3 deletions crates/eips/src/eip4844/sidecar.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! EIP-4844 sidecar type
#![allow(unknown_lints, non_local_definitions)] // TODO: remove when proptest-derive updates

use crate::eip4844::{
kzg_to_versioned_hash, Blob, Bytes48, BYTES_PER_BLOB, BYTES_PER_COMMITMENT, BYTES_PER_PROOF,
};
Expand All @@ -20,7 +18,6 @@ use alloc::vec::Vec;
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
#[repr(C)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(any(test, feature = "arbitrary"), derive(proptest_derive::Arbitrary))]
#[doc(alias = "BlobTxSidecar")]
pub struct BlobTransactionSidecar {
/// The blob data.
Expand Down
7 changes: 1 addition & 6 deletions crates/eips/src/eip4895.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
//!
//! [EIP-4895]: https://eips.ethereum.org/EIPS/eip-4895
#![allow(unknown_lints, non_local_definitions)] // TODO: remove when proptest-derive updates

use alloy_primitives::{Address, U256};
use alloy_rlp::{RlpDecodable, RlpEncodable};

Expand All @@ -12,10 +10,7 @@ pub const GWEI_TO_WEI: u64 = 1_000_000_000;

/// Withdrawal represents a validator withdrawal from the consensus layer.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, RlpEncodable, RlpDecodable)]
#[cfg_attr(
any(test, feature = "arbitrary"),
derive(proptest_derive::Arbitrary, arbitrary::Arbitrary)
)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "ssz", derive(ssz_derive::Encode, ssz_derive::Decode))]
pub struct Withdrawal {
Expand Down
7 changes: 1 addition & 6 deletions crates/eips/src/eip6110.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
//!
//! Provides validator deposits as a list of deposit operations added to the Execution Layer block.
#![allow(unknown_lints, non_local_definitions)] // TODO: remove when proptest-derive updates

use alloy_primitives::{address, Address, FixedBytes, B256};
use alloy_rlp::{RlpDecodable, RlpEncodable};

Expand All @@ -18,10 +16,7 @@ pub const MAINNET_DEPOSIT_CONTRACT_ADDRESS: Address =
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(feature = "ssz", derive(ssz_derive::Encode, ssz_derive::Decode))]
#[cfg_attr(
any(test, feature = "arbitrary"),
derive(proptest_derive::Arbitrary, arbitrary::Arbitrary)
)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
pub struct DepositRequest {
/// Validator public key
pub pubkey: FixedBytes<48>,
Expand Down
7 changes: 1 addition & 6 deletions crates/eips/src/eip7002.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
//!
//! See also [EIP-7002](https://eips.ethereum.org/EIPS/eip-7002): Execution layer triggerable withdrawals
#![allow(unknown_lints, non_local_definitions)] // TODO: remove when proptest-derive updates

use alloy_primitives::{address, bytes, Address, Bytes, FixedBytes};
use alloy_rlp::{RlpDecodable, RlpEncodable};

Expand All @@ -27,10 +25,7 @@ pub const WITHDRAWAL_REQUEST_TYPE: u8 = 0x01;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, RlpEncodable, RlpDecodable, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
any(test, feature = "arbitrary"),
derive(proptest_derive::Arbitrary, arbitrary::Arbitrary)
)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
pub struct WithdrawalRequest {
/// Address of the source of the exit.
pub source_address: Address,
Expand Down
7 changes: 1 addition & 6 deletions crates/eips/src/eip7251.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
//!
//! See also [EIP-7251](https://eips.ethereum.org/EIPS/eip-7251): Increase the MAX_EFFECTIVE_BALANCE
#![allow(unknown_lints, non_local_definitions)] // TODO: remove when proptest-derive updates

use alloy_primitives::{address, bytes, Address, Bytes, FixedBytes};
use alloy_rlp::{RlpDecodable, RlpEncodable};

Expand All @@ -23,10 +21,7 @@ pub const CONSOLIDATION_REQUEST_TYPE: u8 = 0x02;
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(feature = "ssz", derive(ssz_derive::Encode, ssz_derive::Decode))]
#[cfg_attr(
any(test, feature = "arbitrary"),
derive(proptest_derive::Arbitrary, arbitrary::Arbitrary)
)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
pub struct ConsolidationRequest {
/// Source address
pub source_address: Address,
Expand Down
4 changes: 2 additions & 2 deletions crates/eips/src/eip7702/auth_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use core::hash::{Hash, Hasher};
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
any(test, feature = "arbitrary"),
derive(proptest_derive::Arbitrary, arbitrary::Arbitrary)
derive(arbitrary::Arbitrary)
)]
pub struct Authorization {
/// The chain ID of the authorization.
Expand Down Expand Up @@ -235,7 +235,7 @@ impl Deref for RecoveredAuthorization {
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(
any(test, feature = "arbitrary"),
derive(proptest_derive::Arbitrary, arbitrary::Arbitrary)
derive(arbitrary::Arbitrary)
)]
pub struct OptionalNonce(Option<u64>);

Expand Down
6 changes: 0 additions & 6 deletions crates/rpc-types-eth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ thiserror.workspace = true

# arbitrary
arbitrary = { version = "1.3", features = ["derive"], optional = true }
proptest = { version = "1.4", optional = true }
proptest-derive = { version = "0.4", optional = true }

# jsonrpsee
jsonrpsee-types = { version = "0.23", optional = true }
Expand All @@ -50,16 +48,12 @@ alloy-primitives = { workspace = true, features = [
alloy-consensus = { workspace = true, features = ["std", "arbitrary"] }

arbitrary = { workspace = true, features = ["derive"] }
proptest.workspace = true
proptest-derive.workspace = true
rand.workspace = true
similar-asserts.workspace = true

[features]
arbitrary = [
"dep:arbitrary",
"dep:proptest-derive",
"dep:proptest",
"alloy-primitives/arbitrary",
"alloy-serde/arbitrary",
"alloy-eips/arbitrary",
Expand Down
7 changes: 1 addition & 6 deletions crates/rpc-types-eth/src/log.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#![allow(unknown_lints, non_local_definitions)] // TODO: remove when proptest-derive updates

use alloy_primitives::{Address, BlockHash, LogData, TxHash, B256};
use serde::{Deserialize, Serialize};

/// Ethereum Log emitted by a transaction
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[cfg_attr(
any(test, feature = "arbitrary"),
derive(proptest_derive::Arbitrary, arbitrary::Arbitrary)
)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
#[serde(rename_all = "camelCase")]
pub struct Log<T = LogData> {
#[serde(flatten)]
Expand Down
7 changes: 1 addition & 6 deletions crates/rpc-types-eth/src/transaction/receipt.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(unknown_lints, non_local_definitions)] // TODO: remove when proptest-derive updates

use crate::Log;
use alloy_consensus::{AnyReceiptEnvelope, ReceiptEnvelope, TxType};
use alloy_primitives::{Address, BlockHash, TxHash, B256};
Expand All @@ -11,10 +9,7 @@ use serde::{Deserialize, Serialize};
/// This type is generic over an inner [`ReceiptEnvelope`] which contains
/// consensus data and metadata.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(
any(test, feature = "arbitrary"),
derive(proptest_derive::Arbitrary, arbitrary::Arbitrary)
)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
#[serde(rename_all = "camelCase")]
#[doc(alias = "TxReceipt")]
pub struct TransactionReceipt<T = ReceiptEnvelope<Log>> {
Expand Down
2 changes: 0 additions & 2 deletions crates/rpc-types-trace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,5 @@ alloy-primitives = { workspace = true, features = [
] }

arbitrary = { workspace = true, features = ["derive"] }
proptest.workspace = true
proptest-derive.workspace = true
rand.workspace = true
similar-asserts.workspace = true
6 changes: 0 additions & 6 deletions crates/serde/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ serde_json = { workspace = true, features = ["alloc"] }

# arbitrary
arbitrary = { version = "1.3", features = ["derive"], optional = true }
proptest = { version = "1.4", optional = true }
proptest-derive = { version = "0.4", optional = true }

[dev-dependencies]
alloy-primitives = { workspace = true, features = [
Expand All @@ -37,17 +35,13 @@ alloy-primitives = { workspace = true, features = [
] }

arbitrary = { workspace = true, features = ["derive"] }
proptest.workspace = true
proptest-derive.workspace = true
rand.workspace = true

[features]
default = ["std"]
std = ["alloy-primitives/std", "serde/std", "serde_json/std"]
arbitrary = [
"dep:arbitrary",
"dep:proptest-derive",
"dep:proptest",
"alloy-primitives/arbitrary",
"std",
]
Loading

0 comments on commit 1b4bf03

Please sign in to comment.