fix(cast): report transaction types cast cannot encode - #16480
Open
mattsse wants to merge 1 commit into
Open
Conversation
`cast tx --raw` re-encodes the fetched transaction, and alloy panics rather than invent an EIP-2718 encoding for a type it does not model. Arbitrum Nitro opens every block with an `ArbitrumInternalTx` (`0x6a`), so the command crashed the process on any Arbitrum One or Orbit rollup block. `--lane` made the same call and crashed the same way. The response now encodes through `EncodeRpc2718`, which routes `AnyNetwork` via `FoundryTxEnvelope` and reports the types Foundry does not model as an error. The networks with a total envelope of their own encode directly.
mattsse
requested review from
0xrusowsky,
DaniPopes,
figtracer,
grandizzy,
mablr and
stevencartavia
as code owners
August 30, 2026 05:20
Contributor
✅ Changelog foundThe deterministic check will validate the changed entry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cast tx --rawre-encodes the transaction it fetched, and alloy panics rather than invent an EIP-2718 encoding for a type it does not model. Arbitrum Nitro opens every block with anArbitrumInternalTx(0x6a), so the command crashed the process on any Arbitrum One or Orbit rollup block, reachable with nothing more than a block explorer link.--lanemade the same call and crashed the same way.cast txandcast receipton those transactions were unaffected, which is why this went unnoticed.The fix follows what #16465 does for anvil's raw-transaction endpoints: route the response through the Foundry envelope, which knows the types Foundry supports, and report the rest as an error rather than reaching alloy's panic.
Cast::transactionis generic over the network andcast txinstantiates it three ways, so this needs a smallEncodeRpc2718trait rather than a direct call. OnlyAnyTxEnvelopepanics;OpTxEnvelopeandTempoTxEnvelopeencode every type they can deserialize, so their impls encode straight from the envelope while theAnyNetworkimpl goes throughFoundryTxEnvelope. That shape mirrors the existing per-networkUIfmtSignatureExt. The conversion takes the whole RPC transaction rather than the envelope because the deposit path needsfrom.Verified against live endpoints. On Arbitrum and Robinhood Chain the
0x6anow reportsCannot EIP-2718 encode transaction type 0x6awith the process healthy, and standard transactions on those chains and on Ethereum re-encode to bytes whose keccak is the transaction hash.Regression coverage extends the network matrix from #16472, which deliberately left
--rawout because of this panic. It asserts the command never panics, that standard types succeed and round-trip through keccak, and that a failure names the type; the Arbitrum and Robinhood entries reach the error branch becausefind_transactiontakes the first transaction in a block, which on Nitro is always the internal one. Reverting the fix failsflaky_read_arbitrumon all six retries.Two things this does not change.
cast trace --rawpanics identically on a transaction pasted in as JSON, atcrates/cast/src/cmd/trace.rs:57; it is the same one-line fix but a separate path, so it is left for a follow-up. And a live Tempo0x76still cannot be encoded on the default network path, reportingFailed to deserialize tempo tx: missing field 'hash'instead of panicking.cast tx --network tempo --rawhandles it correctly, and the AnyNetwork conversion belongs to #16465.Stacked on #16472 for
read_networks.rs. Independent of #16465, though theAnyNetworkimpl here collapses into that PR'sFoundryTxEnvelope::encode_rpc_2718once both land.AI assistance: written with Claude Code, including the code and tests, then verified locally against live Arbitrum, Robinhood, Ethereum and Tempo endpoints.