Skip to content

fix cast call --trace when --block parameter is passed #6673

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

Conversation

tonyke-bot
Copy link

Motivation

When running cast call --trace --block <block-number> <tx-hash>, the block parameter doesn't work as expected. Latest block number is always used when sending RPC requests to pulling related information for local fork.

This bug is confirmed by running the command with RUST_LOG=trace to see the requests sent to RPC provider.

Solution

Use the given block parameter to modify the config.fork_block_number. When block is not a block number, convert to block number first.

Comment on lines 152 to +154
let evm_opts = figment.extract::<EvmOpts>()?;

config.fork_block_number = derive_fork_block_number(&provider, block).await?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not exactly sure about this,
I believe this should be set to evm_opts instead.

sorry this entire command is a bit messy...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

evm_opts.fork_url = Some(config.get_rpc_url_or_localhost_http()?.into_owned());
evm_opts.fork_block_number = config.fork_block_number;
let env = evm_opts.evm_env().await?;

The fact is, inside get_fork_material(), evm_opts.fork_block_number is overridden with config.fork_block_number

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping for this @mattsse

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's overriden with the config block number then I think it's fine for now

@tonyke-bot
Copy link
Author

ping

Copy link
Member

@Evalir Evalir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs clippy/fmt

Comment on lines 152 to +154
let evm_opts = figment.extract::<EvmOpts>()?;

config.fork_block_number = derive_fork_block_number(&provider, block).await?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's overriden with the config block number then I think it's fine for now

@zerosnacks
Copy link
Member

Hi @tonyke-bot, thanks for your PR! Would you be interested in updating it to use Alloy? Would be great to get this fix in.

@tonyke-bot
Copy link
Author

@zerosnacks ack!

@zerosnacks zerosnacks added this to the v1.0.0 milestone Jul 31, 2024
@zerosnacks zerosnacks added C-cast Command: cast T-bug Type: bug labels Jul 31, 2024
@yash-atreya
Copy link
Member

Superseded by #8009

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cast Command: cast T-bug Type: bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cast: cast call --trace --block <block-number> <tx-hash> doesn't respect block number parameter
5 participants