From fab686ac05baf60004dffa03a88a05dba98cb954 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 11 Feb 2025 20:59:09 +0100 Subject: [PATCH] feat: append tx conditional to pooled tx (#14403) --- Cargo.lock | 1 + crates/optimism/rpc/Cargo.toml | 2 ++ crates/optimism/rpc/src/eth/ext.rs | 9 +++++---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e71b420d10db..839c2f53917f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8635,6 +8635,7 @@ dependencies = [ "reth-optimism-forks", "reth-optimism-payload-builder", "reth-optimism-primitives", + "reth-optimism-txpool", "reth-primitives", "reth-primitives-traits", "reth-provider", diff --git a/crates/optimism/rpc/Cargo.toml b/crates/optimism/rpc/Cargo.toml index 7ee491a61ad4..be280575a513 100644 --- a/crates/optimism/rpc/Cargo.toml +++ b/crates/optimism/rpc/Cargo.toml @@ -35,6 +35,7 @@ reth-optimism-chainspec.workspace = true reth-optimism-consensus.workspace = true reth-optimism-evm.workspace = true reth-optimism-payload-builder.workspace = true +reth-optimism-txpool.workspace = true # TODO remove node-builder import reth-optimism-primitives = { workspace = true, features = ["reth-codec", "serde-bincode-compat"] } reth-optimism-forks.workspace = true @@ -79,6 +80,7 @@ optimism = [ "reth-optimism-consensus/optimism", "reth-optimism-payload-builder/optimism", "reth-optimism-primitives/optimism", + "reth-optimism-txpool/optimism", ] client = [ "jsonrpsee/client", diff --git a/crates/optimism/rpc/src/eth/ext.rs b/crates/optimism/rpc/src/eth/ext.rs index 0be0073d5a64..0c497a66e5c3 100644 --- a/crates/optimism/rpc/src/eth/ext.rs +++ b/crates/optimism/rpc/src/eth/ext.rs @@ -5,6 +5,7 @@ use alloy_eips::BlockNumberOrTag; use alloy_primitives::{Bytes, B256}; use alloy_rpc_types_eth::erc4337::TransactionConditional; use jsonrpsee_core::RpcResult; +use reth_optimism_txpool::conditional::MaybeConditionalTransaction; use reth_provider::{BlockReaderIdExt, StateProviderFactory}; use reth_rpc_eth_api::L2EthApiExtServer; use reth_rpc_eth_types::utils::recover_raw_transaction; @@ -49,7 +50,7 @@ impl L2EthApiExtServer for OpEthApiExt where N: OpNodeCore + 'static, N::Provider: BlockReaderIdExt + StateProviderFactory, - N::Pool: TransactionPool, + N::Pool: TransactionPool, { async fn send_raw_transaction_conditional( &self, @@ -66,7 +67,7 @@ where OpEthApiError::Eth(reth_rpc_eth_types::EthApiError::FailedToDecodeSignedTransaction) })?; - let tx = ::Transaction::from_pooled(recovered_tx); + let mut tx = ::Transaction::from_pooled(recovered_tx); // get current header let header_not_found = || { @@ -97,8 +98,8 @@ where .map_err(OpEthApiError::Sequencer)?; Ok(*tx.hash()) } else { - // otherwise, add to pool - // TODO: include conditional + // otherwise, add to pool with the appended conditional + tx.set_conditional(condition); let hash = self.pool().add_transaction(TransactionOrigin::External, tx).await.map_err( |e| OpEthApiError::Eth(reth_rpc_eth_types::EthApiError::PoolError(e.into())), )?;