fix(cheatcodes): skip gas snapshots if not in isolation mode #9649
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.
Motivation
Opened for visibility
Ref: #9477 (comment)
Gas snapshots are not accurate outside of isolation mode and we've seen users only run gas snapshots with isolation mode enabled for this reason.
When running a test without
--isolate
enabled and gas snapshots cheatcodes are active a warning is raised similar to the deprecated cheatcodes (on per cheatcode used per test suite, collected at the end)This PR also fixes the issue where previously a single test from a test suite or custom group would clear out all the other keys. This has now been changed so that we merge with the previous results, replacing existing keys if they were effected. Note: this comes at the cost of now
staining
old values. This was deemed preferable based on feedback we received.Solution
This PR adds a
requires
keyword for the Cheatcodes spec which lets the developer indicate on prerequisites are required to run a cheatcode. In this can it is isolation mode for the gas snapshots.To do:
Decide whether to requiresnapshotValue
to also be ran in isolation mode given it is for arbitrary values. Because of its existence users still run into the "running one test overwrites the all related snapshot results"Not added, this should run regardless
staining
!)