Repository navigation
fix(cketh): provision sweep gas out of the sweeper balance bound - #11342
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates ckETH sweeper funding accounting so in-flight and finalized sweep costs correctly reduce the tracked balance lower bound.
Changes:
- Provision accepted sweeps against the sweeper balance bound.
- Refund unused fees and failed transfer values upon finalization.
- Add lifecycle tests, shared fixtures, and updated documentation.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
rs/ethereum/cketh/minter/src/test_fixtures.rs |
Adds a reusable sweep request fixture. |
rs/ethereum/cketh/minter/src/state/transactions/tests.rs |
Reuses the shared sweep fixture. |
rs/ethereum/cketh/minter/src/state/sweeper_funding/tests.rs |
Tests provisioning, refunds, accounting invariants, and flooring. |
rs/ethereum/cketh/minter/src/state/sweeper_funding.rs |
Tracks provisioned and refunded sweep costs. |
rs/ethereum/cketh/minter/src/state/audit.rs |
Wires accounting into sweep lifecycle events. |
rs/ethereum/cketh/minter/src/state.rs |
Settles sweeper balance accounting at acceptance and finalization. |
rs/ethereum/cketh/docs/deposit_from_cex.md |
Documents the revised lower-bound calculation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
gregorydemay
force-pushed
the
greg/DEFI-2933-provision-sweep-gas
branch
from
August 27, 2026 07:56
63a865b to
928e0c0
Compare
This was referenced Aug 28, 2026
gregorydemay
force-pushed
the
greg/DEFI-2933-provision-sweep-gas
branch
from
August 28, 2026 08:35
0651dfc to
452ee12
Compare
This was referenced Aug 28, 2026
Closed
gregorydemay
changed the base branch from
greg/DEFI-2926-deposit-from-cex-e2e
to
gdemay/DEFI-2926-deposit-from-cex-e2e
August 28, 2026 08:41
mbjorkqvist
approved these changes
Aug 28, 2026
gregorydemay
force-pushed
the
greg/DEFI-2933-provision-sweep-gas
branch
from
August 29, 2026 10:52
542ceb8 to
a124541
Compare
Base automatically changed from
gdemay/DEFI-2926-deposit-from-cex-e2e
to
master
August 31, 2026 10:17
The funding decision reads a lower bound on the sweeper address' balance, tracked from the minter's own events. Nothing debited it, which was true while nothing spent from that address — and the layers below have since landed the pipeline that does. With those in place the bound only ever grows: fundings top the sweeper up once, sweeps spend the gas, and the bound still reports a full sweeper, so `amount_due` declines every later funding. The sweeper drains, sweeping stalls, and every counter says it is funded. An accepted sweep now provisions the most it can cost that address — its fee ceiling, which caps every resubmission the pipeline makes for it — and gets back the fee it did not pay when it finalizes. An ERC-20 sweep moves its tokens through call data and carries no ETH value of its own, so the fee is the whole of what it can cost, and a reverted sweep is charged for its gas like any other. Provisioning at acceptance rather than debiting at spend is what keeps this a bound while sweeps are in flight. Gas a committed sweep will pay stops counting as available immediately, and a sweep whose finalization is never observed leaves the bound too low — which delays a funding — rather than too high, which would let the minter believe in gas that is gone. It is the discipline the withdrawal pipeline already applies to its own fees. The counters are kept out of `cumulative_spent`: this ETH was counted there once already, when the funding that delivered it finalized, and counting it twice would make spend overtake burn and trip the burn-first invariant. The bound floors at zero rather than trapping, since an upgrade that starts the counters from zero — or a sweeper funded before it was tracked — can legitimately leave provisioning above deliveries, and trapping in a state transition would take the replay of every later event with it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YK3ggw1xtE3HZTGGBu66oD
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YK3ggw1xtE3HZTGGBu66oD
…prepaid gas Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YK3ggw1xtE3HZTGGBu66oD
…line Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SJ2pJpCcJWSmYfrhLjmUZ8
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SJ2pJpCcJWSmYfrhLjmUZ8
gregorydemay
force-pushed
the
greg/DEFI-2933-provision-sweep-gas
branch
from
August 31, 2026 10:17
e9dfee9 to
b254286
Compare
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SJ2pJpCcJWSmYfrhLjmUZ8
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SJ2pJpCcJWSmYfrhLjmUZ8
…r it Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SJ2pJpCcJWSmYfrhLjmUZ8
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SJ2pJpCcJWSmYfrhLjmUZ8
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SJ2pJpCcJWSmYfrhLjmUZ8
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SJ2pJpCcJWSmYfrhLjmUZ8
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SJ2pJpCcJWSmYfrhLjmUZ8
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SJ2pJpCcJWSmYfrhLjmUZ8
|
✅ No security or compliance issues detected. Reviewed everything up to 1835071. Security Overview
Detected Code Changes
|
mbjorkqvist
approved these changes
Aug 31, 2026
mbjorkqvist
left a comment
Contributor
There was a problem hiding this comment.
LGTM, thanks @gregorydemay!
mbjorkqvist
added a commit
that referenced
this pull request
Sep 1, 2026
Master's #11342 gives the funding accounting a sweeper balance that sweeps debit; this branch gives it the per-outcome funding counters and the eager burn-first check. Both sides are kept. `record_finalized_funding` keeps the status-aware signature, credits the sweeper balance with what the transfer delivered, and then checks the invariant through `checked_burned_not_yet_spent`. Master's `let _ = burned_not_yet_spent()` would no longer trap there, since this branch makes that getter saturate for the query surfaces. Regenerate the canbench baseline for master's replay changes.
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.
Why
amount_duedeclines fundings the sweeper actually needs, and sweeping stalls while looking healthy.What
EthBalanceinstead of floored at zero: provisioning beyond deliveries is a bug to surface, not a state to tolerate (no deployed minter ever wrote a sweep event, so there is no legacy log to indulge).cumulative_spent— that ETH was counted there when the funding delivered it, and counting it twice would trip the burn-first invariant (R14).This is #11329 (thanks @mbjorkqvist), integrated on top of the sweep stack per the hand-off on DEFI-2933: rebased onto the sweep-queue lifecycle, whose deposit release now lives in the same finalization transition the refund settles in.