Registry Mirror
Skip to content

Conversation

@Claudius-Maginificent

@Claudius-Maginificent Claudius-Maginificent commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Basic explanation

TL;DR: Keep one complete wallet history entry when an old withdrawal is delivered again after upgrading.

Value: Upgrades retain one complete history entry and the amounts of transactions spending its outputs.

Risks: Looking up an adopted old identifier returns the current identifier. Withdrawal identity lookups read wallet-scoped evidence once per load, write batch or lookup; no performance benchmark is claimed.

User story

As a wallet user, I want previously recorded withdrawals and their spending history to retain their amounts and details after an upgrade.

Scenario

Base flow

A wallet upgrades an old database and later receives the same withdrawal again.

Actual behavior

The changed transaction identifier can produce two history entries, split ownership details, and leave an older spending entry's amount unrepaired.

Expected behavior

History retains one complete entry and the correct spending amounts. Signed transaction bytes remain unchanged.

Detailed discussion

Issue being fixed or feature implemented

Follow-up to #5150, specifically canonical redelivery of historical AssetUnlock records. Addresses 5150-11, including the duplicate report. It builds on #5781 (merged), the bulk-validation prerequisite. Shared replay in #5220 remains a later integration gate.

What was done?

  • Resolve validated legacy AssetUnlock identities to an active canonical history record. Reconcile existing duplicate records through the same resolver and preserve known ownership details.
  • Keep old physical rows as metadata anchors; use the existing immutable original-record archive only as verified identity evidence. No schema migration, financial outpoint/claim rewrite, or raw signed-prevout change.
  • Repair consumers reached through either historical identity, including when their coin was already stored before the identity relationship became known.
  • Preserve compatible active same-transaction context through the existing wallet helper; reject conflicting confirmed contexts atomically. Archives never grant ownership/finality or resurrect removed history.
  • Keep exact physical backend readers separate from public history projection, and retain Strict/Recovery column-drift behavior and diagnostic counts.

The normal exact-canonical upsert policy is unchanged. No FFI ABI, binding or dependency-pin changes. AssetUnlock alias families are indexed from wallet-scoped history/archive evidence once per load, write batch or outpoint lookup; canonical records without aliases need no further queries. No performance benchmark is claimed. A later #5220 integration must validate physical-record replay against these aliases; it is not part of this PR.

How Has This Been Tested?

  • platform-wallet-storage: 1141 tests passed (nextest, all features) at the current head, including 21 alias cases for migration→redelivery, pre-existing duplicates, multiple quorum instances, accounting repair, context promotion/conflict, rollback/retry, wallet isolation, immutable archives and Recovery behavior, plus query-count tests showing alias projection grows linearly and a write batch scans identity evidence once.
  • New literal fixture from the actual historical writer, with a real known-key P2PKH SIGHASH_ALL consumer. Signature and raw bytes survive migration/redelivery; rewriting its prevout invalidates the signature. This does not claim funding quorum validity or chain inclusion.
  • Clippy (--all-targets --all-features -D warnings) for platform-wallet and platform-wallet-storage and the format check passed.
  • Independent full review of the tree after merging v5.2-dev; its in-scope findings are addressed. No full workspace or network test claim.

Breaking Changes

After canonical adoption, public history lookup by a legacy alias returns the canonical record and identifier. Legacy-only records keep their old identifiers until adoption. WalletStorageError gains HistoryAliasContextConflict; the enum is exhaustive, so downstream exhaustive matches must handle the new variant. No database-schema or FFI-ABI break, and no consensus change.

Checklist:

  • I have performed a self-review of my own code
  • My Rust changes follow the coding conventions
  • I have commented my code, particularly in hard-to-understand areas
  • I have added relevant unit/integration tests
  • I have added "!" to the title and described the API behavior changes
  • I have documented the resolver and public helper contracts in code
  • Independent review of the final parent integration completed
  • I have assigned this pull request to a milestone

No GroveDB structure, system contract schema, or shipped consensus generation changes.

🤖 Co-authored by Claudius the Magnificent AI Agent

@coderabbitai

coderabbitai Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@thepastaclaw

thepastaclaw commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

🕓 Review not started yet because this PR is a draft.

  • Request normal review — click when the PR is ready for review.
  • Request priority review — click to move this review to the front of the queue.

Commit 3ca7b1f. Normal review starts when eligible; priority review starts as soon as a slot is available.

@lklimek lklimek added the priority: low Low priority — nice to have label Nov 6, 2026
@Claudius-Maginificent Claudius-Maginificent added priority: medium Medium priority and removed priority: low Low priority — nice to have labels Nov 6, 2026
Base automatically changed from fix/sqlite-bulk-history-identity to v5.2-dev November 23, 2026 14:42
@github-actions github-actions Bot added this to the v5.2.0 milestone Nov 23, 2026
@Claudius-Maginificent Claudius-Maginificent changed the title fix(wallet-storage)!: reconcile historical AssetUnlock identities fix(wallet-storage): reconcile historical AssetUnlock identities Nov 23, 2026
@lklimek
lklimek changed the base branch from v5.2-dev to fix/funding-issuance-floor-across-reload November 24, 2026 11:38
@lklimek
lklimek added this pull request to stack #6217 November 24, 2026 11:38
@lklimek
lklimek force-pushed the fix/sqlite-asset-unlock-history-aliases branch from d37d1e3 to 8f2e0b5 Compare November 24, 2026 11:57
Preserve the final PR scope, including merge resolutions, on the updated native stack.

Co-Authored-By: Codex <noreply@openai.com>
@lklimek
lklimek force-pushed the fix/sqlite-asset-unlock-history-aliases branch from 8f2e0b5 to 3ca7b1f Compare November 25, 2026 09:19

This branch has not been deployed

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

Labels

priority: medium Medium priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants