Skip to content

Commit

Permalink
Enable reth-optimism-primitives/arbitrary for reth-optimism-node/test…
Browse files Browse the repository at this point in the history
…-utils
  • Loading branch information
emhane committed Nov 23, 2024
1 parent be2d4c6 commit 6aa22b9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions crates/optimism/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
31 changes: 29 additions & 2 deletions crates/optimism/primitives/src/tx_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,42 @@ use derive_more::{
Display,
};
use op_alloy_consensus::OpTxType as AlloyOpTxType;
use reth_primitives_traits::InMemorySize;
use reth_primitives_traits::{InMemorySize, TxType};

/// Wrapper type for [`op_alloy_consensus::OpTxType`] to implement
/// [`TxType`](reth_primitives_traits::TxType) trait.
/// [`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);

impl TxType for OpTxType {
#[inline]
fn is_legacy(&self) -> bool {
matches!(self.0, AlloyOpTxType::Legacy)
}

#[inline]
fn is_eip2930(&self) -> bool {
matches!(self.0, AlloyOpTxType::Eip2930)
}

#[inline]
fn is_eip1559(&self) -> bool {
matches!(self.0, AlloyOpTxType::Eip1559)
}

#[inline]
fn is_eip4844(&self) -> bool {
false
}

#[inline]
fn is_eip7702(&self) -> bool {
matches!(self.0, AlloyOpTxType::Eip7702)
}
}

impl InMemorySize for OpTxType {
/// Calculates a heuristic for the in-memory size of the [`OpTxType`].
#[inline]
Expand Down

0 comments on commit 6aa22b9

Please sign in to comment.