Skip to content

feat(cketh): add the SweeperFunding withdrawal-request variant [override-didc-check] - #11072

Draft
mbjorkqvist wants to merge 2 commits into
mathias/DEFI-2933-fee-account-burnfrom
mathias/DEFI-2933-sweeper-funding-request
Draft

feat(cketh): add the SweeperFunding withdrawal-request variant [override-didc-check]#11072
mbjorkqvist wants to merge 2 commits into
mathias/DEFI-2933-fee-account-burnfrom
mathias/DEFI-2933-sweeper-funding-request

Conversation

@mbjorkqvist

@mbjorkqvist mbjorkqvist commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Part of DEFI-2933 (sweeper fee funding), third of a seven-PR stack. Targets #11065.

Why

Sweeper fee funding is mechanically an ordinary ckETH withdrawal — same nonce sequence, same threshold-ECDSA signing, same fee-bumped resubmission — so it becomes a third WithdrawalRequest variant rather than a parallel pipeline.

It differs in exactly one respect, and that difference is what the whole feature turns on: the ckETH burned for funding is never re-minted. A funding request must therefore never reach the reimbursement machinery.

What

Three places enforce that, all of which would otherwise fail only at runtime:

  • maybe_reimburse is the double-minting guard, and record_reimbursement_request asserts membership has been cleared before minting. Funding is kept out of the set on insert, and the corresponding assertion on removal is made conditional. Both are production assertions, so a missed branch traps the canister.
  • The conversion to a reimbursement index becomes fallible, deliberately: a fallible conversion makes the compiler prove at every call site that funding cannot produce an index, rather than relying on a panicking arm that traps if a site is missed. The two callers construct their index inside the reimbursable arms instead.
  • A failed funding transaction records nothing to pay back, only a log line. Everything a later funding needs in order to offset against the unspent burn is reconstructible from the accepted-request event plus the finalized transaction's receipt, so no second event type is introduced.

Everything else follows ckETH: the 21'000 gas limit of a plain value transfer to a code-less address, a resubmission strategy ceilinged at the burned amount — so a climbing gas price shrinks the ETH delivered to the sweeper rather than spending more than was burned — and a fee carved out of that same amount, so balance accounting needs no change.

Funding appears in the withdrawal status endpoint, the dashboard and the event log rather than being hidden: it moves ckETH-denominated value and is a public, auditable action. A user query never matches one, since the sender is the minter itself.

Tests pin the difference, including a deliberate contrast test asserting that a failed user withdrawal is still reimbursed — without it, the no-reimbursement tests would also pass if reimbursement were broken for everything. The fee ceiling is asserted through behaviour rather than by inspecting stored state, and the new event tag round-trips as CBOR.

Stack

Merge in order; each PR targets the one above it.

# PR Status
1 #11060 — Read a native ETH balance via the EVM RPC canister Copilot clean, CI green
2 #11065 — Burn ckETH from the minter's own fee subaccount Copilot clean, CI green
3 Add the SweeperFunding withdrawal-request variant this PR
4 Burn-first accounting for sweeper fee funding not yet opened
5 Sweeper fee-funding task, with an end-to-end test not yet opened
6 Sweeper funding observability and the prepaid-gas gate not yet opened
7 Adversarial end-to-end coverage of sweeper fee funding not yet opened

Sweeper fee funding is mechanically an ordinary ckETH withdrawal — same nonce
sequence, same tECDSA signing, same fee-bumped resubmission — so it becomes a
third `WithdrawalRequest` variant rather than a parallel pipeline. It differs in
exactly one respect, and everything here turns on it: the ckETH burned
for funding is NEVER re-minted, so a funding request must never reach the
reimbursement machinery.

Three places enforce that, all of which would otherwise fail only at runtime:

- `maybe_reimburse` is the double-minting guard, and `record_reimbursement_request`
  asserts membership has been cleared before minting. Funding is now kept out of
  the set on insert, and the corresponding `assert!` on removal is conditional.
  Both are production asserts, so a missed branch would trap the canister.
- `From<&WithdrawalRequest> for ReimbursementIndex` becomes `TryFrom` with a
  `NotReimbursable` error, deliberately fallible so the compiler proves at every
  call site that funding cannot produce an index — rather than a panicking arm
  that traps if a site is missed. The two callers construct their index inside
  the reimbursable arms instead.
- A failed funding transaction records nothing to pay back, only a log line.
  Everything a later funding needs in order to offset against the unspent burn is
  already reconstructible from the accepted-request event plus the finalized
  transaction's receipt, so no second event type is introduced.

Everything else follows ckETH: the 21'000 gas limit (a plain value transfer to a
code-less EOA, which cannot revert), `ResubmissionStrategy::ReduceEthAmount` with
the burned amount as the ceiling — so a climbing gas price shrinks the ETH
delivered to the sweeper instead of breaking the invariant — and a fee carved out of the
burned amount so `eth_balance` accounting needs no change.

Funding is reported in `withdrawal_status`, the dashboard and the event log
rather than hidden: it is a public, auditable action. A dedicated dashboard
section with the prepaid-gas balance arrives with the observability work.

Tests pin that difference, including a deliberate contrast test asserting a
failed *user* withdrawal is still reimbursed — without it the no-reimbursement
tests would also pass if reimbursement were broken for everything. The fee
ceiling is asserted through behaviour (a spike past the burn yields
InsufficientTransactionFee) rather than by inspecting the stored strategy, and
the new CBOR event tag round-trips.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the feat label Aug 7, 2026
@mbjorkqvist mbjorkqvist changed the title feat(cketh): add the SweeperFunding withdrawal-request variant feat(cketh): add the SweeperFunding withdrawal-request variant [override-didc-check] Aug 7, 2026
@mbjorkqvist mbjorkqvist added the CI_OVERRIDE_DIDC_CHECK Skips the backwards compatibility didc check (explain in PR description why) label Aug 7, 2026
The Candid file documents no other event variant, and neither do the
corresponding variants in `endpoints.rs` nor the surrounding code in `state.rs`,
`state/audit.rs` and `withdraw.rs`.

What stays is what the surrounding code already does: `event.rs` gives every
variant a one-line doc, and `state/transactions/mod.rs` documents struct fields
one line each, so `SweeperFundingRequest` mirrors `EthWithdrawalRequest`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI_OVERRIDE_DIDC_CHECK Skips the backwards compatibility didc check (explain in PR description why) feat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant