Skip to content

Running benchmarks causes assertion failed; counterexample on solmate ERC6909 #7531

@sambacha

Description

@sambacha

Component

Forge

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

Latest and commit 070297f52

What command(s) is the bug in?

cargo criterion

Operating System

macOS latest

Describe the bug

When checking out repo and running the following command, I got the following error:

```console
$ cargo criterion --message-format=json >main.json
# (...) passing tests truncated 
Suite result: ok. 76 passed; 0 failed; 0 skipped; finished in 2.47s (12.48s CPU time)

Ran 23 test suites in 2.47s (15.71s CPU time): 566 tests passed, 2 failed, 0 skipped (568 total tests)

Failing tests:
Encountered 2 failing tests in src/test/ERC6909.t.sol:ERC6909Test
[FAIL. Reason: assertion failed; counterexample: calldata=0xc5b21e8f0000000000000000000000007fa9385be102ac3eac297483dd6233d62b3e1496000000000000000000000000000000000000f6823079e2075d4730ceee5e7dc700000000000000000000000000000000000000000000000000000000000001f600000000000000000000000000000000000000000000000000000000000025d4 args=[0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496, 0x000000000000F6823079e2075D4730CEeE5e7dc7, 502, 9684]] testFailTransferFromNotAuthorized(address,address,uint256,uint256) (runs: 220, μ: 38677, ~: 38677)
[FAIL. Reason: assertion failed; counterexample: calldata=0xaad06d3d0000000000000000000000007fa9385be102ac3eac297483dd6233d62b3e1496000000000000000000000000000000000000000000000000000000000000015900000000000000000000000000000000000000000000000000000000000002b500000000000000000000000000000000000000000000000000000000000018be0000000000000000000000000000000000000000000000000000000000001ac0 args=[0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496, 0x0000000000000000000000000000000000000159, 693, 6334, 6848]] testTransferFromWithApproval(address,address,uint256,uint256,uint256) (runs: 1, μ: 34778, ~: 34778)

Encountered a total of 2 failing tests, 566 tests succeeded


stderr:
proptest: Saving this and future failures in cache/fuzz/failures
proptest: If this test was run on a CI system, you may wish to add the following line to your copy of the file. (You may need to create it.)
cc d02cc4795c397123f9383085a20f5e0cd451982d8c0a8ea8a361fafa75278028


Location:
    crates/forge/benches/test.rs:18:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at /Users/janitor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-criterion-1.1.0/src/bench_target.rs:306:26:
Unexpected message FinishedBenchmarkGroup { group: "forge test" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at /Users/janitor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/criterion-0.5.1/src/benchmark_group.rs:380:18:
called `Result::unwrap()` on an `Err` value: Io(Error { kind: UnexpectedEof, message: "failed to fill whole buffer" })
stack backtrace:
   0:        0x102793a68 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3be43c6214e69043
   1:        0x1025eb434 - core::fmt::write::h12f9049830901a82
   2:        0x102767ff0 - std::io::Write::write_fmt::h2ff514dfe799c882
   3:        0x102794b38 - std::sys_common::backtrace::print::h722d6ff0889d39c2
   4:        0x1027947f4 - std::panicking::default_hook::{{closure}}::hd7f9985c1b9ae0aa
   5:        0x1027958a4 - std::panicking::rust_panic_with_hook::h401df0236a0e7dae
   6:        0x102795358 - std::panicking::begin_panic_handler::{{closure}}::h67f4ee7322151c3c
   7:        0x1027952bc - std::sys_common::backtrace::__rust_end_short_backtrace::hbce128a2ff88406e
   8:        0x1027952b0 - _rust_begin_unwind
   9:        0x1025e9fa8 - core::panicking::panic_fmt::hecc1dfe94cb15bc7
  10:        0x1025eea7c - core::result::unwrap_failed::h5e7f249f3c140ed3
  11:        0x1025640d0 - core::ptr::drop_in_place<criterion::benchmark_group::BenchmarkGroup<criterion::measurement::WallTime>>::h0e944e13e27ce2b6
  12:        0x102593964 - test::forge_test_benchmark::hbca3edb384b13717
  13:        0x102593ab0 - test::main::had743751bcf297d8
  14:        0x10256029c - std::sys_common::backtrace::__rust_begin_short_backtrace::hfa6cb04ca6ea436b
  15:        0x102593e1c - _main
thread 'main' panicked at library/core/src/panicking.rs:163:5:
panic in a destructor during cleanup
thread caused non-unwinding panic. aborting.

I went back in the commit and picked an arbitrary commit to bisect against, and got the same failing test (however this time its only 1, not 2)

commit 070297f52

$  cargo criterion --message-format=json > main.json

Test result: ok. 30 passed; 0 failed; 0 skipped; finished in 1.57s

Ran 23 test suites: 567 tests passed, 1 failed, 0 skipped (568 total tests)

Failing tests:
Encountered 1 failing test in src/test/ERC6909.t.sol:ERC6909Test
[FAIL. Reason: assertion failed; counterexample: calldata=0xc5b21e8f0000000000000000000000007fa9385be102ac3eac297483dd6233d62b3e149600000000000000000000000000000000000000000000000000000000000010d90000000000000000000000000000000000000000000000000000000000001a2c0000000000000000000000000000000000000000000000000000000000001dda args=[0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496, 0x00000000000000000000000000000000000010D9, 6700, 7642]] testFailTransferFromNotAuthorized(address,address,uint256,uint256) (runs: 44, μ: 38677, ~: 38677)

Encountered a total of 1 failing tests, 567 tests succeeded


stderr:


Location:
    crates/forge/benches/test.rs:18:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at /Users/janitor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-criterion-1.1.0/src/bench_target.rs:306:26:
Unexpected message FinishedBenchmarkGroup { group: "forge test" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at /Users/janitor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/criterion-0.5.1/src/benchmark_group.rs:380:18:
called `Result::unwrap()` on an `Err` value: Io(Error { kind: UnexpectedEof, message: "failed to fill whole buffer" })
stack backtrace:
   0:        0x1044716c8 - __mh_execute_header
   1:        0x1042c9410 - __mh_execute_header
   2:        0x104445cd4 - __mh_execute_header
   3:        0x104472798 - __mh_execute_header
   4:        0x104472454 - __mh_execute_header
   5:        0x104473504 - __mh_execute_header
   6:        0x104472fb8 - __mh_execute_header
   7:        0x104472f1c - __mh_execute_header
   8:        0x104472f10 - __mh_execute_header
   9:        0x1042c7f84 - __mh_execute_header
  10:        0x1042cca58 - __mh_execute_header
  11:        0x104243d0c - __mh_execute_header
  12:        0x104271a8c - __mh_execute_header
  13:        0x104271b94 - __mh_execute_header
  14:        0x1042401b0 - __mh_execute_header
  15:        0x104271f00 - __mh_execute_header
thread 'main' panicked at library/core/src/panicking.rs:163:5:
panic in a destructor during cleanup
thread caused non-unwinding panic. aborting.

Additionally, I cloned solmate in a separate directory and ran the tests and they are all passing (no errors reported).

[PASS] testFailTransferFromNotAuthorized() (gas: 36078)
Traces:
  [36078] ERC6909Test::testFailTransferFromNotAuthorized()
    ├─ [25249] MockERC6909::mint(0x000000000000000000000000000000000000ABcD, 1337, 100)
    │   ├─ emit Transfer(caller: ERC6909Test: [0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496], from: 0x0000000000000000000000000000000000000000, to: 0x000000000000000000000000000000000000ABcD, id: 1337, amount: 100)
    │   └─ ← [Stop]
    ├─ [5207] MockERC6909::transferFrom(0x000000000000000000000000000000000000ABcD, 0x000000000000000000000000000000000000bEEF, 1337, 100)
    │   └─ ← [Revert] panic: arithmetic underflow or overflow (0x11)
    └─ ← [Revert] panic: arithmetic underflow or overflow (0x11)

[PASS] testFailTransferFromNotAuthorized(address,address,uint256,uint256) (runs: 256, μ: 38677, ~: 38677)
Traces:
  [38677] ERC6909Test::testFailTransferFromNotAuthorized(0x0000000000000000000000000000000000000158, 0x00000000000000000000000000000000000042Ad, 4807, 12598 [1.259e4])
    ├─ emit log_named_uint(key: "Bound Result", val: 12599 [1.259e4])
    ├─ [25249] MockERC6909::mint(0x0000000000000000000000000000000000000158, 4807, 12599 [1.259e4])
    │   ├─ emit Transfer(caller: ERC6909Test: [0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496], from: 0x0000000000000000000000000000000000000000, to: 0x0000000000000000000000000000000000000158, id: 4807, amount: 12599 [1.259e4])
    │   └─ ← [Stop]
    ├─ [5207] MockERC6909::transferFrom(0x0000000000000000000000000000000000000158, 0x00000000000000000000000000000000000042Ad, 4807, 12599 [1.259e4])
    │   └─ ← [Revert] panic: arithmetic underflow or overflow (0x11)
    └─ ← [Revert] panic: arithmetic underflow or overflow (0x11)

Also, proptes says it is saving this and future failures in cache/fuzz/failures but can not find it

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions