Skip to content

fix(cast): use FoundryNetwork for RPC provider in cast run#14211

Closed
decofe wants to merge 1 commit into
masterfrom
zerosnacks/fix-cast-run-op-deser
Closed

fix(cast): use FoundryNetwork for RPC provider in cast run#14211
decofe wants to merge 1 commit into
masterfrom
zerosnacks/fix-cast-run-op-deser

Conversation

@decofe
Copy link
Copy Markdown
Contributor

@decofe decofe commented Apr 9, 2026

Summary

Fixes cast run failing on OP Stack chains (Base, Optimism) with:

Error: deserialization error: data did not match any variant of untagged enum BlockTransactions

Observed in nightly CI:

Motivation

The generic FoundryEvmNetwork refactor (#14121) changed cast run from using AnyNetwork to dispatching via FEN::Network. Non-Tempo chains use EthEvmNetwork whose Network = Ethereum, which cannot deserialize OP deposit transactions (type 0x7e). When cast run fetches a full block from Base or Optimism, the block contains deposit transactions that Ethereum's TxEnvelope can't parse.

Changes

Decouples the RPC provider network type from the EVM factory by making run_with_provider generic over both FEN (EVM factory) and N (provider network). The dispatch in run() detects OP Stack chains early via is_optimism() and uses FoundryNetwork as the provider network.

  • crates/cast/src/cmd/run.rs: Rename run_with_evmrun_with_provider<FEN, N>, add OP detection branch
  • crates/cast/Cargo.toml: Add foundry-primitives dependency

Testing

  • Full workspace cargo check passes
  • Fixes flaky_osaka_can_run_p256_precompile (Base) and flaky_test_non_mainnet_traces (Optimism)

Prompted by: zerosnacks

`cast run` on OP Stack chains (Base, Optimism) fails with:
`data did not match any variant of untagged enum BlockTransactions`

Root cause: the generic `FoundryEvmNetwork` refactor (PR #14121) changed
`cast run` from using `AnyNetwork` to dispatching via `FEN::Network`.
Non-Tempo chains use `EthEvmNetwork` whose `Network = Ethereum`, which
cannot deserialize OP deposit transactions (type 0x7e).

Fix: decouple the RPC provider network type from the EVM factory by making
`run_with_provider` generic over both `FEN` (EVM factory) and `N`
(provider network). The dispatch in `run()` now detects OP Stack chains
early via `is_optimism()` and uses `FoundryNetwork` as the provider
network, which supports all transaction types including OP deposits.

Co-Authored-By: zerosnacks <95942363+zerosnacks@users.noreply.github.com>
@decofe decofe force-pushed the zerosnacks/fix-cast-run-op-deser branch from 5365a1a to 69b520d Compare April 9, 2026 07:50
@zerosnacks zerosnacks closed this Apr 9, 2026
@github-project-automation github-project-automation Bot moved this to Done in Foundry Apr 9, 2026
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.

2 participants