Skip to content

bug(EL): payload builder still panics on cumulative-gas checked_add overflow #452

Open

Description

@crazywriter1

Bug

crates/execution-payload/src/payload.rs still panics on two cumulative-gas accounting paths via:

checked_add(...).expect("total gas shouldn't overflow")
  1. Pre-execution capacity check (pool_tx.gas_limit())
  2. Post-execution cumulative update (gas_used)

If either checked_add returns None, the payload builder aborts instead of failing with a structured PayloadBuilderError / invalid-tx path.

Why this is a bug (not a refactor)

Impact

In production the overflow is extremely unlikely (gas_used / gas_limit are bounded by the block gas limit, far below u64::MAX). The bug is still real: an unreachable panic is the wrong failure mode for block building, and it is inconsistent with the error-propagation pattern already required for this code.

Proposed fix

  • Pre-execution: treat add overflow like “does not fit” (ExceedsGasLimit / mark invalid), do not panic.
  • Post-execution: return PayloadBuilderError on overflow and fail the build cleanly.

No hardfork gate: builder-local error handling only.

Acceptance criteria

  • Both .expect("total gas shouldn't overflow") call sites in payload.rs are removed
  • Overflow / non-fit paths return errors (no panic)
  • cargo test -p arc-execution-payload passes

Activity

  1. crazywriter1 commented on Sep 20, 2026

    @crazywriter1
    ContributorAuthor

    Hello. If this looks useful, could I please be assigned so I can open a PR with Closes: #<this> once you're ready?

    I'd keep the first PR limited to the two payload.rs sites (pre-check → mark invalid / ExceedsGasLimit; post-exec → PayloadBuilderError). Happy to leave the executor path for a separate follow-up if you prefer. @ZhiyuCircle

  2. UzairRehman4 commented on Sep 23, 2026

    @UzairRehman4

    Hi maintainers, I have a fix ready for both .expect("total gas shouldn't overflow") sites described here (pre-execution capacity check treated as "doesn't fit" on overflow, post-execution update returns a PayloadBuilderError instead of panicking), following the acceptance criteria in the issue. Could I be assigned to this issue so I can open a PR per the contributing guidelines? Thanks!

  3. added a commit that references this issue on Sep 23, 2026
    5c046d3
  4. crazywriter1 commented on Sep 28, 2026

    @crazywriter1
    ContributorAuthor

    Requesting assignment to @crazywriter1 for this issue, per CONTRIBUTING.md.

  5. forumevi commented on Oct 27, 2026

    @forumevi

    Requesting assignment per CONTRIBUTING.md.

    I have verified that both .expect("total gas shouldn't overflow") call sites are present on the current main branch:

    • Pre-execution capacity check (loop entry): cumulative_gas_used.checked_add(pool_tx.gas_limit()).expect(...)
    • Post-execution accumulate: cumulative_gas_used.checked_add(gas_used).expect(...)

    Both are in crates/execution-payload/src/payload.rs.

    Proposed fix, limited to the two sites:

    • Pre-execution: replace with a match; treat None as the tx not fitting the block — mark it invalid via ExceedsGasLimit and continue, consistent with the existing capacity-exceeded path above it.
    • Post-execution: replace with a match or ok_or(); treat None as a PayloadBuilderError and return Err, keeping it consistent with the Fatal arm in classify_tx_outcome.

    No hardfork gate needed. Happy to keep this strictly to the two arithmetic sites and leave any refactor for a separate PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions