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

Add options for state changes output and json output in cast run command #9013

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

cassc
Copy link

@cassc cassc commented Oct 3, 2024

Motivation

The current human-readable output from cast run is great for manual interpretation but requires additional parsing to be used programmatically. Additionally, there is a need to inspect storage changes for each call, but currently, these changes are not recorded.

Solution

This PR introduces a -j option for cast run to output traces in JSON format, making it easier to consume programmatically. It also adds a --with-state-changes option that outputs storage changes.

Example usage:

cast run 0xefc789b63631b255aeb6f97d948c9eac14bae4b7f021122fe24c7c6e4f34667f \
  -r https://eth.llamarpc.com -q --decode-internal --with-state-changes -j | \
  jq -R 'select(try fromjson? | . != null) | fromjson'

@cassc cassc marked this pull request as ready for review October 3, 2024 08:58
Copy link
Member

@zerosnacks zerosnacks left a comment

Choose a reason for hiding this comment

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

Thanks for your PR, generally in favor of adding this

crates/verify/src/utils.rs Outdated Show resolved Hide resolved
Comment on lines +59 to +61
/// Prints the state changes, only works with the `json` flag.
#[arg(long)]
with_state_changes: bool,
Copy link
Member

Choose a reason for hiding this comment

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

--json should just toggle the output mode

If desired it should also be added to https://github.com/paradigmxyz/revm-inspectors so the regular output mode has optional support for it as well

Copy link
Author

Choose a reason for hiding this comment

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

Totally agree. I'm happy to submit a separate PR to the revm-inspectors repo to add support for this.

@cassc cassc requested a review from zerosnacks October 8, 2024 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants