-
Notifications
You must be signed in to change notification settings - Fork 58
fix(platform-wallet-storage): durably apply swept transactions in the SQLite store #4559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f013e0c
fix(platform-wallet-storage): durably apply swept transactions in the…
jeanpierreroma b95a50d
docs(platform-wallet-storage): document V007 and pin the materialised…
jeanpierreroma 0e4685f
fix(platform-wallet-storage): delete a swept loser's InstantSend lock…
jeanpierreroma 27fbd47
fix(platform-wallet-storage): key the sweep hold on the placeholder's…
jeanpierreroma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
53 changes: 53 additions & 0 deletions
53
packages/rs-platform-wallet-storage/migrations/V007__utxo_sweep_winner_height.rs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| //! Anchor sweep tombstones at their winner's mined height and pin the | ||
| //! chainlock finality boundary. | ||
| //! | ||
| //! `core_utxos.winner_mined_height` is the mined height of the | ||
| //! transaction that beat an unmaterialised sweep tombstone's outpoint — | ||
| //! the placeholder row `apply_sweep` writes for a held input whose | ||
| //! funding output has never classified (`height IS NULL AND spent = 1`; | ||
| //! no other writer leaves `height` NULL). The height is carried on the | ||
| //! sweep event itself (`TransactionsSwept::winner_mined_height`), and | ||
| //! `apply_sweep` writes the placeholder for EVERY non-released held | ||
| //! input in EVERY sweep context — only the stamp differs. A | ||
| //! block-context sweep (winner actually mined) stamps the winner's | ||
| //! height, and the collector in `core_state::apply` evicts the row | ||
| //! exactly when `min(chainlock_height, synced_height)` reaches that | ||
| //! height — `prune_finalized_observed_spends`' condition verbatim, with | ||
| //! no observation-age margin. An InstantSend-locked, unmined winner | ||
| //! writes the same row with the stamp NULL — under DIP-10 its lock | ||
| //! alone settles the input, but it carries no height to key a lifetime | ||
| //! on — and the collector never takes an unstamped row: it resolves | ||
| //! only through proof, when the funding upsert materialises it, a later | ||
| //! block-context sweep re-stamps it into the collectible set, or a | ||
| //! release deletes it. See `CORE_SWEEP_REMOVAL` and the `apply_sweep` | ||
| //! doc in `core_state.rs` for why an unstamped hold must survive (it is | ||
| //! the only durable carrier of upstream's in-memory `spent_outpoints` | ||
| //! hold across a restart) and what bounds the foreign-input residue. | ||
| //! | ||
| //! `core_sync_state.chainlock_height` is the monotonic-max height of | ||
| //! the last applied chainlock, mirrored from | ||
| //! `CoreChangeSet::last_applied_chain_lock` (previously dropped by | ||
| //! this store). It is one half of the collector's finality boundary; | ||
| //! rows are never collected before a chainlock has been persisted, | ||
| //! matching upstream's "no-op until a chainlock has been applied". | ||
| //! | ||
| //! The partial index covers exactly the unmaterialised rows — the | ||
| //! collector's scan set is the stamped subset of these — so the | ||
| //! per-round sweep touches tombstones only, not the wallet's full | ||
| //! spent history. | ||
| //! | ||
| //! Version numbers, like capability bits, are append-only: an already- | ||
| //! merged assignment keeps its slot, so an unmerged migration takes the | ||
| //! next free number whenever the mainline lands one ahead of it. Under | ||
| //! the pre-release policy V001's test documents, an unshipped migration | ||
| //! may still be edited in place; a dev database that applied an earlier | ||
| //! shape fails refinery's divergence check and must be recreated. | ||
|
|
||
| pub fn migration() -> String { | ||
| "ALTER TABLE core_utxos ADD COLUMN winner_mined_height INTEGER; | ||
| ALTER TABLE core_sync_state ADD COLUMN chainlock_height INTEGER; | ||
| CREATE INDEX idx_core_utxos_unmaterialized | ||
| ON core_utxos(wallet_id, winner_mined_height) | ||
| WHERE height IS NULL;" | ||
| .to_string() | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.