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

Fuzz Seed is not read from foundry.toml on forge snapshot #6179

Closed
2 tasks done
marktoda opened this issue Oct 31, 2023 · 3 comments · Fixed by #7951
Closed
2 tasks done

Fuzz Seed is not read from foundry.toml on forge snapshot #6179

marktoda opened this issue Oct 31, 2023 · 3 comments · Fixed by #7951
Labels
T-bug Type: bug

Comments

@marktoda
Copy link
Contributor

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (94ae897 2023-10-31T00:16:51.730405056Z)

What command(s) is the bug in?

forge snapshot

Operating System

Linux

Describe the bug

When running forge snapshot, fuzz seed as defined in foundry.toml is not honored. When passing it in as an env variable via FOUNDRY_FUZZ_SEED, it works fine.

behavior:
in foundry.toml, I've set

[fuzz]
runs = 100
seed = 0x4444

When running forge snapshot, it works fine and uses 100 runs. Then I set the seed in the environment with

FOUNDRY_FUZZ_SEED=0x4444 forge snapshot and it results in a different snapshot file. I would expect this to be the same seed as set in foundry.toml.

This causes a problem in CI where locally run snapshots do not match CI-run snapshots unless environment variable seed is set.

Reference PR from uniswap/v4-core where we had to set fuzz seed in env Uniswap/v4-core#331

@marktoda
Copy link
Contributor Author

ref think this would solve #5689

@marktoda
Copy link
Contributor Author

I see now that this is likely because we use STATIC_FUZZ_SEED for snapshot https://github.com/foundry-rs/foundry/blob/30ae702a31e175ca9c2c23bba71ee9d8520c8e45/crates/forge/bin/cmd/snapshot.rs#L101C56-L101C72 which overrides the foundry.toml version

but then why does the env variable affect it? and why does the STATIC_FUZZ_SEED result in differing outputs run by run?

@marktoda
Copy link
Contributor Author

marktoda commented Nov 1, 2023

nvm after more research seems the static seed works fine, i think the issue is diff rng between mac vs linux? i.e. when running on local linux machine vs linux CI it works but mac local vs linux CI fails

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant