fix(ckbtc): clear the consolidation request when no transaction is submitted - #11622
Draft
Dfinity-Bjoern wants to merge 1 commit into
Draft
Dfinity-Bjoern wants to merge 1 commit into
Dfinity-Bjoern wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The cleanup logic is consistent across live rollback and event replay, with focused regression coverage.
Pull request overview
Clears orphaned ckBTC UTXO-consolidation requests after signing failures while preserving submitted or stuck transactions.
Changes:
- Detects and clears dangling consolidation requests during rollback and replay.
- Reuses transaction lookup logic for reimbursement checks.
- Adds state-level, replay, and signing-failure tests.
File summaries
| File | Description |
|---|---|
rs/bitcoin/ckbtc/minter/src/tests.rs |
Tests signing-failure rollback. |
rs/bitcoin/ckbtc/minter/src/state/tests.rs |
Tests latch clearing and replay behavior. |
rs/bitcoin/ckbtc/minter/src/state/eventlog.rs |
Clears orphaned requests after replay. |
rs/bitcoin/ckbtc/minter/src/state.rs |
Implements dangling-request detection and cleanup. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…bmitted `consolidate_utxos` records a `CreatedConsolidateUtxosRequest` before it signs the Bitcoin transaction, and `finalize_transaction` was the only place that cleared `current_consolidate_utxos_request` again. Clear it also when no submitted or stuck transaction carries its block index, since such a request can no longer be finalized. Deriving the condition from the state rather than recording a new event keeps replay and the live minter in agreement without changing the event log format. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Dfinity-Bjoern
force-pushed
the
ckbtc-consolidation-hardnening
branch
from
September 18, 2026 21:01
fcf847f to
ce23431
Compare
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.
Change
consolidate_utxosrecords aCreatedConsolidateUtxosRequest, which setscurrent_consolidate_utxos_request, before it signs the Bitcoin transaction.finalize_transactionwas the only place that cleared the field again.This also clears it whenever no submitted or stuck transaction carries its block index, since such a request can no longer be finalized.
The condition is derived from the state rather than recorded as a new event, which avoids an event log format change and keeps replay and the live minter in agreement.
eventlog.rsalready uses replay-time derivation this way fordup_receivedandrejected_sent.Clearing the field only in memory would not be enough: the event stays in the log, so a later request would trip the
assert!inpush_consolidate_utxos_requestduring replay.should_replay_new_request_on_top_of_orphaned_onecovers that case.last_consolidate_utxos_request_time_nsis intentionally left untouched, so the existing 24h interval still applies.Reusing the new
find_unfinalized_transactionalso removes a duplicate scan inschedule_withdrawal_reimbursement.Tests
Five tests, each verified to fail without the change:
should_clear_latch_when_rolling_back_unsubmitted_consolidationshould_keep_latch_while_submitted_transaction_can_still_be_finalizedand thestuckvariantshould_drop_orphaned_request_when_replaying_eventsshould_replay_new_request_on_top_of_orphaned_oneshould_clear_consolidation_latch_when_signing_fails, end to end throughsign_and_submit_requestPossible follow-ups
current_consolidate_utxos_requestis not part ofcheck_semantically_eq, so nothing machine-checks that replay and live state agree on it.resubmit_transactionsreads the field for information the loop variable already carries; removing that reader would makeget_submitted_transactionunused.push_submitted_transactionwould make the invariant structural. Larger change, touches the sharedSentBtcTransactionreplay arm.🤖 Generated with Claude Code