From d23928d53e31ca4c2a62eff6587af9f902b74e1e Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xkitsune@protonmail.com> Date: Tue, 15 Oct 2024 14:21:08 -0400 Subject: [PATCH] forward transaction after validation --- world-chain-builder/src/rpc/transaction.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/world-chain-builder/src/rpc/transaction.rs b/world-chain-builder/src/rpc/transaction.rs index a5b74f8..442fd24 100644 --- a/world-chain-builder/src/rpc/transaction.rs +++ b/world-chain-builder/src/rpc/transaction.rs @@ -32,25 +32,26 @@ where async fn send_raw_transaction(&self, tx: Bytes) -> Result { let (recovered, inner_tx) = recover_raw_transaction(tx.clone())?; let pool_transaction = ::Transaction::from_pooled(recovered); + let pbh_tx = pool_transaction.semaphore_proof.is_some(); + + // submit the transaction to the pool with a `Local` origin + let hash = self + .pool() + .add_transaction(TransactionOrigin::Local, pool_transaction) + .await + .map_err(Self::Error::from_eth_err)?; // 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() { - if pool_transaction.semaphore_proof.is_none() { + if !pbh_tx { tracing::debug!( target: "rpc::eth", "forwarding raw transaction to"); let _ = client.forward_raw_transaction(&inner_tx).await.inspect_err(|err| { - tracing::debug!(target: "rpc::eth", %err, hash=% *pool_transaction.hash(), "failed to forward raw transaction"); + tracing::debug!(target: "rpc::eth", %err, hash=?*hash, "failed to forward raw transaction"); }); } } - // submit the transaction to the pool with a `Local` origin - let hash = self - .pool() - .add_transaction(TransactionOrigin::Local, pool_transaction) - .await - .map_err(Self::Error::from_eth_err)?; - Ok(hash) } }