Skip to content

platform-wallet: retry shielded activity rows the host failed to store #6157

Open

Description

@QuantumExplorer

Problem

Every shielded activity status change goes through queue_shielded_changeset (rs-platform-wallet/src/wallet/shielded/operations.rs), including the flips to Failed in release_stranded_spends and in the token note sweep. On iOS the host persister writes SwiftData inline and returns Err when the save rolls back, but queue_shielded_changeset only logs that result and drops it. Nothing retries the write.

The Rust activity log is held in memory and rebuilt from the host on restore. So after a restart, a row whose Failed (or Confirmed) write was lost reads Pending again. For a spend that expired, nothing can correct it later: its recovery record and note reservations are already gone, and the chain has no output for the scan to rebuild the row from. No funds are at risk; the label is stale.

What a fix needs

  • Keep unstored activity changesets durable on the Rust side, for example as a small outbox table in the shielded store.
  • Replay them on the next sync pass until the host accepts them.
  • Apply this to every status change in the module, not just one path, so they stay consistent.

Follow-up from the review of #6132.

Activity

  1. QuantumExplorer commented on Nov 23, 2026

    @QuantumExplorer
    MemberAuthor

    Two additions to the scope, from the review of #6151:

    • An exit before the host is called. A status change is saved in the Rust store's memory and added to a pass's changeset, and the host is handed that changeset only when the pass ends. Paths that retire a spend's saved transition first (the note scan failing a spend whose input another transition spent in fix(platform-wallet): fail a pending shielded spend whose note another transition spent #6151, and the anchor expiry release before it) lose the verdict when the process exits in between: the host restores the Pending row with nothing left to derive the failure from. The outbox entry needs to be written in the same store step as the change it carries, before the saved transition is retired.
    • The whole shielded changeset, not only activity rows. A changeset the host fails to store also carries nullifiers_spent. The next pass's changeset advances the host's watermark without those spent marks, so a restart restores the notes as unspent and never rescans the actions that spent them.

    A host that buffers can answer store with Ok before it commits, so the acknowledgement has to be a durable one (WalletPersister::store_durably).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions