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 state overrides flags to cast call #10189

Open
Yen opened this issue Mar 27, 2025 · 10 comments · May be fixed by #10255
Open

Add state overrides flags to cast call #10189

Yen opened this issue Mar 27, 2025 · 10 comments · May be fixed by #10255
Labels
C-cast Command: cast first issue A good way to start contributing T-feature Type: feature

Comments

@Yen
Copy link

Yen commented Mar 27, 2025

Component

Cast

Describe the feature you would like

eth_call implementations often support a state override object as the last parameter. The ability to define state overrides in a similar form to --labels on cast, for example --balance-override <ADDRESS>:<BALANCE>, would be useful for debugging scenarios. The commands might get messy for large state changes, something like --state-override <ADDRESS>:<SLOT>:<VALUE>, but being possible to do it would be nice.

In my specific use case, I would like the balance overrides, but I can see uses where the other parameters could be useful.

Thanks

Additional context

No response

@Yen Yen added T-feature Type: feature T-needs-triage Type: this issue needs to be labelled labels Mar 27, 2025
@github-project-automation github-project-automation bot moved this to Todo in Foundry Mar 27, 2025
@grandizzy grandizzy added first issue A good way to start contributing C-cast Command: cast and removed T-needs-triage Type: this issue needs to be labelled labels Apr 1, 2025
@grandizzy
Copy link
Collaborator

@Yen
Copy link
Author

Yen commented Apr 1, 2025

Happy to do an implementation of this if there is some guidance as to what the interface/flags should look like from a core developer. I have a specific use case relating to balance overrides so wouldn't to propose something that fits only that.

@grandizzy
Copy link
Collaborator

grandizzy commented Apr 1, 2025

Happy to do an implementation of this if there is some guidance as to what the interface/flags should look like from a core developer. I have a specific use case relating to balance overrides so wouldn't to propose something that fits only that.

thank you! probably best should be an --state-overrides to take the json with all balance, state, nonce, code overrides per address, same as the one passed to eth_call

@Yen
Copy link
Author

Yen commented Apr 1, 2025

thank you! probably best should be an --state-overrides to take the json with all balance, state, nonce, code overrides per address, same as the one passed to eth_call

Ok, there is no desire to parse individual overrides similar to other flags like --labels as outlined in my original post?

@grandizzy
Copy link
Collaborator

thank you! probably best should be an --state-overrides to take the json with all balance, state, nonce, code overrides per address, same as the one passed to eth_call

Ok, there is no desire to parse individual overrides similar to other flags like --labels as outlined in my original post?

I think I missed that but not part of state overrides we support in alloy https://docs.rs/alloy-rpc-types-eth/0.13.0/alloy_rpc_types_eth/state/struct.AccountOverride.html
can you pls detail where it goes in eth_call?

@Yen
Copy link
Author

Yen commented Apr 1, 2025

I am referring to if, instead of a json object, we want to pass in more CLI-friendly formatted arguments. For example the --labels argument on cast call uses a format of a list of address:label pairs rather that some structured data like JSON. If we were to follow this patten for override commands it might be more convenient as in most cases I assume people only wish to override one or two things.

Something like:

  • --override-balance "0xAAAA:1234,0xBBBB:5678"
  • --override-nonce "0xAAAA:5,0xBBBB:10"
  • --override-code "0xAAAA:0xCODEBYTES"
  • --override-state "0xAAAA:0xSLOT:1234,0xBBBB:0xSLOT:5678"
  • --override-state-diff "0xAAAA:0xSLOT:1234,0xBBBB:0xSLOT:5678"

I am not entirely sure what move_precompile_to field does, but it would presumably just be --override-move-precompile-to "0xADDR".

To me this seems more CLI-friendly than a JSON blob as a single --state-overrides flag.

@grandizzy
Copy link
Collaborator

ah, I see, wasn't familiar with labels switch. For storage slots the format could become a little bit too much but I think makes sense overall. @zerosnacks @yash-atreya wdyt re proposed args?

@Yen
Copy link
Author

Yen commented Apr 1, 2025

Could always add both and have a --override flag that takes in a JSON object for people with large state overrides and such? All the args would be merged together at the end.

@grandizzy
Copy link
Collaborator

sgtm!

@tushar994 tushar994 linked a pull request Apr 5, 2025 that will close this issue
3 tasks
@tushar994
Copy link
Contributor

tushar994 commented Apr 5, 2025

I made a PR for this, would really appreciate your help with a review. Main problem is that I'm not sure how to test this. I've added some basic tests, but I'm not satisfied with them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cast Command: cast first issue A good way to start contributing T-feature Type: feature
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

3 participants