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

fix: check for cancun in cast run #7434

Merged
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
16 changes: 14 additions & 2 deletions crates/cast/bin/cmd/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,25 +117,37 @@ impl RunArgs {
.ok_or_else(|| eyre::eyre!("tx may still be pending: {:?}", tx_hash))?
.to::<u64>();

// fetch the block the transaction was mined in
let block = provider.get_block(tx_block_number.into(), true).await?;

// we need to fork off the parent block
config.fork_block_number = Some(tx_block_number - 1);

let (mut env, fork, chain) = TracingExecutor::get_fork_material(&config, evm_opts).await?;

let mut executor = TracingExecutor::new(env.clone(), fork, self.evm_version, self.debug);
let mut evm_version = self.evm_version;

env.block.number = U256::from(tx_block_number);

let block = provider.get_block(tx_block_number.into(), true).await?;
if let Some(ref block) = block {
env.block.timestamp = block.header.timestamp;
env.block.coinbase = block.header.miner;
env.block.difficulty = block.header.difficulty;
env.block.prevrandao = Some(block.header.mix_hash.unwrap_or_default());
env.block.basefee = block.header.base_fee_per_gas.unwrap_or_default();
env.block.gas_limit = block.header.gas_limit;

// TODO: we need a smarter way to map the block to the corresponding evm_version for
// commonly used chains
if evm_version.is_none() {
// if the block has the excess_blob_gas field, we assume it's a Cancun block
if block.header.excess_blob_gas.is_some() {
evm_version = Some(EvmVersion::Cancun);
}
}
}

let mut executor = TracingExecutor::new(env.clone(), fork, evm_version, self.debug);
let mut env =
EnvWithHandlerCfg::new_with_spec_id(Box::new(env.clone()), executor.spec_id());

Expand Down
Loading