chore: improve tx forwarding (#9878)

This commit is contained in:
Matthias Seitz
2024-07-29 23:31:03 +02:00
committed by GitHub
parent 700caca7a8
commit 85b326756d
2 changed files with 18 additions and 9 deletions

View File

@ -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(())

View File

@ -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<Output = Result<B256, Self::Error>> + 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 =
<Self::Pool as TransactionPool>::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()