Skip to content

Commit

Permalink
fix: sim against the block (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
prestwich authored Oct 25, 2024
1 parent bb3c5d1 commit e687e3d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions crates/builder/src/tasks/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ use crate::{
signer::LocalOrAws,
tasks::block::InProgressBlock,
};
use alloy::consensus::SimpleCoder;
use alloy::network::{TransactionBuilder, TransactionBuilder4844};
use alloy::providers::{Provider as _, WalletProvider};
use alloy::rpc::types::eth::TransactionRequest;
use alloy::signers::Signer;
use alloy::sol_types::SolCall;
use alloy::transports::TransportError;
use alloy::{consensus::SimpleCoder, eips::BlockNumberOrTag};
use alloy::{
eips::BlockId,
network::{TransactionBuilder, TransactionBuilder4844},
};
use alloy_primitives::{FixedBytes, U256};
use eyre::{bail, eyre};
use oauth2::{
Expand Down Expand Up @@ -142,15 +145,16 @@ impl SubmitTask {
.with_from(self.provider.default_signer_address())
.with_to(self.config.zenith_address);

if let Err(TransportError::ErrorResp(e)) = self.provider.call(&tx).await {
let sim_block = BlockId::Number(BlockNumberOrTag::Number(resp.req.host_block_number.to()));
if let Err(TransportError::ErrorResp(e)) = self.provider.call(&tx).block(sim_block).await {
error!(
code = e.code,
message = %e.message,
data = ?e.data,
"error in transaction submission"
);

bail!("bailing transaction submission")
bail!("simulation failed, bailing transaction submission")
}

tracing::debug!(
Expand Down

0 comments on commit e687e3d

Please sign in to comment.