Skip to content

bug: flaky gas snapshot for some fuzz tests #7942

@cruzdanilo

Description

@cruzdanilo

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 (467aff3 2024-05-17T00:17:24.004804000Z)

What command(s) is the bug in?

forge snapshot

Operating System

macOS (Apple Silicon)

Describe the bug

for some fuzz tests (not sure which ones), forge fails to generate consistent gas snapshots, even when using the --force flag. this prevents it from being relied upon for ci validation (forge snapshot --check). the same behavior happens on macos (apple silicon) and linux (x86-64).

i created a somewhat minimal reproduction repository here: https://github.com/cruzdanilo/foundry-snapshot-repro

this is one output generated by for i in {1..16}; do forge snapshot --force | grep runs; done

[PASS] test_snapshot((bytes,bytes,uint256,uint256,uint256)) (runs: 256, μ: 407539, ~: 408263)
[PASS] test_snapshot((bytes,bytes,uint256,uint256,uint256)) (runs: 256, μ: 407539, ~: 408263)
[PASS] test_snapshot((bytes,bytes,uint256,uint256,uint256)) (runs: 256, μ: 407518, ~: 408251)
[PASS] test_snapshot((bytes,bytes,uint256,uint256,uint256)) (runs: 256, μ: 407518, ~: 408251)
[PASS] test_snapshot((bytes,bytes,uint256,uint256,uint256)) (runs: 256, μ: 407518, ~: 408251)
[PASS] test_snapshot((bytes,bytes,uint256,uint256,uint256)) (runs: 256, μ: 407518, ~: 408251)
[PASS] test_snapshot((bytes,bytes,uint256,uint256,uint256)) (runs: 256, μ: 407539, ~: 408263)
[PASS] test_snapshot((bytes,bytes,uint256,uint256,uint256)) (runs: 256, μ: 407539, ~: 408263)
[PASS] test_snapshot((bytes,bytes,uint256,uint256,uint256)) (runs: 256, μ: 407518, ~: 408251)
[PASS] test_snapshot((bytes,bytes,uint256,uint256,uint256)) (runs: 256, μ: 407518, ~: 408251)
[PASS] test_snapshot((bytes,bytes,uint256,uint256,uint256)) (runs: 256, μ: 407518, ~: 408251)
[PASS] test_snapshot((bytes,bytes,uint256,uint256,uint256)) (runs: 256, μ: 407518, ~: 408251)
[PASS] test_snapshot((bytes,bytes,uint256,uint256,uint256)) (runs: 256, μ: 407539, ~: 408263)
[PASS] test_snapshot((bytes,bytes,uint256,uint256,uint256)) (runs: 256, μ: 407539, ~: 408263)
[PASS] test_snapshot((bytes,bytes,uint256,uint256,uint256)) (runs: 256, μ: 407518, ~: 408251)
[PASS] test_snapshot((bytes,bytes,uint256,uint256,uint256)) (runs: 256, μ: 407518, ~: 408251)

this was run on github ci, here is the report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions