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): skip gas snapshots if not in isolation mode #9649

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

zerosnacks
Copy link
Member

@zerosnacks zerosnacks commented Jan 8, 2025

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 require snapshotValue 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

  • Fix tests
  • Test if the skipping works correctly when in-line configs are used
  • Running a single related test should merge its results, replacing only its own result and leaving the others intact (note that this does cause staining!)

…side effect is that any custom group names or file name changes are not reflected - this is delegated to the end user
…has a certain requirement for running it - in the case of gas snapshotting: isolation mode
@zerosnacks zerosnacks changed the title Zerosnacks/skip gas snapshots if not in isolation fix: skip gas snapshots if not in isolation Jan 8, 2025
@zerosnacks zerosnacks changed the title fix: skip gas snapshots if not in isolation fix: skip gas snapshots if not in isolation mode Jan 8, 2025
@zerosnacks zerosnacks changed the title fix: skip gas snapshots if not in isolation mode fix(cheatcodes): skip gas snapshots if not in isolation mode Jan 8, 2025
@zerosnacks zerosnacks added T-feature Type: feature A-cheatcodes Area: cheatcodes labels Jan 8, 2025
@grandizzy grandizzy added the C-forge Command: forge label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cheatcodes Area: cheatcodes C-forge Command: forge T-feature Type: feature
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants