Skip to content

Commit

Permalink
Cleanup remove arbitrary (#1605)
Browse files Browse the repository at this point in the history
  • Loading branch information
eyusufatik authored Dec 13, 2024
1 parent e282dab commit 170138b
Show file tree
Hide file tree
Showing 27 changed files with 1 addition and 455 deletions.
29 changes: 0 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
1 change: 0 additions & 1 deletion bin/citrea/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
1 change: 0 additions & 1 deletion crates/ethereum-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
10 changes: 1 addition & 9 deletions crates/sovereign-sdk/full-node/db/sov-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
52 changes: 0 additions & 52 deletions crates/sovereign-sdk/full-node/db/sov-db/src/schema/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<u8>>);

impl DbBytes {
Expand Down Expand Up @@ -62,7 +61,6 @@ pub(crate) type StateKey = Vec<u8>;
/// 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,
Expand Down Expand Up @@ -327,7 +325,6 @@ impl TryFrom<StoredSoftConfirmation> 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,
Expand Down Expand Up @@ -373,66 +370,17 @@ 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 {
fn from(value: $name) -> Self {
value.0
}
}

#[cfg(feature = "arbitrary")]
impl<'a> ::arbitrary::Arbitrary<'a> for $name {
fn arbitrary(u: &mut ::arbitrary::Unstructured<'a>) -> ::arbitrary::Result<Self> {
u.arbitrary().map($name)
}
}
};
}

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<Self> {
u.arbitrary().map(DbBytes::new)
}
}

impl<'a> ::arbitrary::Arbitrary<'a> for StoredTransaction {
fn arbitrary(u: &mut ::arbitrary::Unstructured<'a>) -> ::arbitrary::Result<Self> {
Ok(StoredTransaction {
hash: u.arbitrary()?,
body: u.arbitrary()?,
})
}
}

impl<'a> ::arbitrary::Arbitrary<'a> for StoredBatch {
fn arbitrary(u: &mut ::arbitrary::Unstructured<'a>) -> ::arbitrary::Result<Self> {
Ok(StoredBatch {
hash: u.arbitrary()?,
txs: u.arbitrary()?,
})
}
}

impl<'a> ::arbitrary::Arbitrary<'a> for StoredSlot {
fn arbitrary(u: &mut ::arbitrary::Unstructured<'a>) -> ::arbitrary::Result<Self> {
Ok(StoredSlot {
hash: u.arbitrary()?,
extra_data: u.arbitrary()?,
batches: u.arbitrary()?,
})
}
}
}
3 changes: 0 additions & 3 deletions crates/sovereign-sdk/full-node/db/sov-schema-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -33,4 +31,3 @@ sov-schema-db = { path = ".", features = ["test-utils"] }
[features]
default = []
test-utils = ["dep:byteorder"]
arbitrary = ["dep:proptest", "dep:proptest-derive"]
1 change: 0 additions & 1 deletion crates/sovereign-sdk/full-node/db/sov-schema-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ pub type SchemaKey = Vec<u8>;
/// Readability alias for a value in the DB.
pub type SchemaValue = Vec<u8>;

#[cfg_attr(feature = "arbitrary", derive(proptest_derive::Arbitrary))]
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
/// Represents operation written to the database
pub enum Operation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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::<BTreeMap<SchemaKey, Operation>>(), columns.len())
.prop_map::<SchemaBatch, _>(|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<Self>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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",
Expand Down
Loading

0 comments on commit 170138b

Please sign in to comment.