Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2025

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 <[email protected]>
Co-authored-by: Matthias Seitz <[email protected]>
Co-authored-by: zerosnacks <[email protected]>
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 <[email protected]>
Co-authored-by: zerosnacks <[email protected]>
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