matter-labs / foundry-zksync

Fork of Foundry tailored for zkSync environment
Apache License 2.0
291 stars 125 forks source link

forge test --zksync crashes #575

Open alexhooketh opened 2 weeks ago

alexhooketh commented 2 weeks ago

Component

Forge

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

What version of Foundry are you on?

forge 0.0.2 (a1155ab 2024-09-01T00:28:04.703903000Z)

What command(s) is the bug in?

forge test --zksync

Operating System

macOS (Apple Silicon)

Describe the bug

I'm running "forge test --zksync" on this. This is the output:

jordan@Air-Alex contracts % forge test --zksync
[⠊] Compiling...
No files changed, compilation skipped
[⠃] Using zksolc-1.5.2
[⠊] Compiling (zksync)
[⠒] Compiling 8 files with zksolc and solc 0.8.20
[⠢] zksolc and solc 0.8.20 finished in 48.82s
Compiler run successful!
The application panicked (crashed).
Message:  called `Option::unwrap()` on a `None` value
Location: crates/zksync/compiler/src/zksolc/mod.rs:136

This is a bug. Consider reporting it at https://github.com/foundry-rs/foundry

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   1: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
   2: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
   3: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
   4: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
   5: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
   6: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
   7: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
   8: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
   9: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
  10: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
  11: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
  12: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
  13: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
  14: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
  15: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
  16: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
  17: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
  18: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
  19: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
  20: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
  21: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>
  22: __mh_execute_header<unknown>
      at <unknown source file>:<unknown line>

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
Run with RUST_BACKTRACE=full to include source snippets.
zsh: abort      forge test --zksync

Running the tests without --zksync, however, works properly:

...
[PASS] test_stopOrder_RevertIf_NonCreatorStopsOrder() (gas: 589949)
[PASS] test_stopOrder_StopOrder() (gas: 531739)
Suite result: ok. 38 passed; 0 failed; 0 skipped; finished in 3.92ms (13.13ms CPU time)

Ran 3 tests for test/UntronState.t.sol:UntronStateTest
[PASS] test_changeRateLimit_RevertIf_NotUpgraderRole() (gas: 15907)
[PASS] test_changeRateLimit_SetRateLimit() (gas: 26426)
[PASS] test_setUp() (gas: 20606)
Suite result: ok. 3 passed; 0 failed; 0 skipped; finished in 3.87ms (526.33µs CPU time)

Ran 5 test suites in 163.40ms (15.90ms CPU time): 52 tests passed, 0 failed, 0 skipped (52 total tests)
jordan@Air-Alex contracts %

I don't know if it worked before, because I've always used forge test without --zksync. I'll try running the tests before that commit and update this issue. forge build works properly both with and without --zksync.

elfedy commented 1 week ago

@alexhooketh this is known to happen in some cases due to non deterministic builds. Check the discussion here, cleaning the cache or setting force_evmla to true in zksolc settings should serve as a good wrokaround until we find a better solution. If the issue still persists for you, could you give us an example reproducing it so we can look into it?