-
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
Fix single broadcast/prank nonce setting #5727
Conversation
Nice! This makes sense to me wrt the delegatecall issue.
maybe @Evalir can clear up semantics here |
The issue actualy happens not only with delegatecalls, but with any broadcasted calls which result in subsequent calls/delegatecalls to other contracts because we are dropping broadcast field at the end of the first such call For me it solved the issue with two broadcasts in the same script which I explained in the issue |
oh yeah @klkvr just tested and you're totally right my bad while it is true that foundry/crates/evm/src/executor/inspector/cheatcodes/env.rs Lines 110 to 128 in 95a93cd
So ya great find and great fix! |
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! just gonna be really careful with this and test
|
||
if prank.single_call { | ||
std::mem::take(&mut self.prank); | ||
} |
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.
Let's add docs on the rationale as to why this is applied iff the outer if
runs—it's a change on the previous behavior and I'm a bit apprehensive it might "fix" (or break) behavior that has come to be expected. Will test this locally
|
||
if broadcast.single_call { | ||
std::mem::take(&mut self.broadcast); | ||
if broadcast.single_call { |
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.
ditto here and the others
Hey @Evalir, I have added some comments. However, IMO, the previous behavior was slightly less intuitive. I'm not entirely sure if we actually need an explanation here. The broadcast cleaning outside of the |
* Fix single broadcast * Add comments * rustfmt --------- Co-authored-by: Enrique Ortiz <hi@enriqueortiz.dev>
Motivation
Closes #5635
Solution
Remove single call broadcast/prank from cheatcodes inspector only when we have came back to the broadcast/prank initialization depth
I think this should get a careful review from someone with deep knowledge of evm crate architecture