Skip to content

Commit

Permalink
Merge pull request #34 from worldcoin/0xkitsune/forward-tx
Browse files Browse the repository at this point in the history
Forward transactions to the Sequencer after validation
  • Loading branch information
0xKitsune authored Oct 15, 2024
2 parents f554215 + d23928d commit 9b6f50a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions world-chain-builder/src/rpc/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,26 @@ where
async fn send_raw_transaction(&self, tx: Bytes) -> Result<B256, Self::Error> {
let (recovered, inner_tx) = recover_raw_transaction(tx.clone())?;
let pool_transaction = <Self::Pool as TransactionPool>::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)
}
}
Expand Down

0 comments on commit 9b6f50a

Please sign in to comment.