-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
base: master
Are you sure you want to change the base?
Add options for state changes output and json output in cast run command #9013
Conversation
…output-storage-change-and-json-output-for-cast-run
There was a problem hiding this 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
…output-storage-change-and-json-output-for-cast-run
Hi everyone, please let me know if there's anything else I can do to help move this PR forward. |
This PR writes the storage change in the trace. Example output when using cast run from [the PR](foundry-rs/foundry#9013): ``` ❯ cargo run --bin cast run 0xefc789b63631b255aeb6f97d948c9eac14bae4b7f021122fe24c7c6e4f34667f -r https://eth.llamarpc.com -q --decode-internal --with-state-changes Compiling: TransparentUpgradeableProxy 0x6bE457e04092B28865E0cBa84E3b2CFa0f871E67 Compiling: TransparentUpgradeableProxy 0x7a7f0b3c23C23a31cFcb0c44709be70d4D545c6e Compiling: TransparentUpgradeableProxy 0xD523794C879D9eC028960a231F866758e405bE34 Compiling: Pool 0xDEbbf61098642C7c06fAd1E116C1a00e50405D0d Traces: [247473] TransparentUpgradeableProxy::stake{value: 1949677189193480698}(1) ├─ [2232] TransparentUpgradeableProxy::_beforeFallback() │ ├─ [2150] ERC1967Upgrade::_getAdmin() │ │ └─ ← 0xD491302a6621128f4b5a6A49ce6657230732b0cb │ └─ ← ├─ [2196] ERC1967Proxy::_implementation() │ └─ ← 0xDEbbf61098642C7c06fAd1E116C1a00e50405D0d ├─ [240157] Pool::stake{value: 1949677189193480698}(1) [delegatecall] │ ├─ [213932] Pool::_stake(0x93386C72aa57082820Ad6Aa29998B820971a8d61, 1949677189193480698 [1.949e18]) │ │ ├─ [228681] TransparentUpgradeableProxy::deposit(0x93386C72aa57082820Ad6Aa29998B820971a8d61, 1949677189193480698 [1.949e18]) │ │ │ ├─ [2232] TransparentUpgradeableProxy::_beforeFallback() │ │ │ │ ├─ [2150] ERC1967Upgrade::_getAdmin() │ │ │ │ │ └─ ← 0xD491302a6621128f4b5a6A49ce6657230732b0cb │ │ │ │ └─ ← │ │ │ ├─ [2196] ERC1967Proxy::_implementation() │ │ │ │ └─ ← 0x1a5b89b2ef0028A059EAD7D9E648B533f87c8558 │ │ │ ├─ [221356] 0x1a5b89b2ef0028A059EAD7D9E648B533f87c8558::deposit(0x93386C72aa57082820Ad6Aa29998B820971a8d61, 1949677189193480698 [1.949e18]) [delegatecall] │ │ │ │ ├─ emit Update(: 1305166715630598691 [1.305e18], : 17341785000000000 [1.734e16], : 1926865000000000 [1.926e15]) │ │ │ │ ├─ [22215] TransparentUpgradeableProxy::reStake(17341785000000000 [1.734e16], 0) │ │ │ │ │ ├─ [2232] TransparentUpgradeableProxy::_beforeFallback() │ │ │ │ │ │ ├─ [2150] ERC1967Upgrade::_getAdmin() │ │ │ │ │ │ │ └─ ← 0xD491302a6621128f4b5a6A49ce6657230732b0cb │ │ │ │ │ │ └─ ← │ │ │ │ │ ├─ [2196] ERC1967Proxy::_implementation() │ │ │ │ │ │ └─ ← 0xbE3366a14D0c87094DEB6DFbA667299b4EaC489d │ │ │ │ │ ├─ [14896] 0xbE3366a14D0c87094DEB6DFbA667299b4EaC489d::reStake(17341785000000000 [1.734e16], 0) [delegatecall] │ │ │ │ │ │ ├─ [3266] TransparentUpgradeableProxy::restake{value: 17341785000000000}(0) │ │ │ │ │ │ │ ├─ [232] TransparentUpgradeableProxy::_beforeFallback() │ │ │ │ │ │ │ │ ├─ [150] ERC1967Upgrade::_getAdmin() │ │ │ │ │ │ │ │ │ └─ ← 0xD491302a6621128f4b5a6A49ce6657230732b0cb │ │ │ │ │ │ │ │ └─ ← │ │ │ │ │ │ │ ├─ [196] ERC1967Proxy::_implementation() │ │ │ │ │ │ │ │ └─ ← 0xDEbbf61098642C7c06fAd1E116C1a00e50405D0d │ │ │ │ │ │ │ ├─ [2450] Pool::restake{value: 17341785000000000}(0) [delegatecall] │ │ │ │ │ │ │ │ └─ ← [Stop] │ │ │ │ │ │ │ └─ ← [Return] │ │ │ │ │ │ └─ ← [Stop] │ │ │ │ │ └─ ← [Return] │ │ │ │ ├─ emit topic 0: 0xb0ec6c271a891e04f03d43bf454839acfbf574e269cb5599c1f70b9257cf9cd7 │ │ │ │ │ data: 0x000000000000000000000000000000000000000000000000003d9c42f6b23a00 │ │ │ │ ├─ emit topic 0: 0xc8724ec5e59eea00f3f35419c3139ead03ff07766e7e9cf00a62381692aac8c7 │ │ │ │ │ topic 1: 0x00000000000000000000000093386c72aa57082820ad6aa29998b820971a8d61 │ │ │ │ │ data: 0x0000000000000000000000000000000000000000000000001b0ea512e08f39fa │ │ │ │ ├─ storage write 0x7a7f0b3c23C23a31cFcb0c44709be70d4D545c6e [0x501d093c0316d001addb7dc8913312112ff29225e2343de5aed242436c83ecaf]: │ │ │ │ │ 0x0000000000000000000000000000000000000000000000000000000000000000 → 0x0000000000000000000000000000000000000000000000001b0ea512e08f39fa ... │ │ │ │ │ 0x0000000000000000000000000000000000000000000000000000000000000003 → 0x0000000000000000000000000000000000000000000000000000000000000004 │ │ │ │ ├─ storage write 0x7a7f0b3c23C23a31cFcb0c44709be70d4D545c6e [0xb4c87350b3618bf3b0453372aae234908cc3b6cf61d458f195edd9160dac1f7f]: │ │ │ │ │ 0x000000000000000000000000000000000000000000000000ce8cbfb644313c26 → 0x000000000000000000000000000000000000000000000000e9d9010c1b72b020 │ │ │ │ └─ ← [Return] 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 │ │ │ └─ ← [Return] 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 │ │ └─ ← │ ├─ emit StakeAdded(staker: 0x93386C72aa57082820Ad6Aa29998B820971a8d61, value: 1949677189193480698 [1.949e18], source: 1) │ └─ ← [Stop] └─ ← [Return] Transaction successfully executed. Gas used: 248777 ``` --------- Co-authored-by: DaniPopes <[email protected]>
For the CI error: error: this function has too many arguments (9/7)
--> crates/cli/src/utils/cmd.rs:357:1
|
357 | / pub async fn handle_traces(
358 | | mut result: TraceResult,
359 | | config: &Config,
360 | | chain: Option<Chain>,
... |
366 | | with_state_changes: bool,
367 | | ) -> Result<()> {
| |_______________^ I believe we have a few options to address this:
Please let me know your thoughts or suggestions. |
this should be fine IMO |
…output-storage-change-and-json-output-for-cast-run
…output-storage-change-and-json-output-for-cast-run
…output-storage-change-and-json-output-for-cast-run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation looks good, some notes
…son-output-for-cast-run
…output-storage-change-and-json-output-for-cast-run
…ut-storage-change-and-json-output-for-cast-run' into add-options-to-output-storage-change-and-json-output-for-cast-run
…son-output-for-cast-run
…output-storage-change-and-json-output-for-cast-run
…ange-and-json-output-for-cast-run' into add-options-to-output-storage-change-and-json-output-for-cast-run
Hi everyone, @zerosnacks @grandizzy any updates on this PR? It's a bit time consuming to keep merging updates on the main branch. Thank you! |
Hey @cassc sorry for the delay, some small notes in regards to the global |
…son-output-for-cast-run
…son-output-for-cast-run
@cassc could you please check #2846 (comment) would like to know if we could tackle all points in the PR (or as a follow-up). Thank you! |
also wonder if we need the new |
Hi @grandizzy I think it's better to tackle in another PR, especially I think at the memoment I might not have enough knowledge about the test-level state changes. |
make sense! @mds1 could you pls chime in re UX for |
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 forcast 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: