fix: use checked arithmetic for cumulative gas accounting in payload builder#42
Merged
msheth-circle merged 5 commits intoApr 30, 2026
Merged
Conversation
…builder Use checked_add and saturating_add for cumulative gas tracking to prevent potential u64 overflow, consistent with the defensive arithmetic pattern applied to reward_beneficiary in circlefin#21.
…review Per reviewer feedback, saturating_add silently clamps at u64::MAX which would corrupt cumulative_gas_used rather than fail the block build cleanly. Switch to checked_add with PayloadBuilderError propagation, matching the defensive pattern used at the capacity check on line 579.
Co-authored-by: Milap Sheth <milap.sheth@circle.com>
Co-authored-by: Milap Sheth <milap.sheth@circle.com>
Contributor
Author
|
@msheth-circle Both applied. Ty |
Contributor
|
There is cargo fmt error https://github.com/circlefin/arc-node/actions/runs/25113631746/job/73594638545?pr=42, could you help to fix it ? |
Contributor
Author
|
@ZhiyuCircle Oh sorry, done |
ZhiyuCircle
approved these changes
Apr 29, 2026
msheth-circle
approved these changes
Apr 30, 2026
circle-github-action-bot
added a commit
that referenced
this pull request
Jun 18, 2026
- 13fc332eebbd21a8d26a806ee255a4e3a9cb17c0 test(NoStory): add minor release flow fixture [run releas... by circle-github-action-bot <[internal]> - d1a0ff43724b2efeecaaf506a733ffaebe49e2b6 test(NoStory): add fourth release flow fixture by circle-github-action-bot <[internal]> - 72707fa37e832a7eff798cce0c817ffa433938a0 fix(NoStory): reject empty release tag candidates by circle-github-action-bot <[internal]> - 4cb9de8f292b987b974c17f5ad242c05ae465bd4 chore(NoStory): merge third release backport PR by circle-github-action-bot <[internal]> - 44135e0bc899cd7207860d3ac72f9f1682b03139 test: add second release flow fixture by circle-github-action-bot <[internal]> - fabb6e171b957089ebff80ec621e6e766c0e09aa test: add release flow include fixture by circle-github-action-bot <[internal]> - 413a58e7d308b5b9978d49ad11e79321df93cd7f fix(NoStory): stabilize public release handoff test by circle-github-action-bot <[internal]> - 973161b3843ceb3c2a3580ff802ca3d340642c6c chore(NoStory): prepare public release handoff test by circle-github-action-bot <[internal]> - 8ccd5a28f1b515a554e24944d41eadec3d5fa897 Merge branch 'chore-NoStory-release-workflow-poc-on-1974'... by circle-github-action-bot <[internal]> - a0256dc2954e5c44749c187bb14db63137609c8c chore(NoStory): support namespaced release flow testing by circle-github-action-bot <[internal]> - 60dfbf99f58ce9926f802b490d38caedd56eac21 chore(NoStory): align release export handoff by circle-github-action-bot <[internal]> - 75309ab1da6eca8f8e9f6b687006c74f45b0b718 fix(NoStory): harden release workflow handoff by circle-github-action-bot <[internal]> - f06b514fbf33bc0cb13b93c1a9c202396717f8a5 chore(NoStory): add release workflow handoff poc by circle-github-action-bot <[internal]> - cfd24e8528434c8bf80556413f5c92936fe68204 chore(NoStory): remove release namespace test scaffolding by circle-github-action-bot <[internal]> - e44408bba5345bd83474fa3eb6fa2961a9a7cd3a chore(NoStory): support release workflow test namespaces by circle-github-action-bot <[internal]> - 9f043ebae53aa3632a05565ddffeacde22045a05 chore(NoStory): add private rc release flow by circle-github-action-bot <[internal]> - 6578fbbc5cc9c7cf7b7ea67d3506db9f3821bc4f fix: extend early-revert penalty to auth rev... by circle-github-action-bot <[internal]> - c1f67cdd868b8597a45823bbd0578546173898d8 feat: support `node_size`, `cc_size`, `node_... by circle-github-action-bot <[internal]> - db199c3cc594ede0606f99ce74649e963a08a38c feat: reduce spammer request timeout and imp... by circle-github-action-bot <[internal]> - 6fc528897bfbf01f23740f5a6054324a4257b7cc feat: Quake web topology viewer and controls... by circle-github-action-bot <[internal]> - fa1384e96631935cbd6c54ff44a7c95dac1e222e fix(1766): misc fixes and cleanups around precompiles and... by circle-github-action-bot <[internal]> - 75873fa88c15fe661ce43a5854b41cd695aaec53 chore: update Malachite to `circlefin/malachite@4e8bb7dd`... by circle-github-action-bot <[internal]> - 600be094d415652ab05560b4e2ad47c37bc28557 feat: add nightly engine bench workflow (#18... by circle-github-action-bot <[internal]> - 7a81d835e22d094b35d14934fc7dbe497f865954 fix: route precompile! body reverts through ... by circle-github-action-bot <[internal]> - c3434bb0342f7d380ffb53968c4ad65cfe5faf9f feat: cache gas estimates for ERC-20 and Guz... by circle-github-action-bot <[internal]> - df34c094c48910ace8fac30f938695e7c55281a3 fix: run forge build in quake setup and resp... by circle-github-action-bot <[internal]> - afeb53a9393bad823813aa362d175d46613d3841 chore: bump eaas to v9.11.1 (#1940) by circle-github-action-bot <[internal]> - f343c4865f9290f2299370d1f326e7532bba154b fix: panic on missing subcall continuation i... by circle-github-action-bot <[internal]> - 5aba4f1a9370e1f7efc044818ab6ecbbcd88155a feat: spammer reuse with parallel nonce resy... by circle-github-action-bot <[internal]> - df0acc22a58fd8ff5c72db68b07230d478ea73c9 chore: add code comment clarifying StateChangePostBlock s... by circle-github-action-bot <[internal]> - 2aadb60dbf8f1af438cf553511d1359d75f38704 fix(NoStory): enable pipefail for clippy step so -D warni... by circle-github-action-bot <[internal]> - f907347fbf66224354f0b3ae6daa9ae66bfdca0e chore: import arc-node PR #42: fix: use checked arithmeti... by circle-github-action-bot <[internal]> - beb164a6733cefdbe599df21b7061eac505efd43 feat: split localdev smoke tests with two sc... by circle-github-action-bot <[internal]> - e2bf6a8196b2a2a9f41d59655b9595427368b7b8 feat: add public-tree drift check on main CI... by circle-github-action-bot <[internal]> - 43eea704ba8b4cc2d4ed6e004ee505c627087f55 fix(NoStory): remediate cargo audit advisories (#1898) by circle-github-action-bot <[internal]> - ad53554705af864b573850ec099ee161453421b7 fix: audit fix - remove stateful marco, upda... by circle-github-action-bot <[internal]> - 725e71d61e8b6066278cf577a1702b5cdf8b7b73 feat: remove rewardBeneficiary from Protocol... by circle-github-action-bot <[internal]> - 445d8134130e49e681ab1c65e6d12298c84026cf fix: gate quake CL CLI flags by target image... by circle-github-action-bot <[internal]> - 83889a9cd76d3b9e14436081852d0a668d9f586d feat(CL): Add a db unwind command (#1516) by circle-github-action-bot <[internal]> - 9d74cea6b4e155737e55b5fd06c655f6e33856a6 feat: revert pending-tx default to hidden an... by circle-github-action-bot <[internal]> - a466bb6a4f30f675f8ac6588a9936b1c9b89eedf doc: document EOA-only restriction on Multic... by circle-github-action-bot <[internal]> - 620ce6979975400515c0705e43e865fbfef92d40 fix: Persist engine validity verdict to unde... by circle-github-action-bot <[internal]> - f1a95bfea35aa321e775f5d1d89a2cd000b64c68 fix: check EIP-7702 authorization list autho... by circle-github-action-bot <[internal]> - d98120dad5580b73081708ea1d89498ab63b5077 feat: apply EIP-2929 warm/cold pricing to pr... by circle-github-action-bot <[internal]> - 5cb6adf7d4342f3a654b49ae957090c059867a3b doc: document getGasValues ring-buffer fresh... by circle-github-action-bot <[internal]> - 109ea51c5273ea19e49908e8c53d87f60dd9ed74 refactor: model consensus fork history and na... by circle-github-action-bot <[internal]> - c14b4a468237a9a7c8de34da327c529c7b944c10 fix: lift spammer gas fee caps above testnet... by circle-github-action-bot <[internal]> - b622135690a52021000876bfef1b735486aac9a4 fix(NoStory): fix raw tx encoding, TCP backpressure drain... by circle-github-action-bot <[internal]> - cdba81ee0abc298551dcb860fc8552b0fee1e16e refactor: cosmetic fixes (#1864) by circle-github-action-bot <[internal]> - 6daf89f94f4a9e68ba9ff60b2b095329f7997f06 fix: align totalSupply input validation with... by circle-github-action-bot <[internal]> - b101c7605f202c03f8fe975de84be5eb85375394 test(NoStory): add PQ verification benchmarks (#1852) by circle-github-action-bot <[internal]> - 45d3b3376169580afcdc6a78d48b1eb85e22312d fix(NoStory): kill stale SSM tunnel process on port confl... by circle-github-action-bot <[internal]> - 8b28cfcd742ef60e5eb28512848e99256eb9b3cc chore: drop vestigial beneficiary param and ... by circle-github-action-bot <[internal]> - 3a4e173e6e567e51bb02a2eaffd7b054c7c43a36 test(NoStory): regression test for Prometheus histogram w... by circle-github-action-bot <[internal]> - 964462dafe4cbbb44f2a6a96f4bab4ac585f9309 feat: raise equivocation evidence log levels... by circle-github-action-bot <[internal]> - 4033dc7ace25c370b4aadf99f2caee418e6cec5b chore: import arc-node PR #44: tests: remove duplicate Na... by circle-github-action-bot <[internal]> - 4cad57ad011820a269d7c882094e4ede18a5ea1d chore: import arc-node PR #45: arcup: error when --instal... by circle-github-action-bot <[internal]> - 783387ef87a384c6d986309a6ec1ba7961edcce4 chore: import arc-node PR #47: docs: add single-host moni... by circle-github-action-bot <[internal]> - 391f3332dec78b32229101d1f597ee7c9bdb29bd chore: import arc-node PR #46: refactor(types): share HTT... by circle-github-action-bot <[internal]> - b5f38a110dcba2f7baf70776a61d619d77f66d01 doc(NoStory): update Docker installation instructions (#1... by circle-github-action-bot <[internal]> - 3df766646e40b64490597640decee807a3370f6f feat: add release binaries workflow and arcu... by circle-github-action-bot <[internal]> - e12060a75059eefcb3525a1ce581708bb00cc18c fix: update CL backpressure semantics (#1849) by circle-github-action-bot <[internal]> - 1ead54346685b16f798e5b1917dce309f2698da9 feat: use forge bytecode for genesis contrac... by circle-github-action-bot <[internal]> - cf4f9cc5e7d5bbbedb8e03a0f88c8b355899f5de feat: unconditionally use validator provided beneficiary ... by circle-github-action-bot <[internal]> - 27e0db142093ed3a9ad366bda236af50e0d2da0d feat: post arc-engine-bench report as PR com... by circle-github-action-bot <[internal]> - 6e37777fd23dc50c3571ed9265f99ba5609ab3ad feat: configurable root EBS volume size for ... by circle-github-action-bot <[internal]> - feacfe3623dbb3497b3a1c28d9a218460d46cd68 fix: On restream, look up block by hash and... by circle-github-action-bot <[internal]> - 8da4b7193194748d2c62c0876e40851dac50231a feat: add periodic transaction rebroadcast (... by circle-github-action-bot <[internal]> - 0bc52ca1439339369846a0aa4bfbc24c300fb265 feat: Run mesh, health, performance and sani... by circle-github-action-bot <[internal]> - df698f343631a7ff354a57228fcad08446579f77 ci(TECHOPS-24751): optimize dockerfile layer caching for ... by circle-github-action-bot <[internal]> - 592ad238d21f7e71ec884a68f2e013186181fd56 Concurrency & CPU budget for CI (#1834) by circle-github-action-bot <[internal]> - 6444a4f8742f1a7fdcab23b9b20333f6f81cbced feat: add ProtocolConfig upgrade scripts (#1... by circle-github-action-bot <[internal]> - 56edf733b6540bab535a3c65629bebd9f166372c feat: add EIP-7708 e2e test (#1403) by circle-github-action-bot <[internal]> - 536f5049e27de45f0972eb3d49283aca0a7dabe8 doc: document intentional batch pending-bloc... by circle-github-action-bot <[internal]> - 7bee76474026d731e5ca8e20989ec4fd5102e363 doc: add Docker instructions for running an ... by circle-github-action-bot <[internal]> - 3fee35933ae476f1a3e2a7e772cad112b87b4ffb fix(quake): validate manifest flags against consensus bin... by circle-github-action-bot <[internal]> - da8b943d8be2911e9abdd5e8673d52371b12c922 fix(NoStory): correct Copybara export PR title to 'sync t... by circle-github-action-bot <[internal]> - 7bec5ac59a6a1b36dfb915803f80b21ee2c115c3 feat: require `--suggested-fee-recipient` wh... by circle-github-action-bot <[internal]> - 682a242dd4836336a3216a52a678d332f7ab1a5c refactor: refactor and use `UndecidedBlocksRe... by circle-github-action-bot <[internal]> - ef905ac6bd160878ba71e107b7aeb07b428b685e feat: add --pprof.heap-prof flag to control h... by circle-github-action-bot <[internal]> - 3c57615b6fc5530b60c421f3f0cac418d0791b02 feat: support using node groups in `quake lo... by circle-github-action-bot <[internal]> - b6afef6a16850fdb1b3174403fb4922cf0067710 feat(TECHOPS-23979): add evm-specs-test runner for EEST f... by circle-github-action-bot <[internal]> - e30c97995d5b94b68f1d86d96350c00f7b77a952 fix(NoStory): address post-merge review feedback on Copyb... by circle-github-action-bot <[internal]> - befb3d5970ae11236c727652dfadadf984482eb7 fix: prevent stream eviction by colluding va... by circle-github-action-bot <[internal]> - 4fd7ba1865e74b1042292bde0942c24d9809823e fix(NoStory) use proposer's suggested_fee_recipient when ... by circle-github-action-bot <[internal]> - 11a118226783f0d2aa44b9ac4b45bc5f52c0bd15 fix: fetch validator set at `certificate_hei... by circle-github-action-bot <[internal]> - 11a8e3a25166b3534c344c00d4b07899be337a76 deps(deps): bump thin-vec from 0.2.14 to 0.2.16 (#1746) by circle-github-action-bot <[internal]> - 50417d277768d584f7994afb93d05b09b9865fae feat: add `--validator` configuration flag t... by circle-github-action-bot <[internal]> - bc29861d48aa768a90d959dc70c795d7449e6228 fix: align RemoteSigningProvider Ed25519 ver... by circle-github-action-bot <[internal]> - 4409339661ed58f301248e81352aa1d579d5683a feat: resolve default follow endpoint from c... by circle-github-action-bot <[internal]> - 2a19fe7385a429c94b13fd6c02e167e12e08d319 fix(NoStory): Account for EL earliest block in `GetHistor... by circle-github-action-bot <[internal]> - ecac30fce4934294b587011fa6ad6bdc01494dca chore(NoStory): change CL default `--log-level` from `deb... by circle-github-action-bot <[internal]> - 4393dc14973a7981852f13a0f9a3ac2d318f706a feat: Quake's `remote download` command (#16... by circle-github-action-bot <[internal]> - 81a5e45c21fab22037119846b0b312ee79fcd3eb feat: uniformize address and key rendering t... by circle-github-action-bot <[internal]> - 2b21154e52fae300e1ab0742949bc2aae886ec88 fix: bound repeated proto fields to prevent ... by circle-github-action-bot <[internal]> - 87570120a529bbb3bb1a2e24ee21039fcb44d0c9 fix(NoStory): correct Blockdaemon WSS endpoint and remove... by circle-github-action-bot <[internal]> - d72493dd7a5e6c000649a2ece7b8c7b8991668ae chore: Dockerfile for arc-engine-bench (#1697) by circle-github-action-bot <[internal]> - 637df919468dcb4013805c4a7925de2f80ba89d5 fix: use checked arithmetic in total_voting_... by circle-github-action-bot <[internal]> - 6504622e9fa32633f59f9e5a2a36924bcf332be5 ci: add Copybara export workflow, composite ... by circle-github-action-bot <[internal]> - e6ccd9029877bb939e3f7a7066bd558473b996a0 fix: propagate `pol_round` as `valid_round` ... by circle-github-action-bot <[internal]> (And 243 more changes) GitOrigin-RevId: 13fc332eebbd21a8d26a806ee255a4e3a9cb17c0
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.
Context
Reopen of #24, which was auto-closed after the main branch reset (per @ZhiyuCircle's note on that PR). Rebased onto the new
origin/mainvia cherry-pick since the original base commit no longer exists.Summary
Replaces
saturating_addwith checked arithmetic in two places inpayload.rsso that u64 gas overflows surface as build failures instead of silently clamping:Capacity check (line 578) —
cumulative_gas_used.checked_add(pool_tx.gas_limit()).is_none_or(|total| total > block_gas_limit). Defensive hardening — per @atiwari-circle's review overflow here is not practically reachable (both sides bounded by block_gas_limit ~30M), butchecked_addis the semantically correct primitive.Cumulative update (line 665) —
cumulative_gas_used.checked_add(gas_used).ok_or_else(|| PayloadBuilderError::other(...))?. This was the line called out as incorrect by @atiwari-circle in fix: use checked arithmetic for cumulative gas accounting in payload builder #24: a silent clamp atu64::MAXwould let the payload builder continue past the block gas limit. Overflow is now propagated viaPayloadBuilderError.Links to original discussion: #24