Skip to content

Commit

Permalink
chore: remove MaybeArbitrary trait (#13301)
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr authored Dec 11, 2024
1 parent 8f6492d commit 61099cd
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 29 deletions.
4 changes: 1 addition & 3 deletions crates/primitives-traits/src/block/body.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//! Block body abstraction.
use crate::{
BlockHeader, FullSignedTx, InMemorySize, MaybeArbitrary, MaybeSerde, MaybeSerdeBincodeCompat,
SignedTransaction,
BlockHeader, FullSignedTx, InMemorySize, MaybeSerde, MaybeSerdeBincodeCompat, SignedTransaction,
};
use alloc::{fmt, vec::Vec};
use alloy_consensus::Transaction;
Expand All @@ -28,7 +27,6 @@ pub trait BlockBody:
+ alloy_rlp::Decodable
+ InMemorySize
+ MaybeSerde
+ MaybeArbitrary
+ MaybeSerdeBincodeCompat
+ 'static
{
Expand Down
3 changes: 1 addition & 2 deletions crates/primitives-traits/src/block/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::{fmt, hash::Hash};

use alloy_primitives::Sealable;

use crate::{InMemorySize, MaybeArbitrary, MaybeCompact, MaybeSerde, MaybeSerdeBincodeCompat};
use crate::{InMemorySize, MaybeCompact, MaybeSerde, MaybeSerdeBincodeCompat};

/// Helper trait that unifies all behaviour required by block header to support full node
/// operations.
Expand All @@ -29,7 +29,6 @@ pub trait BlockHeader:
+ Sealable
+ InMemorySize
+ MaybeSerde
+ MaybeArbitrary
+ MaybeSerdeBincodeCompat
+ AsRef<Self>
+ 'static
Expand Down
6 changes: 1 addition & 5 deletions crates/primitives-traits/src/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ pub mod header;
use alloc::fmt;
use alloy_rlp::{Decodable, Encodable};

use crate::{
BlockBody, BlockHeader, FullBlockBody, FullBlockHeader, InMemorySize, MaybeArbitrary,
MaybeSerde,
};
use crate::{BlockBody, BlockHeader, FullBlockBody, FullBlockHeader, InMemorySize, MaybeSerde};

/// Helper trait that unifies all behaviour required by block to support full node operations.
pub trait FullBlock:
Expand Down Expand Up @@ -42,7 +39,6 @@ pub trait Block:
+ Eq
+ InMemorySize
+ MaybeSerde
+ MaybeArbitrary
+ Encodable
+ Decodable
{
Expand Down
12 changes: 0 additions & 12 deletions crates/primitives-traits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,6 @@ pub use size::InMemorySize;
pub mod node;
pub use node::{BodyTy, FullNodePrimitives, HeaderTy, NodePrimitives, ReceiptTy};

/// Helper trait that requires arbitrary implementation if the feature is enabled.
#[cfg(any(feature = "test-utils", feature = "arbitrary"))]
pub trait MaybeArbitrary: for<'a> arbitrary::Arbitrary<'a> {}
/// Helper trait that requires arbitrary implementation if the feature is enabled.
#[cfg(not(any(feature = "test-utils", feature = "arbitrary")))]
pub trait MaybeArbitrary {}

#[cfg(any(feature = "test-utils", feature = "arbitrary"))]
impl<T> MaybeArbitrary for T where T: for<'a> arbitrary::Arbitrary<'a> {}
#[cfg(not(any(feature = "test-utils", feature = "arbitrary")))]
impl<T> MaybeArbitrary for T {}

/// Helper trait that requires de-/serialize implementation since `serde` feature is enabled.
#[cfg(feature = "serde")]
pub trait MaybeSerde: serde::Serialize + for<'de> serde::Deserialize<'de> {}
Expand Down
3 changes: 1 addition & 2 deletions crates/primitives-traits/src/receipt.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Receipt abstraction
use crate::{InMemorySize, MaybeArbitrary, MaybeCompact, MaybeSerde};
use crate::{InMemorySize, MaybeCompact, MaybeSerde};
use alloc::vec::Vec;
use alloy_consensus::{
Eip2718EncodableReceipt, RlpDecodableReceipt, RlpEncodableReceipt, TxReceipt, Typed2718,
Expand Down Expand Up @@ -28,7 +28,6 @@ pub trait Receipt:
+ Typed2718
+ MaybeSerde
+ InMemorySize
+ MaybeArbitrary
{
}

Expand Down
4 changes: 1 addition & 3 deletions crates/primitives-traits/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub mod signed;

pub mod error;

use crate::{InMemorySize, MaybeArbitrary, MaybeCompact, MaybeSerde};
use crate::{InMemorySize, MaybeCompact, MaybeSerde};
use core::{fmt, hash::Hash};

/// Helper trait that unifies all behaviour required by transaction to support full node operations.
Expand All @@ -26,7 +26,6 @@ pub trait Transaction:
+ alloy_consensus::Transaction
+ InMemorySize
+ MaybeSerde
+ MaybeArbitrary
{
}

Expand All @@ -42,6 +41,5 @@ impl<T> Transaction for T where
+ alloy_consensus::Transaction
+ InMemorySize
+ MaybeSerde
+ MaybeArbitrary
{
}
3 changes: 1 addition & 2 deletions crates/primitives-traits/src/transaction/signed.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! API of a signed transaction.
use crate::{FillTxEnv, InMemorySize, MaybeArbitrary, MaybeCompact, MaybeSerde};
use crate::{FillTxEnv, InMemorySize, MaybeCompact, MaybeSerde};
use alloc::{fmt, vec::Vec};
use alloy_eips::eip2718::{Decodable2718, Encodable2718};
use alloy_primitives::{keccak256, Address, PrimitiveSignature, TxHash, B256};
Expand Down Expand Up @@ -28,7 +28,6 @@ pub trait SignedTransaction:
+ Decodable2718
+ alloy_consensus::Transaction
+ MaybeSerde
+ MaybeArbitrary
+ InMemorySize
{
/// Returns reference to transaction hash.
Expand Down

0 comments on commit 61099cd

Please sign in to comment.