Skip to content

platform-wallet: release an unconfirmed token pool spend once its token anchor is proven pruned #6155

Open

Description

@QuantumExplorer

Problem

A token pool spend is either a shielded token transfer (type 26) or a token unshield (type 27). Each one keeps its saved recovery record, and its fee notes and token notes reserved, until one of these happens:

  • the credit pool scan sees it land;
  • the credit pool prunes its fee bundle's anchor.

Drive's prune_pool_anchors_v0 always keeps the newest anchor of a pool. So while nobody writes to the credit pool, the fee anchor is never pruned. Meanwhile the token pool can keep moving, for example through identity-funded token shields, and prune the spend's token anchor. Once that happens the spend can never execute, but the wallet still holds both sets of notes and shows the spend as pending.

The first credit pool write by anyone releases the hold: a credit shield, transfer or unshield, or another shielded-fee token transition. After that, the next prune drops the fee anchor and the existing release path runs. So the notes are held, not lost.

Every unconfirmed credit-only spend already waits the same way in an idle credit pool. This only shows up on a network whose only shielded activity is identity-funded token shields, such as a quiet devnet or testnet.

What a fix needs

Release such a spend once its token anchor is proven pruned, at any protocol version:

  1. Keep the token id, the token anchor and the height of the anchor set it was read from in the saved record (PendingRedrive) or on the token note reservation.
  2. Each sync, for pools with live token pool spends, read the token pool's recorded anchor set with a proof.
  3. Treat the anchor as pruned only under the rule the credit pool release uses (PrunedAnchorEvidence::proves_pruned): it is absent from a set proven at a height at or above the one it was read at, and the token scan covers that height.
  4. Then mark the row failed and release both reservations.

Follow-up from the review of #6132.

Activity

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