Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward transactions to the Sequencer after validation #34

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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