mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: improve tx forwarding (#9878)
This commit is contained in:
@ -91,6 +91,13 @@ impl SequencerClient {
|
|||||||
.body(body)
|
.body(body)
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
|
.inspect_err(|err| {
|
||||||
|
tracing::warn!(
|
||||||
|
target = "rpc::eth",
|
||||||
|
%err,
|
||||||
|
"Failed to forward transaction to sequencer",
|
||||||
|
);
|
||||||
|
})
|
||||||
.map_err(SequencerRpcError::HttpError)?;
|
.map_err(SequencerRpcError::HttpError)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@ -22,7 +22,7 @@ use reth_rpc_types::{
|
|||||||
AnyTransactionReceipt, Transaction, TransactionRequest, TypedTransactionRequest,
|
AnyTransactionReceipt, Transaction, TransactionRequest, TypedTransactionRequest,
|
||||||
};
|
};
|
||||||
use reth_rpc_types_compat::transaction::from_recovered_with_block_context;
|
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};
|
use crate::{FromEthApiError, IntoEthApiError};
|
||||||
|
|
||||||
@ -249,19 +249,21 @@ pub trait EthTransactions: LoadTransaction {
|
|||||||
tx: Bytes,
|
tx: Bytes,
|
||||||
) -> impl Future<Output = Result<B256, Self::Error>> + Send {
|
) -> impl Future<Output = Result<B256, Self::Error>> + Send {
|
||||||
async move {
|
async move {
|
||||||
// On optimism, transactions are forwarded directly to the sequencer to be included in
|
let recovered = recover_raw_transaction(tx.clone())?;
|
||||||
// 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 pool_transaction =
|
let pool_transaction =
|
||||||
<Self::Pool as TransactionPool>::Transaction::from_recovered_pooled_transaction(
|
<Self::Pool as TransactionPool>::Transaction::from_recovered_pooled_transaction(
|
||||||
recovered,
|
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
|
// submit the transaction to the pool with a `Local` origin
|
||||||
let hash = self
|
let hash = self
|
||||||
.pool()
|
.pool()
|
||||||
|
|||||||
Reference in New Issue
Block a user