fix: complete payload builder gas overflow error propagation - #135
Closed
crazywriter1 wants to merge 2 commits into
Closed
crazywriter1 wants to merge 2 commits into
crazywriter1 wants to merge 2 commits into
Conversation
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 This is not a judgement on the change itself. If you'd still like to land it:
Please see CONTRIBUTING.md for details. Thanks again for taking the time to contribute. |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Completes the defensive gas accounting started in #42 (reopen of #24). That PR replaced
saturating_addwithchecked_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.rsPre-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 viaExceedsGasLimit, instead of panicking.Post-execution cumulative update —
checked_add(gas_used)now returnsPayloadBuilderErroron overflow instead of.expect(). A silent clamp or panic would let the builder continue past safe accounting; overflow now fails the build cleanly.Context
saturating_addon the cumulative update was wrongchecked_addbut retained.expect()at both sitesblock_gas_limit~30M vsu64::MAX), butchecked_addwith explicit propagation is the semantically correct primitiveTesting
cargo fmt -p arc-execution-payload -- --checkcargo clippy -p arc-execution-payload --all-targets -- -D warningscargo test -p arc-execution-payload— 25 passed