Skip to content

Basic startPrank/stopPrank cheat code support#594

Merged
anishnaik merged 9 commits intomasterfrom
dev/startPrank
Mar 24, 2025
Merged

Basic startPrank/stopPrank cheat code support#594
anishnaik merged 9 commits intomasterfrom
dev/startPrank

Conversation

@Xenomega
Copy link
Copy Markdown
Member

@Xenomega Xenomega commented Mar 13, 2025

This PR closes #446 . It introduces the basic variant of startPrank and stopPrank cheat codes (msg.sender support only)

Expected behavior:

  • startPrank does pranking only one call level deeper than it was initiated from. Thus, the scope startPrank is called in is not affected, only direct sub-calls.
  • Multiple stopPrank can be called without a startPrank, with no issue/revert.
  • Multiple startPrank can be called, overriding the previous startPrank (it does not act like a stack).
    • Foundry will error if a previous startPrank was not applied at least once. This doesn't seem important to us to enforce(?)
  • A startPrank in a reverted scope should inherently have no effect (not be pranking anymore).

Outstanding TODOs:

  • Update the cheat code wiki page.
  • Open up issue to track adding support for tx.origin and delegateCall overloads in a later PR. The TX origin is exposed from evm.Origin, but we need an evm handle. And the delegateCall flag requires us to poke scopeContext.Contract.self, which is currently unexposed in medusa-geth. Relevant TODO comments are left as placeholders.

@Xenomega Xenomega changed the title [WIP] startPrank/stopPrank cheat code support startPrank/stopPrank cheat code support Mar 14, 2025
@Xenomega Xenomega changed the title startPrank/stopPrank cheat code support Basic startPrank/stopPrank cheat code support Mar 14, 2025
Copy link
Copy Markdown
Collaborator

@anishnaik anishnaik left a comment

Choose a reason for hiding this comment

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

bing bong

@anishnaik anishnaik merged commit aa1ddc5 into master Mar 24, 2025
12 checks passed
@anishnaik anishnaik deleted the dev/startPrank branch March 24, 2025 16:42
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.

Implement startPrank and stopPrank

2 participants