Skip to content

fix: complete payload builder gas overflow error propagation - #135

Closed
crazywriter1 wants to merge 2 commits into
circlefin:mainfrom
crazywriter1:fix/payload-gas-overflow-hardening
Closed

crazywriter1 wants to merge 2 commits into
circlefin:mainfrom
crazywriter1:fix/payload-gas-overflow-hardening

Conversation

@crazywriter1

Copy link
Copy Markdown
Contributor

Summary

Completes the defensive gas accounting started in #42 (reopen of #24). That PR replaced saturating_add with checked_add, but left two .expect("total gas shouldn't overflow") calls that could still panic the payload builder. This change applies the error-handling pattern requested by @atiwari-circle in the #24 review.

Changes

crates/execution-payload/src/payload.rs

  1. Pre-execution capacity check — cumulative_gas_used.checked_add(pool_tx.gas_limit()).is_none_or(|total| total > block_gas_limit)
    If addition overflows (not practically reachable — both values are bounded by block_gas_limit), the transaction is treated as not fitting and marked invalid via ExceedsGasLimit, instead of panicking.

  2. Post-execution cumulative update — checked_add(gas_used) now returns PayloadBuilderError on overflow instead of .expect(). A silent clamp or panic would let the builder continue past safe accounting; overflow now fails the build cleanly.

Context

Testing

  • cargo fmt -p arc-execution-payload -- --check
  • cargo clippy -p arc-execution-payload --all-targets -- -D warnings
  • cargo test -p arc-execution-payload — 25 passed

@ZhiyuCircle

Copy link
Copy Markdown
Contributor

Hi @crazywriter1,

Thank you for your interest in contributing to Arc Node, and apologies for the delay in getting back to this PR.

We're closing out the pull request backlog that predates our current contribution policy. This PR is being closed because the number it references is a pull request, not an issue. All PRs must reference an existing issue using the format Closes: #XXX, and the author must be assigned to that issue before the PR is opened.

This is not a judgement on the change itself. If you'd still like to land it:

  1. Open an issue describing the problem, or find the existing one
  2. Comment on the issue requesting assignment, and wait for maintainer approval
  3. Open a fresh PR once you have been assigned

Please see CONTRIBUTING.md for details. Thanks again for taking the time to contribute.

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

Labels

bug Something isn't working EL Component: EL need-triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants