Update VM cheatcodes to be permanent #499
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #399
Before this PR, VM cheatcodes like
warp
,roll
,fee
, andcoinbase
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 theTestChain
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.