Skip to content

fix(kona): graceful OOG on precompile gas overspend in fpvm provider#21582

Open
ajsutton wants to merge 1 commit into
developfrom
aj/fix/kona-precompile-overspend-oog
Open

fix(kona): graceful OOG on precompile gas overspend in fpvm provider#21582
ajsutton wants to merge 1 commit into
developfrom
aj/fix/kona-precompile-overspend-oog

Conversation

@ajsutton

Copy link
Copy Markdown
Contributor

What

The fpvm precompile provider's hand-rolled run panicked via assert!(underflow, "Gas underflow is not possible") if a precompile reported gas_used > gas_limit. Align it with revm v40's EthPrecompiles::run (which op-revm inherits by delegation): gracefully out-of-gas the call (spend_all + PrecompileOOG) instead of panicking.

Why

Surfaced while reviewing the reth v2.3.0 / revm v40 bump (#21348). revm v40 added defensive handling for a precompile overspending its gas limit; op-revm picks it up automatically by delegation, but kona reimplements run and still asserts.

The branch is unreachable for the current registered precompile set — every accelerated and inner precompile checks cost <= gas_limit before returning Ok — so there is no consensus or fault-proof divergence today. This is hardening: it keeps the FPVM and op-reth aligned by construction rather than by audit, and removes a foot-gun where a future precompile that omits the check would halt the fault-proof program instead of deterministically OOG-ing.

Test

test_run_overspending_precompile_oogs_without_panicking registers a mock accelerated precompile reporting gas_used = gas_limit + 1 and asserts run returns PrecompileOOG with all gas spent. Verified red against the old assert! (panics at provider.rs:148) and green with the fix.

The fpvm precompile provider's hand-rolled `run` panicked via
`assert!(underflow, "Gas underflow is not possible")` if a precompile
reported `gas_used > gas_limit`. revm v40's `EthPrecompiles::run` (which
op-revm inherits by delegation) instead gracefully out-of-gases this case
(`spend_all` + `PrecompileOOG`).

The branch is unreachable for the registered precompile set — each checks
cost <= gas_limit before returning `Ok` — so there is no consensus impact.
But matching upstream keeps the FPVM and op-reth aligned by construction
rather than by audit, and removes a foot-gun where a future precompile
that omits the check would halt the fault-proof program instead of
deterministically OOG-ing.
@ajsutton ajsutton requested a review from a team as a code owner June 26, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant