From 170138b3c8df1fac70c13ab41cf6e05b1e87ee56 Mon Sep 17 00:00:00 2001 From: Esad Yusuf Atik Date: Fri, 13 Dec 2024 15:18:16 +0300 Subject: [PATCH] Cleanup remove arbitrary (#1605) --- Cargo.lock | 29 ------- Cargo.toml | 2 - bin/citrea/Cargo.toml | 1 - crates/ethereum-rpc/Cargo.toml | 1 - .../full-node/db/sov-db/Cargo.toml | 10 +-- .../full-node/db/sov-db/src/ledger_db/mod.rs | 1 - .../full-node/db/sov-db/src/schema/types.rs | 52 ------------ .../full-node/db/sov-schema-db/Cargo.toml | 3 - .../full-node/db/sov-schema-db/src/lib.rs | 1 - .../db/sov-schema-db/src/schema_batch.rs | 21 ----- .../sov-accounts/Cargo.toml | 11 --- .../sov-accounts/src/fuzz.rs | 84 ------------------- .../sov-accounts/src/lib.rs | 3 - .../sov-accounts/src/query.rs | 4 - .../module-system/sov-modules-api/Cargo.toml | 12 --- .../src/containers/accessory_map.rs | 37 -------- .../sov-modules-api/src/containers/map.rs | 37 -------- .../src/containers/offchain_map.rs | 37 -------- .../sov-modules-api/src/default_context.rs | 1 - .../sov-modules-api/src/default_signature.rs | 35 -------- .../sov-modules-api/src/pub_key_hex.rs | 11 --- .../module-system/sov-modules-core/Cargo.toml | 10 --- .../sov-modules-core/src/common/address.rs | 5 -- .../sov-modules-core/src/common/bytes.rs | 35 -------- .../module-system/sov-state/Cargo.toml | 9 -- .../sovereign-sdk/rollup-interface/Cargo.toml | 2 - .../rollup-interface/src/spec.rs | 2 - 27 files changed, 1 insertion(+), 455 deletions(-) delete mode 100644 crates/sovereign-sdk/module-system/module-implementations/sov-accounts/src/fuzz.rs diff --git a/Cargo.lock b/Cargo.lock index cd1e76c14..9d3b53697 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1730,7 +1730,6 @@ dependencies = [ "lazy_static", "log", "log-panics", - "proptest", "prover-services", "regex", "reqwest", @@ -2828,7 +2827,6 @@ dependencies = [ "futures", "jsonrpsee", "parking_lot", - "proptest", "reth-primitives", "reth-rpc-eth-types", "reth-rpc-types", @@ -5071,17 +5069,6 @@ dependencies = [ "unarray", ] -[[package]] -name = "proptest-derive" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf16337405ca084e9c78985114633b6827711d22b9e6ef6c6c0d665eb3f0b6e" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "prost" version = "0.12.6" @@ -7385,12 +7372,9 @@ dependencies = [ name = "sov-accounts" version = "0.5.0-rc.1" dependencies = [ - "arbitrary", "borsh", "clap", "jsonrpsee", - "proptest", - "proptest-derive", "schemars", "serde", "serde_json", @@ -7406,7 +7390,6 @@ name = "sov-db" version = "0.5.0-rc.1" dependencies = [ "anyhow", - "arbitrary", "bincode", "borsh", "byteorder", @@ -7414,8 +7397,6 @@ dependencies = [ "hex", "jmt", "num_cpus", - "proptest", - "proptest-derive", "rand 0.8.5", "rlimit", "rocksdb", @@ -7482,7 +7463,6 @@ name = "sov-modules-api" version = "0.5.0-rc.1" dependencies = [ "anyhow", - "arbitrary", "bech32 0.9.1", "bincode", "borsh", @@ -7493,8 +7473,6 @@ dependencies = [ "hex", "jmt", "jsonrpsee", - "proptest", - "proptest-derive", "rand 0.8.5", "schemars", "serde", @@ -7517,7 +7495,6 @@ name = "sov-modules-core" version = "0.5.0-rc.1" dependencies = [ "anyhow", - "arbitrary", "bech32 0.9.1", "borsh", "derive_more", @@ -7525,7 +7502,6 @@ dependencies = [ "hex", "jmt", "proptest", - "proptest-derive", "schemars", "serde", "serde_json", @@ -7619,7 +7595,6 @@ name = "sov-rollup-interface" version = "0.5.0-rc.1" dependencies = [ "anyhow", - "arbitrary", "async-trait", "borsh", "bytes", @@ -7641,8 +7616,6 @@ dependencies = [ "byteorder", "once_cell", "prometheus", - "proptest", - "proptest-derive", "rocksdb", "sov-schema-db", "tempfile", @@ -7656,12 +7629,10 @@ name = "sov-state" version = "0.5.0-rc.1" dependencies = [ "anyhow", - "arbitrary", "bcs", "borsh", "jmt", "proptest", - "proptest-derive", "serde", "sha2", "sov-db", diff --git a/Cargo.toml b/Cargo.toml index 2640293eb..738ed3fdf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,7 +55,6 @@ jmt = { git = "https://github.com/penumbra-zone/jmt.git", rev = "fd1c8ef" } # External dependencies async-trait = "0.1.71" anyhow = { version = "1.0.68", default-features = false } -arbitrary = { version = "1.3.1", features = ["derive"] } backoff = { version = "0.4.0", features = ["futures", "tokio"] } borsh = { version = "1.5", default-features = false, features = ["derive"] } # TODO: Consider replacing this serialization format @@ -82,7 +81,6 @@ once_cell = { version = "1.19.0", default-features = false, features = ["alloc"] parking_lot = { version = "0.12.3" } prometheus = { version = "0.13.3", default-features = false } proptest = { version = "1.3.1", default-features = false, features = ["alloc"] } -proptest-derive = "0.4.0" rand = "0.8" rayon = "1.8.0" rlimit = "0.10.2" diff --git a/bin/citrea/Cargo.toml b/bin/citrea/Cargo.toml index 1a4a4d582..1f0f926cc 100644 --- a/bin/citrea/Cargo.toml +++ b/bin/citrea/Cargo.toml @@ -76,7 +76,6 @@ alloy-rlp = { workspace = true } bincode = { workspace = true } borsh = { workspace = true } hex = { workspace = true } -proptest = { workspace = true } reqwest = { workspace = true } rs_merkle = { workspace = true } serde_json = { workspace = true } diff --git a/crates/ethereum-rpc/Cargo.toml b/crates/ethereum-rpc/Cargo.toml index 97539e828..9704c7a8e 100644 --- a/crates/ethereum-rpc/Cargo.toml +++ b/crates/ethereum-rpc/Cargo.toml @@ -40,7 +40,6 @@ sov-modules-api = { path = "../sovereign-sdk/module-system/sov-modules-api", def sov-rollup-interface = { path = "../sovereign-sdk/rollup-interface", features = ["native"] } [dev-dependencies] -proptest = { workspace = true } tokio = { workspace = true } [features] diff --git a/crates/sovereign-sdk/full-node/db/sov-db/Cargo.toml b/crates/sovereign-sdk/full-node/db/sov-db/Cargo.toml index 176db14e4..67500409d 100644 --- a/crates/sovereign-sdk/full-node/db/sov-db/Cargo.toml +++ b/crates/sovereign-sdk/full-node/db/sov-db/Cargo.toml @@ -21,14 +21,11 @@ sov-schema-db = { path = "../sov-schema-db" } # External anyhow = { workspace = true, default-features = true } -arbitrary = { workspace = true, optional = true } bincode = { workspace = true } borsh = { workspace = true, default-features = true, features = ["bytes", "rc"] } byteorder = { workspace = true, default-features = true } hex = { workspace = true } num_cpus = { workspace = true } -proptest = { workspace = true, optional = true, default-features = true } -proptest-derive = { workspace = true, optional = true } rlimit = { workspace = true } rocksdb = { workspace = true } serde = { workspace = true, default-features = true, features = ["rc"] } @@ -42,12 +39,7 @@ rand = { workspace = true } sha2 = { workspace = true } tempfile = { workspace = true } -[features] -arbitrary = [ - "dep:arbitrary", - "dep:proptest", - "dep:proptest-derive", -] + [[bench]] name = "state_db_single_snapshot" diff --git a/crates/sovereign-sdk/full-node/db/sov-db/src/ledger_db/mod.rs b/crates/sovereign-sdk/full-node/db/sov-db/src/ledger_db/mod.rs index 74580b9f0..1163a5f2b 100644 --- a/crates/sovereign-sdk/full-node/db/sov-db/src/ledger_db/mod.rs +++ b/crates/sovereign-sdk/full-node/db/sov-db/src/ledger_db/mod.rs @@ -52,7 +52,6 @@ pub struct LedgerDB { /// A SlotNumber, BatchNumber, TxNumber, and EventNumber which are grouped together, typically representing /// the respective heights at the start or end of slot processing. #[derive(Default, Clone, Debug)] -#[cfg_attr(feature = "arbitrary", derive(proptest_derive::Arbitrary))] pub struct ItemNumbers { /// The slot number pub slot_number: u64, diff --git a/crates/sovereign-sdk/full-node/db/sov-db/src/schema/types.rs b/crates/sovereign-sdk/full-node/db/sov-db/src/schema/types.rs index 0c6951d45..390163557 100644 --- a/crates/sovereign-sdk/full-node/db/sov-db/src/schema/types.rs +++ b/crates/sovereign-sdk/full-node/db/sov-db/src/schema/types.rs @@ -21,7 +21,6 @@ use sov_rollup_interface::zk::{BatchProofInfo, CumulativeStateDiff, Proof}; #[derive( Clone, PartialEq, PartialOrd, Eq, Ord, Debug, Default, BorshDeserialize, BorshSerialize, )] -#[cfg_attr(feature = "arbitrary", derive(proptest_derive::Arbitrary))] pub struct DbBytes(Arc>); impl DbBytes { @@ -62,7 +61,6 @@ pub(crate) type StateKey = Vec; /// and the hash of the da block. TODO(@preston-evans98): add any additional data /// required to reconstruct the da block proof. #[derive(Debug, PartialEq, BorshDeserialize, BorshSerialize)] -#[cfg_attr(feature = "arbitrary", derive(proptest_derive::Arbitrary))] pub struct StoredSlot { /// The slot's hash, as reported by the DA layer. pub hash: DbHash, @@ -327,7 +325,6 @@ impl TryFrom for SoftConfirmationResponse { /// The on-disk format for a batch. Stores the hash and identifies the range of transactions /// included in the batch. #[derive(Debug, PartialEq, BorshDeserialize, BorshSerialize)] -#[cfg_attr(feature = "arbitrary", derive(proptest_derive::Arbitrary))] pub struct StoredBatch { /// The hash of the batch, as reported by the DA layer. pub hash: DbHash, @@ -373,7 +370,6 @@ macro_rules! u64_wrapper { ::serde::Serialize, ::serde::Deserialize, )] - #[cfg_attr(feature = "arbitrary", derive(proptest_derive::Arbitrary))] pub struct $name(pub u64); impl From<$name> for u64 { @@ -381,13 +377,6 @@ macro_rules! u64_wrapper { value.0 } } - - #[cfg(feature = "arbitrary")] - impl<'a> ::arbitrary::Arbitrary<'a> for $name { - fn arbitrary(u: &mut ::arbitrary::Unstructured<'a>) -> ::arbitrary::Result { - u.arbitrary().map($name) - } - } }; } @@ -395,44 +384,3 @@ u64_wrapper!(SlotNumber); u64_wrapper!(BatchNumber); u64_wrapper!(TxNumber); u64_wrapper!(EventNumber); - -#[cfg(feature = "arbitrary")] -pub mod arbitrary { - //! Arbitrary definitions for the types. - - use super::*; - - impl<'a> ::arbitrary::Arbitrary<'a> for DbBytes { - fn arbitrary(u: &mut ::arbitrary::Unstructured<'a>) -> ::arbitrary::Result { - u.arbitrary().map(DbBytes::new) - } - } - - impl<'a> ::arbitrary::Arbitrary<'a> for StoredTransaction { - fn arbitrary(u: &mut ::arbitrary::Unstructured<'a>) -> ::arbitrary::Result { - Ok(StoredTransaction { - hash: u.arbitrary()?, - body: u.arbitrary()?, - }) - } - } - - impl<'a> ::arbitrary::Arbitrary<'a> for StoredBatch { - fn arbitrary(u: &mut ::arbitrary::Unstructured<'a>) -> ::arbitrary::Result { - Ok(StoredBatch { - hash: u.arbitrary()?, - txs: u.arbitrary()?, - }) - } - } - - impl<'a> ::arbitrary::Arbitrary<'a> for StoredSlot { - fn arbitrary(u: &mut ::arbitrary::Unstructured<'a>) -> ::arbitrary::Result { - Ok(StoredSlot { - hash: u.arbitrary()?, - extra_data: u.arbitrary()?, - batches: u.arbitrary()?, - }) - } - } -} diff --git a/crates/sovereign-sdk/full-node/db/sov-schema-db/Cargo.toml b/crates/sovereign-sdk/full-node/db/sov-schema-db/Cargo.toml index ff4fa3a26..e52d1a2f2 100644 --- a/crates/sovereign-sdk/full-node/db/sov-schema-db/Cargo.toml +++ b/crates/sovereign-sdk/full-node/db/sov-schema-db/Cargo.toml @@ -18,8 +18,6 @@ anyhow = { workspace = true, default-features = true } byteorder = { workspace = true, default-features = true, optional = true } once_cell = { workspace = true, default-features = true } prometheus = { workspace = true } -proptest = { workspace = true, optional = true, default-features = true } -proptest-derive = { workspace = true, optional = true } rocksdb = { workspace = true } tokio = { workspace = true } tracing = { workspace = true, default-features = true } @@ -33,4 +31,3 @@ sov-schema-db = { path = ".", features = ["test-utils"] } [features] default = [] test-utils = ["dep:byteorder"] -arbitrary = ["dep:proptest", "dep:proptest-derive"] diff --git a/crates/sovereign-sdk/full-node/db/sov-schema-db/src/lib.rs b/crates/sovereign-sdk/full-node/db/sov-schema-db/src/lib.rs index 1adea613a..d458f0ddc 100644 --- a/crates/sovereign-sdk/full-node/db/sov-schema-db/src/lib.rs +++ b/crates/sovereign-sdk/full-node/db/sov-schema-db/src/lib.rs @@ -376,7 +376,6 @@ pub type SchemaKey = Vec; /// Readability alias for a value in the DB. pub type SchemaValue = Vec; -#[cfg_attr(feature = "arbitrary", derive(proptest_derive::Arbitrary))] #[derive(Debug, PartialEq, Eq, Hash, Clone)] /// Represents operation written to the database pub enum Operation { diff --git a/crates/sovereign-sdk/full-node/db/sov-schema-db/src/schema_batch.rs b/crates/sovereign-sdk/full-node/db/sov-schema-db/src/schema_batch.rs index d0695fbe0..46952edfa 100644 --- a/crates/sovereign-sdk/full-node/db/sov-schema-db/src/schema_batch.rs +++ b/crates/sovereign-sdk/full-node/db/sov-schema-db/src/schema_batch.rs @@ -117,24 +117,3 @@ where self.inner.as_mut().and_then(|inner| inner.next()) } } - -#[cfg(feature = "arbitrary")] -impl proptest::arbitrary::Arbitrary for SchemaBatch { - type Parameters = &'static [ColumnFamilyName]; - fn arbitrary_with(columns: Self::Parameters) -> Self::Strategy { - use proptest::prelude::any; - use proptest::strategy::Strategy; - - proptest::collection::vec(any::>(), columns.len()) - .prop_map::(|vec_vec_write_ops| { - let mut rows = HashMap::new(); - for (col, write_op) in columns.iter().zip(vec_vec_write_ops.into_iter()) { - rows.insert(*col, write_op); - } - SchemaBatch { last_writes: rows } - }) - .boxed() - } - - type Strategy = proptest::strategy::BoxedStrategy; -} diff --git a/crates/sovereign-sdk/module-system/module-implementations/sov-accounts/Cargo.toml b/crates/sovereign-sdk/module-system/module-implementations/sov-accounts/Cargo.toml index 1bf29b93c..4a9923ed9 100644 --- a/crates/sovereign-sdk/module-system/module-implementations/sov-accounts/Cargo.toml +++ b/crates/sovereign-sdk/module-system/module-implementations/sov-accounts/Cargo.toml @@ -12,10 +12,7 @@ readme = "README.md" resolver = "2" [dependencies] -arbitrary = { workspace = true, optional = true } borsh = { workspace = true, features = ["rc"] } -proptest = { workspace = true, optional = true } -proptest-derive = { workspace = true, optional = true } schemars = { workspace = true, optional = true } serde = { workspace = true } serde_json = { workspace = true, optional = true } @@ -41,14 +38,6 @@ sov-prover-storage-manager = { path = "../../../full-node/sov-prover-storage-man [features] default = ["native"] -arbitrary = [ - "dep:arbitrary", - "dep:proptest", - "dep:proptest-derive", - "sov-state/arbitrary", - "sov-modules-api/arbitrary", - "sov-state/arbitrary", -] native = [ "serde", "serde_json", diff --git a/crates/sovereign-sdk/module-system/module-implementations/sov-accounts/src/fuzz.rs b/crates/sovereign-sdk/module-system/module-implementations/sov-accounts/src/fuzz.rs deleted file mode 100644 index f1090bdae..000000000 --- a/crates/sovereign-sdk/module-system/module-implementations/sov-accounts/src/fuzz.rs +++ /dev/null @@ -1,84 +0,0 @@ -use arbitrary::{Arbitrary, Unstructured}; -use proptest::arbitrary::any; -use proptest::strategy::{BoxedStrategy, Strategy}; -use sov_modules_api::{Context, Module, PrivateKey, WorkingSet}; - -use crate::{Account, AccountConfig, Accounts}; - -impl<'a, C> Arbitrary<'a> for Account -where - C: Context, - C::Address: Arbitrary<'a>, -{ - fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result { - let addr = u.arbitrary()?; - let nonce = u.arbitrary()?; - Ok(Self { addr, nonce }) - } -} - -impl proptest::arbitrary::Arbitrary for Account -where - C: Context, - C::Address: proptest::arbitrary::Arbitrary, -{ - type Parameters = (); - type Strategy = BoxedStrategy; - - fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy { - (any::(), any::()) - .prop_map(|(addr, nonce)| Account { addr, nonce }) - .boxed() - } -} - -impl<'a, C> Arbitrary<'a> for AccountConfig -where - C: Context, - C::PublicKey: Arbitrary<'a>, -{ - fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result { - // TODO we might want a dedicated struct that will generate the private key counterpart so - // payloads can be signed and verified - Ok(Self { - pub_keys: u.arbitrary_iter()?.collect::>()?, - }) - } -} - -impl proptest::arbitrary::Arbitrary for AccountConfig -where - C: Context, - C::PrivateKey: proptest::arbitrary::Arbitrary, -{ - type Parameters = (); - type Strategy = BoxedStrategy; - - fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy { - any::>() - .prop_map(|keys| AccountConfig { - pub_keys: keys.into_iter().map(|k| k.pub_key()).collect(), - }) - .boxed() - } -} - -impl<'a, C> Accounts -where - C: Context, - C::Address: Arbitrary<'a>, - C::PublicKey: Arbitrary<'a>, -{ - /// Creates an arbitrary set of accounts and stores it under `working_set`. - pub fn arbitrary_workset( - u: &mut Unstructured<'a>, - working_set: &mut WorkingSet, - ) -> arbitrary::Result { - let config: AccountConfig = u.arbitrary()?; - let accounts = Accounts::default(); - - accounts.genesis(&config, working_set); - - Ok(accounts) - } -} diff --git a/crates/sovereign-sdk/module-system/module-implementations/sov-accounts/src/lib.rs b/crates/sovereign-sdk/module-system/module-implementations/sov-accounts/src/lib.rs index 883a6bd9f..5cce09056 100644 --- a/crates/sovereign-sdk/module-system/module-implementations/sov-accounts/src/lib.rs +++ b/crates/sovereign-sdk/module-system/module-implementations/sov-accounts/src/lib.rs @@ -1,5 +1,3 @@ -#[cfg(all(feature = "arbitrary", feature = "native"))] -mod fuzz; mod genesis; mod hooks; pub use genesis::*; @@ -33,7 +31,6 @@ pub struct Account { /// A module responsible for managing accounts on the rollup. #[cfg_attr(feature = "native", derive(sov_modules_api::ModuleCallJsonSchema))] #[derive(ModuleInfo, Clone)] -#[cfg_attr(feature = "arbitrary", derive(Debug))] pub struct Accounts { /// The address of the sov-accounts module. #[address] diff --git a/crates/sovereign-sdk/module-system/module-implementations/sov-accounts/src/query.rs b/crates/sovereign-sdk/module-system/module-implementations/sov-accounts/src/query.rs index 03ac8998e..29d284885 100644 --- a/crates/sovereign-sdk/module-system/module-implementations/sov-accounts/src/query.rs +++ b/crates/sovereign-sdk/module-system/module-implementations/sov-accounts/src/query.rs @@ -7,10 +7,6 @@ use crate::{Account, Accounts}; /// This is the response returned from the accounts_getAccount endpoint. #[derive(Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, Clone)] -#[cfg_attr( - feature = "arbitrary", - derive(arbitrary::Arbitrary, proptest_derive::Arbitrary) -)] pub enum Response { /// The account corresponding to the given public key exists. AccountExists { diff --git a/crates/sovereign-sdk/module-system/sov-modules-api/Cargo.toml b/crates/sovereign-sdk/module-system/sov-modules-api/Cargo.toml index 720961cdb..804efc89f 100644 --- a/crates/sovereign-sdk/module-system/sov-modules-api/Cargo.toml +++ b/crates/sovereign-sdk/module-system/sov-modules-api/Cargo.toml @@ -14,7 +14,6 @@ resolver = "2" [dependencies] jsonrpsee = { workspace = true, optional = true } anyhow = { workspace = true } -arbitrary = { workspace = true, optional = true } digest = { workspace = true } sov-state = { path = "../sov-state" } sov-modules-core = { path = "../sov-modules-core" } @@ -23,8 +22,6 @@ sov-modules-macros = { path = "../sov-modules-macros", optional = true, default- sov-prover-storage-manager = { path = "../../full-node/sov-prover-storage-manager", optional = true } serde = { workspace = true } borsh = { workspace = true } -proptest = { workspace = true, optional = true } -proptest-derive = { workspace = true, optional = true } thiserror = { workspace = true } sha2 = { workspace = true } bech32 = { workspace = true } @@ -51,15 +48,6 @@ sov-prover-storage-manager = { path = "../../full-node/sov-prover-storage-manage [features] -arbitrary = [ - "dep:arbitrary", - "dep:proptest", - "dep:proptest-derive", - "native", - "sov-rollup-interface/arbitrary", - "proptest/default", - "sov-state/arbitrary", -] bench = [] default = ["native", "macros"] native = [ diff --git a/crates/sovereign-sdk/module-system/sov-modules-api/src/containers/accessory_map.rs b/crates/sovereign-sdk/module-system/sov-modules-api/src/containers/accessory_map.rs index 1bc0011e8..79665317e 100644 --- a/crates/sovereign-sdk/module-system/sov-modules-api/src/containers/accessory_map.rs +++ b/crates/sovereign-sdk/module-system/sov-modules-api/src/containers/accessory_map.rs @@ -70,40 +70,3 @@ where &self.codec } } - -#[cfg(feature = "arbitrary")] -impl<'a, K, V, Codec> AccessoryStateMap -where - K: arbitrary::Arbitrary<'a>, - V: arbitrary::Arbitrary<'a>, - Codec: StateCodec + Default, - Codec::KeyCodec: StateKeyCodec, - Codec::ValueCodec: StateValueCodec, -{ - /// Generates an arbitrary [`AccessoryStateMap`] instance. - /// - /// See the [`arbitrary`] crate for more information. - pub fn arbitrary_working_set( - u: &mut arbitrary::Unstructured<'a>, - working_set: &mut AccessoryWorkingSet, - ) -> arbitrary::Result - where - S: Storage, - { - use arbitrary::Arbitrary; - - let prefix = Prefix::arbitrary(u)?; - let len = u.arbitrary_len::<(K, V)>()?; - let codec = Codec::default(); - let map = Self::with_codec(prefix, codec); - - (0..len).try_fold(map, |map, _| { - let key = K::arbitrary(u)?; - let value = V::arbitrary(u)?; - - map.set(&key, &value, working_set); - - Ok(map) - }) - } -} diff --git a/crates/sovereign-sdk/module-system/sov-modules-api/src/containers/map.rs b/crates/sovereign-sdk/module-system/sov-modules-api/src/containers/map.rs index 9c3843822..b4060dbf3 100644 --- a/crates/sovereign-sdk/module-system/sov-modules-api/src/containers/map.rs +++ b/crates/sovereign-sdk/module-system/sov-modules-api/src/containers/map.rs @@ -72,40 +72,3 @@ where &self.prefix } } - -#[cfg(feature = "arbitrary")] -impl<'a, K, V, Codec> StateMap -where - K: arbitrary::Arbitrary<'a>, - V: arbitrary::Arbitrary<'a>, - Codec: StateCodec + Default, - Codec::KeyCodec: StateKeyCodec, - Codec::ValueCodec: StateValueCodec, -{ - /// Returns an arbitrary [`StateMap`] instance. - /// - /// See the [`arbitrary`] crate for more information. - pub fn arbitrary_working_set( - u: &mut arbitrary::Unstructured<'a>, - working_set: &mut WorkingSet, - ) -> arbitrary::Result - where - S: Storage, - { - use arbitrary::Arbitrary; - - let prefix = Prefix::arbitrary(u)?; - let len = u.arbitrary_len::<(K, V)>()?; - let codec = Codec::default(); - let map = StateMap::with_codec(prefix, codec); - - (0..len).try_fold(map, |map, _| { - let key = K::arbitrary(u)?; - let value = V::arbitrary(u)?; - - map.set(&key, &value, working_set); - - Ok(map) - }) - } -} diff --git a/crates/sovereign-sdk/module-system/sov-modules-api/src/containers/offchain_map.rs b/crates/sovereign-sdk/module-system/sov-modules-api/src/containers/offchain_map.rs index b532a6aa6..d33b790e3 100644 --- a/crates/sovereign-sdk/module-system/sov-modules-api/src/containers/offchain_map.rs +++ b/crates/sovereign-sdk/module-system/sov-modules-api/src/containers/offchain_map.rs @@ -70,40 +70,3 @@ where &self.codec } } - -#[cfg(feature = "arbitrary")] -impl<'a, K, V, Codec> OffchainStateMap -where - K: arbitrary::Arbitrary<'a>, - V: arbitrary::Arbitrary<'a>, - Codec: StateCodec + Default, - Codec::KeyCodec: StateKeyCodec, - Codec::ValueCodec: StateValueCodec, -{ - /// Generates an arbitrary [`OffchainStateMap`] instance. - /// - /// See the [`arbitrary`] crate for more information. - pub fn arbitrary_working_set( - u: &mut arbitrary::Unstructured<'a>, - working_set: &mut OffchainWorkingSet, - ) -> arbitrary::Result - where - S: Storage, - { - use arbitrary::Arbitrary; - - let prefix = Prefix::arbitrary(u)?; - let len = u.arbitrary_len::<(K, V)>()?; - let codec = Codec::default(); - let map = Self::with_codec(prefix, codec); - - (0..len).try_fold(map, |map, _| { - let key = K::arbitrary(u)?; - let value = V::arbitrary(u)?; - - map.set(&key, &value, working_set); - - Ok(map) - }) - } -} diff --git a/crates/sovereign-sdk/module-system/sov-modules-api/src/default_context.rs b/crates/sovereign-sdk/module-system/sov-modules-api/src/default_context.rs index d57f5e733..a6c21a94f 100644 --- a/crates/sovereign-sdk/module-system/sov-modules-api/src/default_context.rs +++ b/crates/sovereign-sdk/module-system/sov-modules-api/src/default_context.rs @@ -16,7 +16,6 @@ use crate::default_signature::private_key::DefaultPrivateKey; use crate::default_signature::{DefaultPublicKey, DefaultSignature}; #[cfg(feature = "native")] -#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, Serialize, Deserialize)] pub struct DefaultContext { pub sender: Address, diff --git a/crates/sovereign-sdk/module-system/sov-modules-api/src/default_signature.rs b/crates/sovereign-sdk/module-system/sov-modules-api/src/default_signature.rs index 5bb59d855..1cfd27f57 100644 --- a/crates/sovereign-sdk/module-system/sov-modules-api/src/default_signature.rs +++ b/crates/sovereign-sdk/module-system/sov-modules-api/src/default_signature.rs @@ -129,41 +129,6 @@ pub mod private_key { self.pub_key().to_address::
() } } - - #[cfg(feature = "arbitrary")] - impl<'a> arbitrary::Arbitrary<'a> for DefaultPrivateKey { - fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { - use rand::rngs::StdRng; - use rand::SeedableRng; - - // it is important to generate the secret deterministically from the arbitrary argument - // so keys and signatures will be reproducible for a given seed. - // this unlocks fuzzy replay - let seed = <[u8; 32]>::arbitrary(u)?; - let rng = &mut StdRng::from_seed(seed); - let key_pair = SigningKey::generate(rng); - - Ok(Self { key_pair }) - } - } - - #[cfg(feature = "arbitrary")] - impl<'a> arbitrary::Arbitrary<'a> for DefaultPublicKey { - fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { - DefaultPrivateKey::arbitrary(u).map(|p| p.pub_key()) - } - } - - #[cfg(feature = "arbitrary")] - impl<'a> arbitrary::Arbitrary<'a> for DefaultSignature { - fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { - // the secret/public pair is lost; it is impossible to verify this signature - // to run a verification, generate the keys+payload individually - let payload_len = u.arbitrary_len::()?; - let payload = u.bytes(payload_len)?; - DefaultPrivateKey::arbitrary(u).map(|s| s.sign(payload)) - } - } } #[cfg_attr(feature = "native", derive(schemars::JsonSchema))] diff --git a/crates/sovereign-sdk/module-system/sov-modules-api/src/pub_key_hex.rs b/crates/sovereign-sdk/module-system/sov-modules-api/src/pub_key_hex.rs index eb6ab91c6..7fe434ec3 100644 --- a/crates/sovereign-sdk/module-system/sov-modules-api/src/pub_key_hex.rs +++ b/crates/sovereign-sdk/module-system/sov-modules-api/src/pub_key_hex.rs @@ -81,17 +81,6 @@ impl TryFrom<&PublicKeyHex> for DefaultPublicKey { } } -// TODO: Check this and it's relevance with gas_oracle_test -#[cfg(feature = "arbitrary")] -impl<'a> arbitrary::Arbitrary<'a> for PublicKeyHex { - fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result { - use sov_modules_core::PrivateKey; - let public_key = - crate::default_signature::private_key::DefaultPrivateKey::arbitrary(u)?.pub_key(); - Ok(PublicKeyHex::from(&public_key)) - } -} - #[cfg(test)] mod tests { use sov_modules_core::PrivateKey; diff --git a/crates/sovereign-sdk/module-system/sov-modules-core/Cargo.toml b/crates/sovereign-sdk/module-system/sov-modules-core/Cargo.toml index 9d3c23175..de72570e0 100644 --- a/crates/sovereign-sdk/module-system/sov-modules-core/Cargo.toml +++ b/crates/sovereign-sdk/module-system/sov-modules-core/Cargo.toml @@ -14,15 +14,12 @@ resolver = "2" [dependencies] anyhow = { workspace = true } -arbitrary = { workspace = true, optional = true } bech32 = { workspace = true } borsh = { workspace = true } derive_more = { workspace = true, features = ["display", "into"] } digest = { workspace = true } hex = { workspace = true } jmt = { workspace = true, optional = true } -proptest = { workspace = true, optional = true } -proptest-derive = { workspace = true, optional = true } schemars = { workspace = true, optional = true } serde = { workspace = true } sha2 = { workspace = true } @@ -44,13 +41,6 @@ sov-prover-storage-manager = { path = "../../full-node/sov-prover-storage-manage [features] default = ["std"] -arbitrary = [ - "dep:arbitrary", - "dep:proptest", - "dep:proptest-derive", - "proptest/default", - "std", -] native = [] std = [ "anyhow/default", diff --git a/crates/sovereign-sdk/module-system/sov-modules-core/src/common/address.rs b/crates/sovereign-sdk/module-system/sov-modules-core/src/common/address.rs index 10efb7e4a..4019e064e 100644 --- a/crates/sovereign-sdk/module-system/sov-modules-core/src/common/address.rs +++ b/crates/sovereign-sdk/module-system/sov-modules-core/src/common/address.rs @@ -25,10 +25,6 @@ use crate::common::Bech32ParseError; Into, Display, )] -#[cfg_attr( - feature = "arbitrary", - derive(arbitrary::Arbitrary, proptest_derive::Arbitrary) -)] #[serde(try_from = "String", into = "String")] #[display(fmt = "{}", "value")] pub struct AddressBech32 { @@ -37,7 +33,6 @@ pub struct AddressBech32 { /// Module address representation #[cfg_attr(all(feature = "native", feature = "std"), derive(schemars::JsonSchema))] -#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] #[derive(PartialEq, Clone, Copy, Eq, BorshDeserialize, BorshSerialize, Hash)] pub struct Address { addr: [u8; 32], diff --git a/crates/sovereign-sdk/module-system/sov-modules-core/src/common/bytes.rs b/crates/sovereign-sdk/module-system/sov-modules-core/src/common/bytes.rs index 9722d6e52..c9f859d09 100644 --- a/crates/sovereign-sdk/module-system/sov-modules-core/src/common/bytes.rs +++ b/crates/sovereign-sdk/module-system/sov-modules-core/src/common/bytes.rs @@ -84,10 +84,6 @@ impl AsRef> for AlignedVec { borsh::BorshSerialize ) )] -#[cfg_attr( - feature = "arbitrary", - derive(arbitrary::Arbitrary, proptest_derive::Arbitrary) -)] pub struct Prefix { prefix: AlignedVec, } @@ -222,34 +218,3 @@ impl From for Prefix { Prefix::new(combined_prefix) } } - -#[cfg(feature = "arbitrary")] -mod arbitrary_impls { - use arbitrary::{Arbitrary, Unstructured}; - use proptest::arbitrary::any; - use proptest::strategy::{BoxedStrategy, Strategy}; - - use super::*; - - impl<'a> Arbitrary<'a> for AlignedVec { - fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result { - u.arbitrary().map(|v: Vec| { - // we re-allocate so the capacity is also guaranteed to be aligned - Self::new(v[..(v.len() / Self::ALIGNMENT) * Self::ALIGNMENT].to_vec()) - }) - } - } - - impl proptest::arbitrary::Arbitrary for AlignedVec { - type Parameters = (); - type Strategy = BoxedStrategy; - - fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy { - any::>() - .prop_map(|v| { - Self::new(v[..(v.len() / Self::ALIGNMENT) * Self::ALIGNMENT].to_vec()) - }) - .boxed() - } - } -} diff --git a/crates/sovereign-sdk/module-system/sov-state/Cargo.toml b/crates/sovereign-sdk/module-system/sov-state/Cargo.toml index 80487274a..ef469e893 100644 --- a/crates/sovereign-sdk/module-system/sov-state/Cargo.toml +++ b/crates/sovereign-sdk/module-system/sov-state/Cargo.toml @@ -13,11 +13,8 @@ resolver = "2" [dependencies] anyhow = { workspace = true } -arbitrary = { workspace = true, optional = true } borsh = { workspace = true, features = ["rc", "bytes"] } bcs = { workspace = true } -proptest = { workspace = true, optional = true } -proptest-derive = { workspace = true, optional = true } serde = { workspace = true, features = ["rc"] } sov-rollup-interface = { path = "../../rollup-interface" } sov-modules-core = { path = "../sov-modules-core" } @@ -30,11 +27,5 @@ tempfile = { workspace = true } proptest = { workspace = true } [features] -arbitrary = [ - "dep:arbitrary", - "dep:proptest", - "dep:proptest-derive", - "sov-modules-core/arbitrary", -] default = [] native = ["sov-db"] diff --git a/crates/sovereign-sdk/rollup-interface/Cargo.toml b/crates/sovereign-sdk/rollup-interface/Cargo.toml index 969264b24..476aa8a1f 100644 --- a/crates/sovereign-sdk/rollup-interface/Cargo.toml +++ b/crates/sovereign-sdk/rollup-interface/Cargo.toml @@ -16,7 +16,6 @@ resolver = "2" [dependencies] anyhow = { workspace = true } -arbitrary = { workspace = true, optional = true } async-trait = { workspace = true } borsh = { workspace = true } bytes = { workspace = true, optional = true, default-features = true } @@ -36,7 +35,6 @@ serde_json = { workspace = true } default = ["std"] native = ["std", "tokio", "futures", "tracing"] testing = ["native"] -arbitrary = ["dep:arbitrary"] std = [ "anyhow/default", "borsh/default", diff --git a/crates/sovereign-sdk/rollup-interface/src/spec.rs b/crates/sovereign-sdk/rollup-interface/src/spec.rs index eaecfbf0d..abce77fe7 100644 --- a/crates/sovereign-sdk/rollup-interface/src/spec.rs +++ b/crates/sovereign-sdk/rollup-interface/src/spec.rs @@ -24,7 +24,6 @@ mod spec { Hash, )] #[borsh(use_discriminant = true)] - #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub enum SpecId { /// Genesis spec #[default] @@ -56,7 +55,6 @@ mod spec { Hash, )] #[borsh(use_discriminant = true)] - #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub enum SpecId { /// Genesis spec #[default]