Skip to content

Commit 57f77ac

Browse files
authored
fix: fail send_raw_transaction if forwarding fails (paradigmxyz#15867)
1 parent 67e34b5 commit 57f77ac

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

crates/optimism/rpc/src/eth/transaction.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use reth_node_api::FullNodeComponents;
99
use reth_optimism_primitives::{OpReceipt, OpTransactionSigned};
1010
use reth_rpc_eth_api::{
1111
helpers::{EthSigner, EthTransactions, LoadTransaction, SpawnBlocking},
12-
FromEthApiError, FullEthApiTypes, RpcNodeCore, RpcNodeCoreExt, TransactionCompat,
12+
EthApiTypes, FromEthApiError, FullEthApiTypes, RpcNodeCore, RpcNodeCoreExt, TransactionCompat,
1313
};
1414
use reth_rpc_eth_types::{utils::recover_raw_transaction, EthApiError};
1515
use reth_storage_api::{
@@ -21,7 +21,7 @@ use crate::{eth::OpNodeCore, OpEthApi, OpEthApiError, SequencerClient};
2121

2222
impl<N> EthTransactions for OpEthApi<N>
2323
where
24-
Self: LoadTransaction<Provider: BlockReaderIdExt>,
24+
Self: LoadTransaction<Provider: BlockReaderIdExt> + EthApiTypes<Error = OpEthApiError>,
2525
N: OpNodeCore<Provider: BlockReader<Transaction = ProviderTx<Self::Provider>>>,
2626
{
2727
fn signers(&self) -> &parking_lot::RwLock<Vec<Box<dyn EthSigner<ProviderTx<Self::Provider>>>>> {
@@ -39,9 +39,19 @@ where
3939
// blocks that it builds.
4040
if let Some(client) = self.raw_tx_forwarder().as_ref() {
4141
tracing::debug!(target: "rpc::eth", hash = %pool_transaction.hash(), "forwarding raw transaction to sequencer");
42-
let _ = client.forward_raw_transaction(&tx).await.inspect_err(|err| {
42+
let hash = client.forward_raw_transaction(&tx).await.inspect_err(|err| {
4343
tracing::debug!(target: "rpc::eth", %err, hash=% *pool_transaction.hash(), "failed to forward raw transaction");
44-
});
44+
})?;
45+
46+
// Retain tx in local tx pool after forwarding, for local RPC usage.
47+
let _ = self
48+
.pool()
49+
.add_transaction(TransactionOrigin::Local, pool_transaction)
50+
.await.inspect_err(|err| {
51+
tracing::warn!(target: "rpc::eth", %err, %hash, "successfully sent tx to sequencer, but failed to persist in local tx pool");
52+
});
53+
54+
return Ok(hash)
4555
}
4656

4757
// submit the transaction to the pool with a `Local` origin

0 commit comments

Comments
 (0)