Skip to content

Conversation

zerosnacks
Copy link
Member

@zerosnacks zerosnacks commented Jul 29, 2025

Motivation

Closes: #11128

Solution

Previously resulted in:

eth_simulateV1
The application panicked (crashed).
Message:  called `Option::unwrap()` on a `None` value
Location: crates/anvil/src/eth/backend/mem/mod.rs:1729

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

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 7 frames hidden ⋮                               
   8: core::panicking::panic::h4a11c031239f36a8
      at <unknown source file>:<unknown line>
   9: core::option::unwrap_failed::h62317944fa5dc382
      at <unknown source file>:<unknown line>
  10: anvil::eth::backend::mem::Backend::simulate::{{closure}}::{{closure}}::h4f7a2c0dde92fd30
      at <unknown source file>:<unknown line>
  11: tokio::runtime::task::raw::poll::h07991a65e36b9f08
      at <unknown source file>:<unknown line>
  12: std::sys::backtrace::__rust_begin_short_backtrace::h7f53d53b8358a8a1
      at <unknown source file>:<unknown line>
  13: core::ops::function::FnOnce::call_once{{vtable.shim}}::hdf48ba9eb1133995
      at <unknown source file>:<unknown line>
  14: std::sys::pal::unix::thread::Thread::new::thread_start::h1822d22fde68314f
      at <unknown source file>:<unknown line>
  15: start_thread<unknown>
      at ./nptl/pthread_create.c:447
  16: clone3<unknown>
      at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
Aborted (core dumped)

now yields (and no longer panics):

(user side)

{"jsonrpc":"2.0","id":1,"error":{"code":-32602,"message":"Failed to parse transaction request: missing required fields"}}

(anvil side)

eth_simulateV1

RPC request failed:
    Request: EthSimulateV1(SimulatePayload { block_state_calls: [SimBlock { block_overrides: None, state_overrides: None, calls: [TransactionRequest { from: Some(0x26e9568a58a5fd4437e7674d857dc3b2b1d30ddd), to: Some(Call(0x88c430c91cbb608b41cdb2fce27604e12233233f)), gas_price: None, max_fee_per_gas: Some(3159), max_priority_fee_per_gas: Some(847), max_fee_per_blob_gas: None, gas: Some(300000), value: Some(0), input: TransactionInput { input: None, data: Some(0x629c6d8e04ede7b81aae6bdb1f36d1c80f85f253860527578929149cfdce8fd4cdeaa4980000000000000000000000000000000000000000000000000000000000000060a420871db2c68c3ba70219ca71c81aed7452a208eb54ab66a957aeb95dc4c7ba0000000000000000000000000000000000000000000000000000000000000030b1cc3955fd6cda4e19a15e4eb8e6e71f6cb59f98fab8e7ed087d05b1a3bf878bba289eee016bd23ccbdd3533ec98f2e000000000000000000000000000000000) }, nonce: Some(1487), chain_id: None, access_list: None, transaction_type: Some(3), blob_versioned_hashes: None, sidecar: None, authorization_list: None }] }], trace_transfers: true, validation: false, return_full_transactions: false }, Some(latest))
    Error: Invalid params: Failed to parse transaction request: missing required fields

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@zerosnacks zerosnacks moved this to Ready For Review in Foundry Jul 29, 2025
@zerosnacks zerosnacks marked this pull request as ready for review July 29, 2025 10:11
Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@zerosnacks zerosnacks enabled auto-merge (squash) July 29, 2025 10:12
@zerosnacks zerosnacks merged commit 54d2561 into master Jul 29, 2025
22 checks passed
@zerosnacks zerosnacks deleted the zerosnacks/fix-anvil-crash branch July 29, 2025 10:17
@github-project-automation github-project-automation bot moved this from Ready For Review to Done in Foundry Jul 29, 2025
grandizzy pushed a commit to grandizzy/foundry that referenced this pull request Jul 29, 2025
)

make typed request casting not panic and return useful error to user
grandizzy added a commit that referenced this pull request Jul 29, 2025
* perf: box inspectors in InspectorStack (#11100)

* fix: use existing functions for accountinfo (#11134)

* fix(`anvil`): unwrap panic in `eth/backend/mem/mod.rs` (#11141)

make typed request casting not panic and return useful error to user

---------

Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com>
grandizzy pushed a commit to grandizzy/foundry that referenced this pull request Jul 30, 2025
)

make typed request casting not panic and return useful error to user
grandizzy added a commit that referenced this pull request Jul 30, 2025
* Revert "v1.3.0: backport perf improvements and anvil fixes (#11136)"

This reverts commit 13ca215.

* fix: use existing functions for accountinfo (#11134)

* fix(`anvil`): unwrap panic in `eth/backend/mem/mod.rs` (#11141)

make typed request casting not panic and return useful error to user

---------

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com>
grandizzy pushed a commit to grandizzy/foundry that referenced this pull request Aug 5, 2025
)

make typed request casting not panic and return useful error to user
@grandizzy grandizzy mentioned this pull request Aug 5, 2025
3 tasks
grandizzy added a commit that referenced this pull request Aug 5, 2025
* fix(cast): use all providers if local artifacts used (#11090)

* fix(cast): use all providers if local artifacts used

* Fix

* fix(cast): improve handling of `mktx --raw-unsigned` with runtime validation (#11111)

* fix(mktx): improve handling of `--raw-unsigned` with runtime validation

- Updated the logic for handling the `--from` argument in the `run` function.
- Added validation for required `nonce` parameter when `--from` is not provided, ensuring necessary transaction details are specified.
- Used `Address::ZERO` as a placeholder when there is no need to query provider
- unit tests

* fix: fmt

* fix(`anvil`): unwrap panic in `eth/backend/mem/mod.rs` (#11141)

make typed request casting not panic and return useful error to user

* fix(forge): consistent handling unresolved imports (#11164)

* fix(forge): consistent handling unresolved imports

* Add test

* fix(lint): exclude disabled ids in multi-lint passes (#11122)

* fix: use empty 7702 auths (#11182)

* fix(forge): bump compilers to fix remapping sol file (#11184)

* Bump compilers 0.18.2

* Add test

* fix(coverage): disambiguate duplicate function names (#11188)

* fix(forge): set state changes journal in active fork (#11196)

* chore(ci): fix `typos` CI job failing (#11198)

fix typos

* Bump version 1.3.1 (#11199)

* fix(forge): improve error messages for etherscan verification failures (#11194)

* fix(forge): improve error messages for etherscan verification failures

* fix: cargo clippy

* tests(forge): add tests for unknown chain id

* fix: err formating for EtherscanConfigError

---------

Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com>

* chore(tests): bump forge-std version (#11174)

* chore: bump forge-std version used for tests

* Fixes

---------

Co-authored-by: DaniPopes <DaniPopes@users.noreply.github.com>
Co-authored-by: grandizzy <grandizzy.the.egg@gmail.com>

---------

Co-authored-by: Mablr <59505383+mablr@users.noreply.github.com>
Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com>
Co-authored-by: 0xrusowsky <90208954+0xrusowsky@users.noreply.github.com>
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
Co-authored-by: Shiyas Mohammed <83513144+shiyasmohd@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: DaniPopes <DaniPopes@users.noreply.github.com>
MerkleBoy pushed a commit to MerkleBoy/foundry that referenced this pull request Sep 17, 2025
)

make typed request casting not panic and return useful error to user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug(anvil): unwrap panic in eth/backend/mem/mod.rs

4 participants