Skip to content

fix(cast): stop re-validating mined transactions on replay - #16457

Merged
mattsse merged 2 commits into
masterfrom
mattsse/cast-run-replay-validation
Aug 29, 2026
Merged

fix(cast): stop re-validating mined transactions on replay#16457
mattsse merged 2 commits into
masterfrom
mattsse/cast-run-replay-validation

Conversation

@mattsse

@mattsse mattsse commented Aug 29, 2026

Copy link
Copy Markdown
Member

cast run re-applied two checks that a mined transaction has already passed on-chain, and each one made whole chains unreplayable.

The block gas limit check rejects transactions that some chains admit anyway. BSC validator transactions carry a gas limit of i64::MAX, well past the 55M block limit, so replaying one failed with transaction validation error: caller gas limit exceeds the block gas limit. Replay now always skips the check, which is what cast call --trace already does; --disable-block-gas-limit stays accepted and is now implied.

Requiring a parent beacon block root for Cancun bakes in Ethereum's beacon chain. Polygon and Scroll run a Cancun or later EVM without one and never deploy the EIP-4788 contract, so every transaction on them failed with MissingParentBeaconBlockRoot, at every --evm-version from Cancun up — there was no flag that got past it. The root is applied when the header carries one and skipped when it does not, so Ethereum replay is unaffected and chains without a beacon chain simply have no root to apply.

Found by replaying recent blocks on twelve chains and diffing against eth_getBlockReceipts. After the change, Scroll transactions replay and match receipt gas exactly, Polygon transactions replay, and Ethereum, Avalanche and Optimism are unchanged.


This PR was written by Claude Code, including the survey behind it and this description. Verified against live nodes for each chain named above.

`cast run` re-applied two checks that a mined transaction has already
passed, and both made whole chains unreplayable.

The block gas limit check rejects transactions some chains admit anyway:
BSC validator transactions carry a gas limit of `i64::MAX`, so replaying
any transaction in such a block failed with "caller gas limit exceeds the
block gas limit". Replay now always skips the check, matching what
`cast call --trace` already does.

Requiring a parent beacon block root for Cancun assumes Ethereum's beacon
chain. Polygon and Scroll run a Cancun or later EVM without one and never
deploy the EIP-4788 contract, so every transaction on them failed with
`MissingParentBeaconBlockRoot` at any `--evm-version` at or above Cancun.
The root is now applied when the header carries one and skipped when it
does not.

Verified against live nodes: Scroll and Polygon transactions replay,
Scroll matches receipt gas exactly, and Ethereum, Avalanche and Optimism
are unchanged.
@github-actions

Copy link
Copy Markdown
Contributor

✅ Changelog found

The deterministic check will validate the changed entry.

Comment thread crates/cast/src/cmd/run.rs
The helper can no longer fail, so it drops the `Result` and becomes a `const fn`, which clippy's `missing_const_for_fn` required.

`run_disable_block_gas_limit_check` asserted that replay fails without `--disable-block-gas-limit`. Replay no longer applies that check, so both invocations now expect success and the test is renamed for what it covers.
@mattsse
mattsse merged commit e35ebe7 into master Aug 29, 2026
27 checks passed
@mattsse
mattsse deleted the mattsse/cast-run-replay-validation branch August 29, 2026 08:43
@github-project-automation github-project-automation Bot moved this to Done in Foundry Aug 29, 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