NomicFoundation / edr

An Ethereum development runtime implementation that can be reused to build new developer tools.
MIT License
57 stars 12 forks source link

Unexpected thread '<unnamed>' panicked at `crates/foundry/cheatcodes/src/fs.rs:387:61` error #701

Closed agostbiro closed 1 week ago

agostbiro commented 2 weeks ago

The full error is:

thread '<unnamed>' panicked at crates/foundry/cheatcodes/src/fs.rs:387:61:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: foundry_cheatcodes::fs::get_artifact_code
   4: foundry_cheatcodes::fs::<impl foundry_cheatcodes::Cheatcode for foundry_cheatcodes_spec::vm::Vm::getCodeCall>::apply
   5: foundry_cheatcodes::Cheatcode::apply_traced
   6: <foundry_cheatcodes::inspector::Cheatcodes as revm::inspector::Inspector<DB>>::call
   7: revm::inspector::_::<impl revm::inspector::Inspector<DB> for &mut T>::call
   8: revm::inspector::handler_register::inspector_handle_register::{{closure}}
   9: revm::handler::handle_types::execution::ExecutionHandler<EXT,DB>::call
  10: revm::evm::Evm<EXT,DB>::transact
  11: foundry_evm::executors::Executor::call_raw_with_env
  12: foundry_evm::executors::Executor::execute_test
  13: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &F>::call_mut
  14: rayon::iter::plumbing::bridge_producer_consumer::helper
  15: rayon_core::join::join_context::{{closure}}
  16: <rayon_core::job::StackJob<L,F,R> as rayon_core::job::Job>::execute
  17: rayon_core::registry::WorkerThread::wait_until_cold
thread '<unnamed>' panicked at crates/foundry/cheatcodes/src/fs.rs:387:61:
index out of bounds: the len is 0 but the index is 0
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Reproduction steps:

  1. Check out the wip/testing-solidity-tests-wtih-hardhat branch of NomicFoundation/edr.
  2. Check out the wip/solidity-test-merged branch of NomicFoundation/hardhat
  3. Go to v-next/hardhat of the Hardhat checkout
  4. Build Hardhat with pnpm build
  5. Go to crates/edr_solidity_tests/tests/testdata of the EDR checkout
  6. Link Hardhat with npm link $PATH_TO_HARDHAT/v-next/hardhat
  7. Replace the value of https://github.com/NomicFoundation/edr/blob/wip/testing-solidity-tests-wtih-hardhat/crates/edr_solidity_tests/tests/testdata/hardhat.config.js#L4 with ["default/fuzz", "multi-version"] or ["default/repros", "multi-version"].
  8. Run solidity tests with npx hardhat3 test:solidity
iosh commented 1 week ago

@agostbiro Can i try this issue?

agostbiro commented 1 week ago

Sure thanks @iosh . I might have actually fixed this already in https://github.com/NomicFoundation/edr/pull/716. Could you test it out by merging the latest feat/solidity-tests into your fork's wip/testing-solidity-tests-wtih-hardhat?

iosh commented 1 week ago

Sure thanks @iosh . I might have actually fixed this already in #716. Could you test it out by merging the latest feat/solidity-tests into your fork's wip/testing-solidity-tests-wtih-hardhat?

Ok , I will follow the steps to test and verify this issue.

iosh commented 1 week ago

@agostbiro I merged your change into the branch and the panic is resolved, When i run the npx hardhat3 test:solidity i see some tests fail, but i think the panic problem is resolved, should is submit a PR(your changes) to the wip/testing-solidity-tests-with-hardhat branch, or should just close this issue?

agostbiro commented 1 week ago

Awesome thanks @iosh ! I think it's expected that some tests fail there. We can close this issue.