-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 test gas in snapshot off by 1 gas #5689
Comments
Which repo can we use to reproduce this? Thanks for reporting! |
The complete repo is not open sourced yet, the contract source (without tests) is here: The specific test causing issues is a fuzz test again EVM2EVMOnRamp.sol: |
Nice, our ccip repo was made public today, the test causing the issue is here: to reproduce it,
|
Any update on this? I'm hitting it more and more it seems. Made sure to CI ran on commit 64faf451b95b939406d068d37eaa3bb034d35250 in this repo How to reproduce
CI:
|
fuzz gas tests can differ but you can run with perhaps we should add a the off by one is likely just an outliner the results in diff average/mean are you using constant seeds? for example |
@mattsse foundry/crates/forge/bin/cmd/snapshot.rs Lines 99 to 101 in 0f530f2
|
I'm seeing the off-by-1 gas issue more frequently as well, this could be just a platform-specific rounding error. |
hmm, couldn't find anything wrong with the mean/avg math could you perhaps try increasing/decreasing the fuzzruns, maybe there's an edge case with cross platform fuzzed values resulting in +256gas |
The previous attempt to assert identical gas usage in CI has been reverted because a snapshot generated in CI was different from a snapshot generated locally. The diff still exist as of today, but amounts are minuscule. The amounts range from 1 to tens. And these diffs exist in fuzz tests only. This is a known bug in Foundry: foundry-rs/foundry#5689 This commit adds back gas snapshot, and check for a minimum diff in CI. This way, snapshot diff tool can be used while waiting for the Foundry issue to be fixed. Resolves issue Uniswap#216
The previous attempt to assert identical gas usage in CI has been reverted because a snapshot generated in CI was different from a snapshot generated locally. The diff still exist as of today, but amounts are minuscule. The amounts range from 1 to tens. And these diffs exist in fuzz tests only. This is a known bug in Foundry: foundry-rs/foundry#5689 This commit adds back gas snapshot, and check for a minimum diff in CI. This way, snapshot diff tool can be used while waiting for the Foundry issue to be fixed. Resolves issue Uniswap#216
The previous attempt to assert identical gas usage in CI has been reverted because a snapshot generated in CI was different from a snapshot generated locally. The diff still exist as of today, but amounts are minuscule. The amounts range from 1 to tens. And these diffs exist in fuzz tests only. This is a known bug in Foundry: foundry-rs/foundry#5689 This commit adds back gas snapshot, and check for a small diff in CI. By allowing just one percent of diff, forge snapshot diff tool can be utilized while waiting for the Foundry issue to be fixed. Resolves issue Uniswap#216
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (b536f51 2023-08-21T00:25:51.452435000Z)
What command(s) is the bug in?
forge snapshot --check
Operating System
Linux
Describe the bug
In our CI workflow using Github actions:
We check the present snapshot with
forge snapshot --check {{snapshot}}
.This step is failing due to 1 fuzz test result:
Diff in "...(address,address,uint96)": consumed "(runs: 256, μ: 213572, ~: 213547)" gas, expected "(runs: 256, μ: 213573, ~: 213548)"
The gas measured during CI is consistently lower by 1 than our local machine, i.e. 213572 vs 213573, and 213547 vs 213548.
We are using default number of fuzz runs.
The text was updated successfully, but these errors were encountered: