Skip to content

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

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

fix: complete payload builder gas overflow error propagation#135
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 checkcumulative_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 updatechecked_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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants