foundry: `forge test` crashes with `Message: called Option::unwrap() on a None value`
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 (ea2eff9 2024-05-28T00:17:45.727606000Z)
What command(s) is the bug in?
forge test
Operating System
macOS (Apple Silicon)
Describe the bug
The bug lies in the updated Foundry version.
Steps to reproduce:
- Clone the repository
git clone https://github.com/exp-table/pigeon
- Add your RPC URLs to the
.envfile
ETH_MAINNET_RPC_URL=
POLYGON_MAINNET_RPC_URL=
ARBITRUM_MAINNET_RPC_URL=
# Optional
ENABLE_CELER_ESTIMATES=true
ENABLE_HYPERLANE_ESTIMATES=false
ENABLE_LZ_ESTIMATES=true
- Run the tests using
forge test
Logs:
[⠊] Compiling...
No files changed, compilation skipped
Ran 5 tests for test/Celer.t.sol:CelerHelperTest
[PASS] testCustomOrderingCeler() (gas: 108685)
[PASS] testFancyCeler() (gas: 123722)
[PASS] testMultiDstCeler() (gas: 151884)
[PASS] testSimpleCeler() (gas: 72229)
[PASS] testSimpleCelerWithEstimates() (gas: 77270)
Suite result: ok. 5 passed; 0 failed; 0 skipped; finished in 7.69s (1.91s CPU time)
Ran 4 tests for test/Axelar.t.sol:AxelarHelperTest
[PASS] testCustomOrderingAxelar() (gas: 341805)
[PASS] testFancyAxelar() (gas: 236169)
[PASS] testMultiDstAxelar() (gas: 391397)
[PASS] testSimpleAxelar() (gas: 189999)
Suite result: ok. 4 passed; 0 failed; 0 skipped; finished in 11.48s (3.90s CPU time)
The application panicked (crashed).
Message: called `Option::unwrap()` on a `None` value
Location: /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/revm-9.0.0/src/journaled_state.rs:641
This is a bug. Consider reporting it at https://github.com/foundry-rs/foundry
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⋮ 8 frames hidden ⋮
9: core::panicking::panic::hc59c8a709a9b37ae
at <unknown source file>:<unknown line>
10: core::option::unwrap_failed::h64934fbe08d33633
at <unknown source file>:<unknown line>
11: revm::journaled_state::JournaledState::sload::hb292ab2772e652cb
at <unknown source file>:<unknown line>
12: <revm::context::Context<EXT,DB> as revm_interpreter::host::Host>::sload::h7c2eadaa276e2317
at <unknown source file>:<unknown line>
13: revm_interpreter::instructions::host::sload::h1c9497870d645e6c
at <unknown source file>:<unknown line>
14: revm::inspector::handler_register::inspector_instruction::{{closure}}::h03e2dc73635a341d
at <unknown source file>:<unknown line>
15: revm::handler::mainnet::execution::execute_frame::h026fc75de773d06f
at <unknown source file>:<unknown line>
16: revm::evm::Evm<EXT,DB>::transact::h235456cda0c49183
at <unknown source file>:<unknown line>
17: foundry_evm::executors::Executor::call_raw_with_env::he2005afc97600e72
at <unknown source file>:<unknown line>
18: foundry_evm::executors::Executor::execute_test::h9cc3b93e2c860177
at <unknown source file>:<unknown line>
19: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &F>::call_mut::h44e499dd908e19bc
at <unknown source file>:<unknown line>
20: rayon::iter::plumbing::bridge_producer_consumer::helper::h2693959307ecc7a2
at <unknown source file>:<unknown line>
21: rayon_core::join::join_context::{{closure}}::h6ffee74b42c8d4bf
at <unknown source file>:<unknown line>
22: rayon::iter::plumbing::bridge_producer_consumer::helper::h2693959307ecc7a2
at <unknown source file>:<unknown line>
23: rayon_core::join::join_context::{{closure}}::h6ffee74b42c8d4bf
at <unknown source file>:<unknown line>
24: rayon::iter::plumbing::bridge_producer_consumer::helper::h2693959307ecc7a2
at <unknown source file>:<unknown line>
25: rayon_core::join::join_context::{{closure}}::h6ffee74b42c8d4bf
at <unknown source file>:<unknown line>
26: rayon::iter::plumbing::bridge_producer_consumer::helper::h2693959307ecc7a2
at <unknown source file>:<unknown line>
27: forge::runner::ContractRunner::run_tests::h1f32def75e6f25bf
at <unknown source file>:<unknown line>
28: forge::multi_runner::MultiContractRunner::run_tests::hac520a5a0e7c1729
at <unknown source file>:<unknown line>
29: rayon::iter::plumbing::bridge_producer_consumer::helper::h16cdcbd0a900c75f
at <unknown source file>:<unknown line>
30: rayon_core::join::join_context::{{closure}}::h3308bff5d566a6dc
at <unknown source file>:<unknown line>
31: rayon::iter::plumbing::bridge_producer_consumer::helper::h16cdcbd0a900c75f
at <unknown source file>:<unknown line>
32: <rayon_core::job::StackJob<L,F,R> as rayon_core::job::Job>::execute::hbcf434872e4b1d95
at <unknown source file>:<unknown line>
33: rayon_core::registry::WorkerThread::wait_until_cold::hc2f2f5c5d2ac906c
at <unknown source file>:<unknown line>
34: std::sys_common::backtrace::__rust_begin_short_backtrace::h26c5ce7ae435c375
at <unknown source file>:<unknown line>
35: core::ops::function::FnOnce::call_once{{vtable.shim}}::h7359e7db922f9b5d
at <unknown source file>:<unknown line>
36: std::sys::pal::unix::thread::Thread::new::thread_start::h9266fbbdd0c3d8be
at <unknown source file>:<unknown line>
37: __pthread_joiner_wake<unknown>
at <unknown source file>:<unknown line>
Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
zsh: abort forge test
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (1 by maintainers)
So below, I’ve attached a mock file, which we use for our token bridging simulation. We switch fork and deal tokens to mock a cross-chain bridging action that primarily runs into the same issue. This is a PoC, but we might sometimes need the state of the other fork, so that’s why we cannot use the
vm. makePersistentOh, right, I think that’s best option, so when fork changed if caller not persistent we autoset it
Thanks for the prompt response. That works, for now, I hope this issue is fixed in the Foundry as it could break the users of the library, too, I assume.
simplified version of test to reproduce issue
@sujithsomraaj please make
wormholeHelperpersistent for fixing it for the momentwhat likely happens is that since you create / select multiple forks in setup the
wormholeHelperis ending up in a different fork env than the active one used when callingvm.loadin_prepareWormhole