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

Update VM cheatcodes to be permanent #499

Merged
merged 13 commits into from
Jan 31, 2025
Merged

Update VM cheatcodes to be permanent #499

merged 13 commits into from
Jan 31, 2025

Conversation

anishnaik
Copy link
Collaborator

@anishnaik anishnaik commented Oct 25, 2024

Closes #399

Before this PR, VM cheatcodes like warp, roll, fee, and coinbase only affected the VM state for the current transaction. Once the transaction ended, the effect of the cheatcode disappeared. This was a deviation from how foundry and echidna worked. Additionally, it prevented the use case of setting a "starting timestamp" in the constructor that can be used for the entire fuzzing campaign.

This PR allows for all these VM cheatcodes, except difficulty (see #547), to be "permanent". Meaning once the cheatcode is used, the actual block's value is changed which will affect all future blocks. If you change the timestamp, all future blocks will use that new timestamp as the starting point.

The primary implication of this is that the core invariants of the TestChain had to be changed. Block number and timestamp are no longer strictly increasing. Additionally, you can technically have two blocks with the same block number or timestamp. To handle these situations, we had to strip the TestChain for parts. This makes the whole implementation a lot simpler (and dumber). We no longer spoof blocks, assert that block number/timestamp is always increasing, and basically we no longer give a crap about trying to be a "real" blockchain.

@anishnaik anishnaik requested a review from Xenomega as a code owner October 25, 2024 19:13
@anishnaik anishnaik changed the title WIP: Update warp to be permanent Update VM cheatcodes to be permanent Jan 30, 2025
@anishnaik anishnaik requested a review from bsamuels453 January 30, 2025 17:03
@anishnaik anishnaik merged commit 0dc97b3 into master Jan 31, 2025
12 checks passed
@anishnaik anishnaik deleted the dev/fix-warp branch January 31, 2025 21:09
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.

Medusa doesn't respect one's desired starting block.timestamp
1 participant