mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Revert "Revert "chore(sdk): Add MaybeArbitrary as super trait"" (#12810)
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
This commit is contained in:
@ -48,7 +48,8 @@ optimism = [
|
||||
]
|
||||
|
||||
dev = [
|
||||
"reth-optimism-cli/dev"
|
||||
"reth-optimism-cli/dev",
|
||||
"reth-optimism-primitives/arbitrary",
|
||||
]
|
||||
|
||||
min-error-logs = ["tracing/release_max_level_error"]
|
||||
|
||||
@ -48,7 +48,7 @@ reth-primitives = { workspace = true, features = ["test-utils"] }
|
||||
reth-optimism-chainspec.workspace = true
|
||||
alloy-genesis.workspace = true
|
||||
alloy-consensus.workspace = true
|
||||
reth-optimism-primitives.workspace = true
|
||||
reth-optimism-primitives = { workspace = true, features = ["arbitrary"] }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
|
||||
@ -119,6 +119,7 @@ test-utils = [
|
||||
"reth-trie-db/test-utils",
|
||||
"revm/test-utils",
|
||||
"reth-optimism-node/test-utils",
|
||||
"reth-optimism-primitives/arbitrary",
|
||||
]
|
||||
reth-codec = [
|
||||
"reth-primitives/reth-codec",
|
||||
|
||||
@ -34,9 +34,13 @@ serde = { workspace = true, optional = true }
|
||||
# misc
|
||||
derive_more.workspace = true
|
||||
|
||||
# test-utils
|
||||
arbitrary = { workspace = true, features = ["derive"], optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
reth-codecs = { workspace = true, features = ["test-utils"] }
|
||||
rstest.workspace = true
|
||||
arbitrary.workspace = true
|
||||
|
||||
[features]
|
||||
default = ["std", "reth-codec"]
|
||||
@ -65,3 +69,13 @@ serde = [
|
||||
"reth-codecs/serde",
|
||||
"op-alloy-consensus/serde",
|
||||
]
|
||||
arbitrary = [
|
||||
"dep:arbitrary",
|
||||
"reth-primitives-traits/arbitrary",
|
||||
"reth-primitives/arbitrary",
|
||||
"reth-codecs?/arbitrary",
|
||||
"op-alloy-consensus/arbitrary",
|
||||
"alloy-consensus/arbitrary",
|
||||
"alloy-eips/arbitrary",
|
||||
"alloy-primitives/arbitrary",
|
||||
]
|
||||
@ -2,10 +2,11 @@
|
||||
//! `OpTxType` implements `reth_primitives_traits::TxType`.
|
||||
//! This type is required because a `Compact` impl is needed on the deposit tx type.
|
||||
|
||||
use core::fmt::Debug;
|
||||
|
||||
use alloy_primitives::{U64, U8};
|
||||
use alloy_rlp::{Decodable, Encodable, Error};
|
||||
use bytes::BufMut;
|
||||
use core::fmt::Debug;
|
||||
use derive_more::{
|
||||
derive::{From, Into},
|
||||
Display,
|
||||
@ -13,8 +14,10 @@ use derive_more::{
|
||||
use op_alloy_consensus::OpTxType as AlloyOpTxType;
|
||||
use reth_primitives_traits::{InMemorySize, TxType};
|
||||
|
||||
/// Wrapper type for [`op_alloy_consensus::OpTxType`] to implement [`TxType`] trait.
|
||||
/// Wrapper type for [`op_alloy_consensus::OpTxType`] to implement
|
||||
/// [`TxType`] trait.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Display, Ord, Hash, From, Into)]
|
||||
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
|
||||
#[into(u8)]
|
||||
pub struct OpTxType(AlloyOpTxType);
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ use alloc::fmt;
|
||||
|
||||
use alloy_consensus::Transaction;
|
||||
|
||||
use crate::{FullSignedTx, InMemorySize, MaybeSerde};
|
||||
use crate::{FullSignedTx, InMemorySize, MaybeArbitrary, MaybeSerde};
|
||||
|
||||
/// Helper trait that unifies all behaviour required by transaction to support full node operations.
|
||||
pub trait FullBlockBody: BlockBody<Transaction: FullSignedTx> {}
|
||||
@ -26,6 +26,7 @@ pub trait BlockBody:
|
||||
+ alloy_rlp::Decodable
|
||||
+ InMemorySize
|
||||
+ MaybeSerde
|
||||
+ MaybeArbitrary
|
||||
{
|
||||
/// Ordered list of signed transactions as committed in block.
|
||||
type Transaction: Transaction;
|
||||
|
||||
@ -4,7 +4,7 @@ use core::fmt;
|
||||
|
||||
use alloy_primitives::Sealable;
|
||||
|
||||
use crate::{InMemorySize, MaybeCompact, MaybeSerde};
|
||||
use crate::{InMemorySize, MaybeArbitrary, MaybeCompact, MaybeSerde};
|
||||
|
||||
/// Helper trait that unifies all behaviour required by block header to support full node
|
||||
/// operations.
|
||||
@ -28,6 +28,7 @@ pub trait BlockHeader:
|
||||
+ Sealable
|
||||
+ InMemorySize
|
||||
+ MaybeSerde
|
||||
+ MaybeArbitrary
|
||||
{
|
||||
}
|
||||
|
||||
@ -46,5 +47,6 @@ impl<T> BlockHeader for T where
|
||||
+ Sealable
|
||||
+ InMemorySize
|
||||
+ MaybeSerde
|
||||
+ MaybeArbitrary
|
||||
{
|
||||
}
|
||||
|
||||
@ -5,7 +5,9 @@ pub mod header;
|
||||
|
||||
use alloc::fmt;
|
||||
|
||||
use crate::{BlockHeader, FullBlockBody, FullBlockHeader, InMemorySize, MaybeSerde};
|
||||
use crate::{
|
||||
BlockHeader, FullBlockBody, FullBlockHeader, InMemorySize, MaybeArbitrary, MaybeSerde,
|
||||
};
|
||||
|
||||
/// Helper trait that unifies all behaviour required by block to support full node operations.
|
||||
pub trait FullBlock:
|
||||
@ -26,7 +28,17 @@ impl<T> FullBlock for T where
|
||||
// senders
|
||||
#[auto_impl::auto_impl(&, Arc)]
|
||||
pub trait Block:
|
||||
Send + Sync + Unpin + Clone + Default + fmt::Debug + PartialEq + Eq + InMemorySize + MaybeSerde
|
||||
Send
|
||||
+ Sync
|
||||
+ Unpin
|
||||
+ Clone
|
||||
+ Default
|
||||
+ fmt::Debug
|
||||
+ PartialEq
|
||||
+ Eq
|
||||
+ InMemorySize
|
||||
+ MaybeSerde
|
||||
+ MaybeArbitrary
|
||||
{
|
||||
/// Header part of the block.
|
||||
type Header: BlockHeader + 'static;
|
||||
|
||||
@ -159,9 +159,12 @@ impl<H> From<SealedHeader<H>> for Sealed<H> {
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "arbitrary"))]
|
||||
impl<'a> arbitrary::Arbitrary<'a> for SealedHeader {
|
||||
impl<'a, H> arbitrary::Arbitrary<'a> for SealedHeader<H>
|
||||
where
|
||||
H: for<'b> arbitrary::Arbitrary<'b> + Sealable,
|
||||
{
|
||||
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
|
||||
let header = Header::arbitrary(u)?;
|
||||
let header = H::arbitrary(u)?;
|
||||
|
||||
Ok(Self::seal(header))
|
||||
}
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
//! Receipt abstraction
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use core::fmt;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use alloy_consensus::TxReceipt;
|
||||
use alloy_primitives::B256;
|
||||
|
||||
use crate::{InMemorySize, MaybeCompact, MaybeSerde};
|
||||
use crate::{InMemorySize, MaybeArbitrary, MaybeCompact, MaybeSerde};
|
||||
|
||||
/// Helper trait that unifies all behaviour required by receipt to support full node operations.
|
||||
pub trait FullReceipt: Receipt + MaybeCompact {}
|
||||
@ -27,6 +27,7 @@ pub trait Receipt:
|
||||
+ alloy_rlp::Decodable
|
||||
+ MaybeSerde
|
||||
+ InMemorySize
|
||||
+ MaybeArbitrary
|
||||
{
|
||||
/// Returns transaction type.
|
||||
fn tx_type(&self) -> u8;
|
||||
|
||||
@ -4,7 +4,7 @@ use core::fmt;
|
||||
|
||||
use alloy_primitives::{U64, U8};
|
||||
|
||||
use crate::{InMemorySize, MaybeCompact};
|
||||
use crate::{InMemorySize, MaybeArbitrary, MaybeCompact};
|
||||
|
||||
/// Helper trait that unifies all behaviour required by transaction type ID to support full node
|
||||
/// operations.
|
||||
@ -33,6 +33,7 @@ pub trait TxType:
|
||||
+ alloy_rlp::Encodable
|
||||
+ alloy_rlp::Decodable
|
||||
+ InMemorySize
|
||||
+ MaybeArbitrary
|
||||
{
|
||||
/// Returns `true` if this is a legacy transaction.
|
||||
fn is_legacy(&self) -> bool;
|
||||
|
||||
@ -131,4 +131,5 @@ test-utils = [
|
||||
"revm/test-utils",
|
||||
"reth-prune-types/test-utils",
|
||||
"reth-stages-types/test-utils",
|
||||
"reth-optimism-primitives?/arbitrary",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user