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

fix(cheatcodes): disallow using vm.prank after vm.startPrank #5520

Merged
merged 3 commits into from
Aug 1, 2023

Conversation

Evalir
Copy link
Member

@Evalir Evalir commented Aug 1, 2023

Motivation

Closes #5515 . This problem (tx.origin not being updated correctly after doing vm.prank after a vm.startPrank) is introduced in part due to #4884 — we now have certain rules to override pranks that weren't explicit enough in the code. You should probably not be able to call vm.prank after a vm.startPrank, as vm.startPrank is "multi-use" and must be stopped, while vm.prank is "single use", and one should not overlap the other, as you can use vm.startPrank again after having used the first startPrank. This is made a little confusing as we don't have a changePrank cheatcode, but rather re-use vm.startPrank for this.

We could probably make a case for allowing this, but this feels like a hard-to-explain possible footgun and I'd rather disallow it entirely.

Solution

Disallow calling vm.prank after a vm.startPrank.

@Evalir Evalir requested review from mds1 and mattsse August 1, 2023 19:37
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

this sounds reasonable to me,

pending @mds1

@Evalir
Copy link
Member Author

Evalir commented Aug 1, 2023

alright, should be good now @mds1 !

Copy link
Collaborator

@mds1 mds1 left a comment

Choose a reason for hiding this comment

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

LGTM!

@Evalir Evalir merged commit ca67d15 into master Aug 1, 2023
@Evalir Evalir deleted the evalir/fix-startprank branch August 1, 2023 20:12
aathan pushed a commit to aathan/foundry that referenced this pull request Aug 2, 2023
…oundry-rs#5520)

* chore: disallow using vm.prank after vm.startprank

* chore: rename state single call bool

* Update evm/src/executor/inspector/cheatcodes/env.rs

Co-authored-by: Matt Solomon <[email protected]>

---------

Co-authored-by: Matt Solomon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(forge): tx.origin set using startPrank is not reset to DefaultSender after calling a prank-ed call
3 participants