Skip to content

bug(anvil): anvil_dumpState is non-deterministic again #9570

Open
@KholdStare

Description

@KholdStare

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 (6b07c77 2024-12-17T16:21:09.880972720Z)

What command(s) is the bug in?

anvil

Operating System

Linux

Describe the bug

anvil_dumpState should be deterministic. In particular, running anvil_dumpState on the same anvil state should result in the same output. This is very important to us, as we rely on dumpState in CI to verify that what we are testing is the same thing that is deployed. If it's not deterministic, then we cannot rely on this check, and could inadvertently start running our tests on slightly different code than what we deployed. This does not fill me with confidence.

There is a long history of this popping back up. I first reported a variation of this 2 years ago here: #3891

To reproduce, see this repo: https://github.com/KholdStare/foundry-dumpstate-bug. In particular this script to reproduce after forge init: https://github.com/KholdStare/foundry-dumpstate-bug/blob/main/run_dumpstate.sh

My main hope from this bug is to have some basic unittests established that will catch regressions in this. This has cropped up numerous times, and each time the issue is fixed but no unittest is added to catch non-determinism in anvil_dumpState. Some tests to try:

  • blank anvil state should produce the same anvil_dumpState every time
  • deploying something should produce the same anvil_dumpState every time
  • round trip test. anvil_dumpState -> anvil_loadState -> anvil_dumpState should produce the same output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions