Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use OpPooledTransaction in OpNetworkPrimitives #13417

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions Cargo.lock

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

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -477,11 +477,11 @@ alloy-transport-ipc = { version = "0.8.2", default-features = false }
alloy-transport-ws = { version = "0.8.2", default-features = false }

# op
op-alloy-rpc-types = "0.8.4"
op-alloy-rpc-types-engine = "0.8.4"
op-alloy-rpc-jsonrpsee = "0.8.4"
op-alloy-network = "0.8.4"
op-alloy-consensus = "0.8.4"
op-alloy-rpc-types = "0.8.5"
op-alloy-rpc-types-engine = "0.8.5"
op-alloy-rpc-jsonrpsee = "0.8.5"
op-alloy-network = "0.8.5"
op-alloy-consensus = "0.8.5"

# misc
aquamarine = "0.6"
Expand Down
4 changes: 2 additions & 2 deletions crates/optimism/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ reth-optimism-primitives = { workspace = true, features = ["serde"] }
# revm with required optimism features
revm = { workspace = true, features = ["secp256k1", "blst", "c-kzg"] }

# ethereum
# alloy
alloy-eips.workspace = true
alloy-primitives.workspace = true
op-alloy-rpc-types-engine.workspace = true
alloy-rpc-types-engine.workspace = true
alloy-consensus.workspace = true
op-alloy-consensus.workspace = true

# misc
clap.workspace = true
Expand All @@ -78,7 +79,6 @@ reth-revm = { workspace = true, features = ["test-utils"] }
reth-tasks.workspace = true

alloy-primitives.workspace = true
op-alloy-consensus.workspace = true
alloy-signer-local.workspace = true
alloy-network.workspace = true
alloy-consensus.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,6 @@ impl NetworkPrimitives for OpNetworkPrimitives {
type BlockBody = reth_primitives::BlockBody;
type Block = reth_primitives::Block;
type BroadcastedTransaction = reth_primitives::TransactionSigned;
type PooledTransaction = reth_primitives::PooledTransaction;
type PooledTransaction = op_alloy_consensus::OpPooledTransaction;
type Receipt = reth_primitives::Receipt;
}
45 changes: 42 additions & 3 deletions crates/optimism/primitives/src/transaction/signed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use crate::OpTxType;
use alloc::vec::Vec;
use alloy_consensus::{
transaction::RlpEcdsaTx, SignableTransaction, Transaction, TxEip1559, TxEip2930, TxEip7702,
TxLegacy, Typed2718,
transaction::RlpEcdsaTx, SignableTransaction, Signed, Transaction, TxEip1559, TxEip2930,
TxEip7702, TxLegacy, Typed2718,
};
use alloy_eips::{
eip2718::{Decodable2718, Eip2718Error, Eip2718Result, Encodable2718},
Expand All @@ -22,7 +22,7 @@ use core::{
use derive_more::{AsRef, Deref};
#[cfg(not(feature = "std"))]
use once_cell::sync::OnceCell as OnceLock;
use op_alloy_consensus::{OpTypedTransaction, TxDeposit};
use op_alloy_consensus::{OpPooledTransaction, OpTypedTransaction, TxDeposit};
#[cfg(any(test, feature = "reth-codec"))]
use proptest as _;
use reth_primitives::transaction::{recover_signer, recover_signer_unchecked};
Expand Down Expand Up @@ -418,6 +418,45 @@ impl Hash for OpTransactionSigned {
}
}

impl From<Signed<TxEip7702>> for OpTransactionSigned {
fn from(value: Signed<TxEip7702>) -> Self {
let (tx, signature, hash) = value.into_parts();
Self { hash: hash.into(), signature, transaction: tx.into() }
}
}

impl From<Signed<TxEip1559>> for OpTransactionSigned {
fn from(value: Signed<TxEip1559>) -> Self {
let (tx, signature, hash) = value.into_parts();
Self { hash: hash.into(), signature, transaction: tx.into() }
}
}

impl From<Signed<TxEip2930>> for OpTransactionSigned {
fn from(value: Signed<TxEip2930>) -> Self {
let (tx, signature, hash) = value.into_parts();
Self { hash: hash.into(), signature, transaction: tx.into() }
}
}

impl From<Signed<TxLegacy>> for OpTransactionSigned {
fn from(value: Signed<TxLegacy>) -> Self {
let (tx, signature, hash) = value.into_parts();
Self { hash: hash.into(), signature, transaction: tx.into() }
}
}

impl From<OpPooledTransaction> for OpTransactionSigned {
fn from(tx: OpPooledTransaction) -> Self {
match tx {
OpPooledTransaction::Legacy(signed) => signed.into(),
OpPooledTransaction::Eip2930(signed) => signed.into(),
OpPooledTransaction::Eip1559(signed) => signed.into(),
OpPooledTransaction::Eip7702(signed) => signed.into(),
}
}
}

#[cfg(any(test, feature = "arbitrary"))]
impl<'a> arbitrary::Arbitrary<'a> for OpTransactionSigned {
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
Expand Down
Loading