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

feat: add way to disable emitting of gas snapshots to disk #9710

Merged
merged 2 commits into from
Feb 7, 2025

Conversation

turbocrime
Copy link
Contributor

@turbocrime turbocrime commented Jan 18, 2025

Motivation

fixes #9697

Solution

following pattern set by #9791

new config field: gas_snapshot_emit, default true
new env var: FORGE_SNAPSHOT_EMIT, overrides config
new cli flag: --gas-snapshot-emit=<bool>, overrides config and env

existing default behaviors are maintained.

crates/forge/bin/cmd/test/mod.rs Outdated Show resolved Hide resolved
crates/forge/bin/cmd/test/mod.rs Outdated Show resolved Hide resolved
@turbocrime
Copy link
Contributor Author

cc @zerosnacks assigned to #9697

@zerosnacks
Copy link
Member

Generally supportive on the approach, defaulting to true also makes sense here

Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

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

thank you! left couple of comments

crates/forge/bin/cmd/test/mod.rs Outdated Show resolved Hide resolved
crates/forge/bin/cmd/test/mod.rs Outdated Show resolved Hide resolved
crates/forge/bin/cmd/test/mod.rs Outdated Show resolved Hide resolved
crates/forge/bin/cmd/test/mod.rs Outdated Show resolved Hide resolved
crates/forge/bin/cmd/test/mod.rs Outdated Show resolved Hide resolved
crates/forge/bin/cmd/test/mod.rs Outdated Show resolved Hide resolved
@grandizzy
Copy link
Collaborator

Generally supportive on the approach, defaulting to true also makes sense here

I'd suggest having args like --snapshot-no-record and --snapshot-no-check that would disable default behavior if passed, or something along these lines, would that work?

@zerosnacks zerosnacks self-assigned this Jan 21, 2025
@turbocrime
Copy link
Contributor Author

the environment variable FORGE_SNAPSHOT_CHECK is already established. adding an additional FORGE_SNAPSHOT_NO_CHECK seems like it could be confusing. interactions between the env and the flags become unclear.

i made the FORGE_SNAPSHOT_CHECK change because

  • using a clap flag seemed simple and more consistent than checking the env directly in the conditional
  • it collected all the available options and env var access in the clap options block
  • the current behavior simply conditions on presence, so something like FORGE_SNAPSHOT_CHECK="false" is interpreted as a truthy value!!

but now i see that also raises many questions, and it is not entirely consistent with the behavior of my added flag.

i will revert changes to FORGE_SNAPSHOT_CHECK and create an issue describing its present behavior. it may be good to resolve that, and all the questions there, before adding a new flag.

@zerosnacks
Copy link
Member

i will revert changes to FORGE_SNAPSHOT_CHECK and create an issue describing its present behavior. it may be good to resolve that, and all the questions there, before adding a new flag.

added the gas_snapshot_check config entry + flag + suggested change to FORGE_SNAPSHOT_CHECK here: #9791

@turbocrime
Copy link
Contributor Author

thanks for working on this, wound up with other tasks on my plate and wasn't able to make time

@turbocrime turbocrime closed this Jan 30, 2025
@turbocrime turbocrime reopened this Jan 30, 2025
@turbocrime
Copy link
Contributor Author

the emit behavior still remains to be implemented? will leave this open for now, might get to it with free time this week

@zerosnacks
Copy link
Member

zerosnacks commented Jan 30, 2025

@turbocrime No worries! Feel free to ping me if you run into (time) issues / have questions

@turbocrime
Copy link
Contributor Author

turbocrime commented Feb 7, 2025

updated to tip of main, now using config, env var, and a flag, following the pattern @zerosnacks used in #9791

new config field: gas_snapshot_emit, default true (present behavior)
new env var: FORGE_SNAPSHOT_EMIT, overrides config
new cli flag: --gas-snapshot-emit=<bool>, overrides config and env

tests feel verbose, could possibly be improved, but i believe they confirm function.

ready for re-review

hopefully i can come back at some point to expand docs like foundry-rs/book#1407 but i've got limited time now.

@turbocrime turbocrime requested a review from grandizzy February 7, 2025 00:49
@turbocrime turbocrime changed the title feat: forge test snapshot flags feat: forge snapshot emit config, env, and flag Feb 7, 2025
@turbocrime turbocrime changed the title feat: forge snapshot emit config, env, and flag feat: forge section snapshot emit config, env, and flag Feb 7, 2025
@zerosnacks
Copy link
Member

Thanks @turbocrime! Implementation and tests look good

@zerosnacks zerosnacks changed the title feat: forge section snapshot emit config, env, and flag feat: add way to disable emitting of gas snapshots to disk Feb 7, 2025
Copy link
Member

@zerosnacks zerosnacks left a comment

Choose a reason for hiding this comment

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

lgtm! pending one more review

cc @grandizzy

Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

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

Looks good, thank you!

@zerosnacks zerosnacks merged commit 5f6bd20 into foundry-rs:master Feb 7, 2025
22 checks passed
zerosnacks added a commit to foundry-rs/book that referenced this pull request Feb 7, 2025
@zerosnacks
Copy link
Member

hopefully i can come back at some point to expand docs like foundry-rs/book#1407 but i've got limited time now.

Added the new flag to the book foundry-rs/book#1442 :)

zerosnacks added a commit to foundry-rs/book that referenced this pull request Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge T-feature Type: feature
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

feat: provide some way to disable generation of section snapshots by the snapshot cheatcodes
3 participants