From 85b326756d11d1a4f4630f3036fccd9a9dffaa76 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 29 Jul 2024 23:31:03 +0200 Subject: [PATCH] chore: improve tx forwarding (#9878) --- crates/optimism/node/src/rpc.rs | 7 +++++++ .../rpc-eth-api/src/helpers/transaction.rs | 20 ++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/crates/optimism/node/src/rpc.rs b/crates/optimism/node/src/rpc.rs index d7c3f49efb..63e28300b5 100644 --- a/crates/optimism/node/src/rpc.rs +++ b/crates/optimism/node/src/rpc.rs @@ -91,6 +91,13 @@ impl SequencerClient { .body(body) .send() .await + .inspect_err(|err| { + tracing::warn!( + target = "rpc::eth", + %err, + "Failed to forward transaction to sequencer", + ); + }) .map_err(SequencerRpcError::HttpError)?; Ok(()) diff --git a/crates/rpc/rpc-eth-api/src/helpers/transaction.rs b/crates/rpc/rpc-eth-api/src/helpers/transaction.rs index 4231cd6724..da8496f757 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/transaction.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/transaction.rs @@ -22,7 +22,7 @@ use reth_rpc_types::{ AnyTransactionReceipt, Transaction, TransactionRequest, TypedTransactionRequest, }; use reth_rpc_types_compat::transaction::from_recovered_with_block_context; -use reth_transaction_pool::{TransactionOrigin, TransactionPool}; +use reth_transaction_pool::{PoolTransaction, TransactionOrigin, TransactionPool}; use crate::{FromEthApiError, IntoEthApiError}; @@ -249,19 +249,21 @@ pub trait EthTransactions: LoadTransaction { tx: Bytes, ) -> impl Future> + Send { async move { - // On optimism, transactions are forwarded directly to the sequencer to be included in - // blocks that it builds. - if let Some(client) = self.raw_tx_forwarder().as_ref() { - tracing::debug!( target: "rpc::eth", "forwarding raw transaction to"); - client.forward_raw_transaction(&tx).await?; - } - - let recovered = recover_raw_transaction(tx)?; + let recovered = recover_raw_transaction(tx.clone())?; let pool_transaction = ::Transaction::from_recovered_pooled_transaction( recovered, ); + // On optimism, transactions are forwarded directly to the sequencer to be included in + // blocks that it builds. + if let Some(client) = self.raw_tx_forwarder().as_ref() { + tracing::debug!( target: "rpc::eth", "forwarding raw transaction to"); + let _ = client.forward_raw_transaction(&tx).await.inspect_err(|err| { + tracing::debug!(target: "rpc::eth", %err, hash=% *pool_transaction.hash(), "failed to forward raw transaction"); + }); + } + // submit the transaction to the pool with a `Local` origin let hash = self .pool()