-
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
feat(cheatcodes): add vm.getStateDiff
to get state diffs as string
#9435
base: master
Are you sure you want to change the base?
Conversation
dc4f42f
to
5add458
Compare
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.
lgtm
I'm honestly a bit conflicted with this api / feature. With primitive type storage in incremental slots what is proposed here is definitely useful, although I think for us would be more useful in an easier-to-consume & post-process format (e.g. json). Currently I lack the imagination though to see how i could understand that a change in slot |
can add a flag to cheatcode to return plain text or json formatted
I think this would imply leveraging of storage layout but probably more complex, will have a look at but most probably feasible to add post v1. |
vm.getStateDiff(isJson)
to get state diffs as string
@grandizzy just had another look at the structure & was wondering it could make sense to change it so sth like: My thinking is that it's a bit weird that if a label is supplied, the address is lost on the diff. |
thank you, makes sense, will structure the output this way |
@sakulstra I formatted it as below in d46080c {
"0x2e234dae75c793f67a35089c9d99245e1c58470b":{
"label":"NestedStorer",
"changes":{
"31391530734884398925509096751136955997235046655136458338700630915422204365175":{
"original":"0x0000000000000000000000000000000000000000000000000000000000000000",
"dirty":"0x0000000000000000000000000000000000000000000000000000000000000001"
},
"86546418208203448386783321347074308435724792809315873744194221534962779865098":{
"original":"0x0000000000000000000000000000000000000000000000000000000000000000",
"dirty":"0x0000000000000000000000000000000000000000000000000000000000000001"
},
"89735575844917174604881245405098157398514761457822262993733937076486162048205":{
"original":"0x0000000000000000000000000000000000000000000000000000000000000000",
"dirty":"0x0000000000000000000000000000000000000000000000000000000000000001"
},
"99655811014363889343382125167956395016210879868288374279890486979400290732814":{
"original":"0x0000000000000000000000000000000000000000000000000000000000000000",
"dirty":"0x0000000000000000000000000000000000000000000000000000000000000001"
}
}
}
} |
@grandizzy looks good to me. I personally find the new naming not so optimal, but i think is just taste. |
changed in 1536119 and updated comment above |
rerequesting review as there were several changes (json output)
vm.getStateDiff(isJson)
to get state diffs as stringvm.getStateDiff
to get state diffs as string
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.
Nice! Lgtm
Motivation
Closes #2846 by adding
startStateDiffRecording()
cheatcode as string (can be printed with console.log or written in file), at the moment of cheatcode call (can be called multiple times between start / stop state diff)E.g.
Json format
vm.getStateDiffJson()
Solution