Skip to content

fix(mint): clean finalized swap sagas during recovery#2188

Merged
thesimplekid merged 1 commit into
cashubtc:mainfrom
thesimplekid:clean_up_old_saga
Jul 8, 2026
Merged

fix(mint): clean finalized swap sagas during recovery#2188
thesimplekid merged 1 commit into
cashubtc:mainfrom
thesimplekid:clean_up_old_saga

Conversation

@thesimplekid

Copy link
Copy Markdown
Collaborator

Detect swap sagas whose inputs are already spent and whose outputs are signed before running setup compensation. Recovery deletes only the orphaned saga record for those finalized swaps, avoiding repeated startup failures while preserving spent proofs and signed outputs.

Add a regression test that reinserts a completed swap saga and verifies restart cleanup leaves the finalized swap state intact.

Description


Notes to the reviewers


Suggested CHANGELOG Updates

CHANGED

ADDED

REMOVED

FIXED


Checklist

  • I followed the code style guidelines
  • I ran just quick-check before committing
  • If the Wallet API was modified (added/removed/changed), I have reflected those changes in the FFI bindings (crates/cdk-ffi)

@github-project-automation github-project-automation Bot moved this to Backlog in CDK Jul 2, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cbeabf27c9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/cdk/src/mint/start_up_check.rs Outdated
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.45794% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.01%. Comparing base (18d3003) to head (d84ef27).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
crates/cdk/src/mint/start_up_check.rs 93.45% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2188      +/-   ##
==========================================
+ Coverage   72.98%   73.01%   +0.02%     
==========================================
  Files         359      359              
  Lines       79325    79432     +107     
==========================================
+ Hits        57897    57996      +99     
- Misses      21428    21436       +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@thesimplekid thesimplekid added this to the 0.17.3 milestone Jul 3, 2026
@thesimplekid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 002fa7a062

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@thesimplekid

Copy link
Copy Markdown
Collaborator Author

@cdk-bot review

@cdk-bot cdk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified findings approved for disclosure:

  • delete_saga failure can abort swap saga recovery loop (medium) - A transient or persistent delete_saga failure for one already-finalized swap saga aborts startup swap-saga recovery, leaving subsequent incomplete sagas unrecovered on that startup; if the failure persists, sagas behind it can remain stuck indefinitely.
    Additional locations included in summary:
    • crates/cdk/src/mint/start_up_check.rs:249

Comment thread crates/cdk/src/mint/start_up_check.rs Outdated
@thesimplekid

Copy link
Copy Markdown
Collaborator Author

@cdk-bot

Detect swap sagas whose inputs are already spent and whose outputs are signed
before running setup compensation. Recovery deletes only the orphaned saga record
for those finalized swaps, avoiding repeated startup failures while preserving
spent proofs and signed outputs.

Add a regression test that reinserts a completed swap saga and verifies restart
cleanup leaves the finalized swap state intact.
@thesimplekid thesimplekid merged commit d84ef27 into cashubtc:main Jul 8, 2026
11 of 12 checks passed
@thesimplekid thesimplekid deleted the clean_up_old_saga branch July 8, 2026 08:05
@github-project-automation github-project-automation Bot moved this from Backlog to Done in CDK Jul 8, 2026
@cdk-bot

cdk-bot commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Successfully created backport PR for v0.17.x:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants