Skip to content

fix(platform-wallet): hold the Clear admission across the remaining shielded pool payments - #6203

Merged
QuantumExplorer merged 5 commits into
v5.1-devfrom
fix/platform-wallet-shielded-payments-hold-clear-admission
Nov 24, 2026
Merged

QuantumExplorer merged 5 commits into
v5.1-devfrom
fix/platform-wallet-shielded-payments-hold-clear-admission

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

What this does. Three kinds of payment out of the shielded pool (buying a token, paying for a DashPay private contact request, creating a private document entry) now register themselves with the shielded coordinator before they start, and stay registered until they finish. The seven credit pool spends already did this. While one is registered, a shielded Clear is refused with the retryable "operation in progress" error instead of running under it. A payment started after a Clear is refused until the wallet's shielded accounts are set up again.

Value. Before this, a Clear tapped while one of the three payments was building its proof or broadcasting went through. It wiped the notes the payment had reserved, its saved retry record and, for a private contact request, the record that stops a second request to the same contact from being paid for. The payment still broadcast, and then wrote its activity and result into the emptied store.

Risks.

  • A Clear tapped during one of these payments now needs a second tap once the payment has finished (a proof takes tens of seconds, then the broadcast and its result).
  • One of the three payments on a wallet that was cleared and not bound again now returns ShieldedNotBound at once. Before, it went on and failed later, on the empty store.
  • Nothing else about how these three payments interleave with a wallet setup (a "bind") changes: they did not wait for one before, and do not now. The seven credit pool spends are not changed at all.
  • No consensus code is touched and no FFI function, result code or signature changes.

Issue being fixed or feature implemented

Closes #6176.

NetworkShieldedCoordinator::clear excludes an operation only if the operation holds the coordinator's operation admission (operation_guard()). #6182 made Clear refuse while an operation holds it, and #6178 made the seven credit pool spends hold it together with the wallet generation's lifecycle gate, through PlatformWallet::admit_shielded_spend. Three payments were left out on purpose and held only the lifecycle gate:

  • PlatformWallet::shielded_token_purchase_from_pool (type 28)
  • PlatformWallet::pay_private_contact_request, behind send_private_contact_request, accept_private_contact_request and accept_contact_request_replying_in_kind
  • PlatformWallet::create_private_document_entry (type 29)

No open pull request or issue other than #6176 covered this.

What was done?

The three payments call a new PlatformWallet::admit_shielded_payment(coordinator) where they used to take the lifecycle gate, and hold what it returns until they return. It takes, in this order:

  1. the wallet generation's lifecycle gate, then checks the handle is still the current generation (WalletRemovedBeforeSend if not);
  2. the coordinator's operation admission;
  3. then checks the handle's keys are the ones installed on this coordinator since its last Clear (ShieldedNotBound if not).

It returns the same ShieldedSpendAdmission as admit_shielded_spend, the helper of the seven credit pool spends, and shares its first two steps with it (admit_current_generation). The one difference is step 3: the credit pool spends take shielded_config_lock for the binding check, and these three payments do not.

Payment Admitted from Held through
Token purchase before the spend key is derived note selection, proof, broadcast, settlement
Private contact request payment when the DashPay send calls pay the journal read, note selection, the journal and transition saves, proof, broadcast, settlement
Private document create after the entry is sealed spend key, note selection, the transition save, proof, broadcast, settlement

Why these three do not take the configuration lock (from review). A bind holds shielded_config_lock from its start to its return and takes shield_guard next, which an asset-lock funding holds across a ChainLock wait with no deadline (#5518). A payment that waited for the lock would wait with the bind, and return neither a result nor an error, though it pays from notes the wallet already has. On v5.1-dev these three payments never took that lock, so waiting there would be new. The lock is not needed for the check to be right: a Clear is what invalidates a binding, and the admission held here keeps it out (the clear generation is bumped only under the admission's exclusive side); a bind only installs a binding, once it has registered the accounts.

What the lock would add is an order, the payment after a bind already in flight. Without it, exactly as on v5.1-dev:

admit_shielded_spend and the seven credit pool spends are unchanged. An earlier commit on this branch removed the lock from that helper as well; it was taken back, because for those spends it widened the first overlap above.

No caller already holds the admission. The callers are the FFI exports, ShieldedTokenPurchaser::purchase and the DashPay send. None takes operation_guard(), and nothing the three payments call takes it or the lifecycle gate a second time.

The private contact request ordering. This payment is the pay callback of the DashPay send, called after the host has signed and sealed the request. I checked what the send holds at that call, on all three entry points:

  • The lifecycle gate: not held. The send takes it only while it settles an unconfirmed public request, and that section has ended. The accept path's reply runs without the gate too.
  • The wallet manager lock: not held. The reservation, the commitment note and the marker store each take and release it before pay.
  • The coordinator's admission, shielded_config_lock, shield_guard, the shielded store: never taken by the send.

So the payment takes the gate and then the admission, in the order bind_shielded takes them, and only then the shielded store and the wallet manager lock. Against Clear: Clear takes the admission with try_write() and never waits, so nothing can queue behind it, and a payment that arrives while a Clear runs waits for that Clear holding only the gate, which Clear does not take. A wallet removal takes the gate before anything else, holding nothing.

The order is written in two places: on pay_private_contact_request (a "Lock ordering" section), and at the pay(...) call in send_reserved_private_contact_request, which says nothing may be held across that call and why.

PlatformWalletError::ShieldedOperationInProgress's doc now lists payments from a shielded pool among the operations that refuse a Clear.

Before / after

// a token purchase, a private contact request payment or a private
// document create is building its proof
coordinator.clear().await
  • Before: Ok(()). The payment's reserved notes, its saved transition and (private contact request) its journal record were purged; the payment then broadcast and settled into the reset store.
  • After: Err(PlatformWalletError::ShieldedOperationInProgress), at once, nothing changed. Ok(()) once the payment has returned.
coordinator.clear().await?;
wallet.create_private_document_entry(&coordinator, seed, 0, &new, &crypto, prover).await
  • Before: the create went on with the keys still on the handle and failed on the reset store (ShieldedNoUnspentNotes).
  • After: Err(PlatformWalletError::ShieldedNotBound) before a key or a note is read, until bind_shielded runs again.

Public interface changes

No signature changes. No new error variant, FFI function or result code.

Behaviour changes on platform_wallet::PlatformWallet:

  • shielded_token_purchase_from_pool, create_private_document_entry, send_private_contact_request, accept_private_contact_request and accept_contact_request_replying_in_kind (the last three when they pay privately) can now return PlatformWalletError::ShieldedNotBound for a handle whose keys are not installed on the coordinator passed in, or were installed before its last Clear. Before, an unbound handle already got ShieldedNotBound from the spend key derivation; a handle bound before a Clear went on and failed on the empty store. For a private contact request the refusal comes before the payment is marked started, so the pair's reservation is released and the send can be made again.
  • These calls take the coordinator's operation admission themselves and hold it until the payment returns. Code that calls them must not already hold the lifecycle gate or the admission. Each method's doc says so. They take neither shielded_config_lock nor shield_guard, as before.
  • NetworkShieldedCoordinator::clear and PlatformWalletManager::clear_shielded return ShieldedOperationInProgress while one of these payments runs.
  • The seven credit pool spends, the token pool transfer and unshield, binds and tips are unchanged.

FFI (rs-platform-wallet-ffi), unchanged code: the exports for these payments already send their errors through map_spend_result, which maps ShieldedNotBound to ErrorWalletOperation and WalletRemovedBeforeSend to NotFound. platform_wallet_manager_shielded_clear already returns code 84 for the refusal. Swift and Kotlin need no change.

Internal additions: PlatformWallet::admit_shielded_payment and PlatformWallet::admit_current_generation (the shared first two steps). Test-only: CapturingPersistence in wallet/shielded/viewing_key_bind_tests.rs is now pub(crate), and the private document test fixture gained wallet_keeping, so tests outside the shielded module can bind a wallet.

Not covered here

How Has This Been Tested?

New tests, each run without the part of the change it covers and seen to fail, then passing with it.

Paused payment, once per kind: the payment is held at the first lock it takes after its admission; while held, the coordinator reports an admitted operation, a real clear() returns ShieldedOperationInProgress at once, the teardown gate cannot be taken and the configuration lock is free; once it returns, the admission is released and a Clear goes through.

  • should_hold_removal_and_refuse_a_clear_until_a_private_contact_request_payment_returns (held at the shielded store)
  • should_hold_removal_and_refuse_a_clear_until_a_token_purchase_from_the_pool_returns (held at the key slot)
  • should_hold_removal_and_refuse_a_clear_until_a_create_returns (private document, sealed for real, held at the key slot)

With a funded note reserved: the payment is handed the store one acquisition at a time until the note is seen reserved; the admission is still held, a Clear is refused and the reservation is untouched; the payment then rolls back and the note is spendable again.

  • should_refuse_a_clear_while_a_private_contact_request_payment_holds_a_reserved_note
  • should_refuse_a_clear_while_a_create_holds_a_reserved_note

Through the real DashPay send, on the manager's own coordinator:

  • should_refuse_a_clear_while_a_private_contact_request_is_paid_for_from_the_pool: PlatformWallet::send_private_contact_request runs its store read, signature, seal and reservation, and its payment is held at the store. Clear is refused and a removal waits. A bind is then polled beside it and a real remove_wallet is polled until it queues on the gate; all three return once the store is released, and the removal has unregistered the wallet from the coordinator.

Not held behind a bind queued on a funding: shield_guard is held as an asset-lock funding holds it, a bind waits on it with the configuration lock in hand, and the payment returns with the guard still held; a removal polled then waits for the bind, and both return once the guard is released.

  • should_not_hold_a_private_contact_request_payment_behind_a_bind_queued_on_a_funding
  • should_not_hold_a_token_purchase_from_the_pool_behind_a_bind_queued_on_a_funding
  • should_not_hold_a_create_behind_a_bind_queued_on_a_funding

Refused after a Clear until bound again:

  • should_refuse_a_private_contact_request_payment_after_a_clear_until_bound_again
  • should_refuse_a_token_purchase_from_the_pool_after_a_clear_until_bound_again
  • should_refuse_a_create_after_a_clear_until_the_wallet_is_bound_again

Failures seen:

  • With the three payments on the v5.1-dev guard (gate only): the three paused tests and the DashPay send test stop with "never admitted"; the two reserved-note tests fail at "still admitted with its note reserved"; the three after-Clear tests get ShieldedNoUnspentNotes (or a token configuration fetch error) where ShieldedNotBound is expected.
  • With the three payments waiting for the configuration lock: the three "not held" tests time out.

Existing tests updated: the two "removal waits" tests of these payments now use a bound wallet, and the two "wallet no longer current" tests assert the re-created, unbound wallet gets ShieldedNotBound. spend_admission_tests.rs (the credit pool spends) is unchanged.

Commands, all with CARGO_INCREMENTAL=0, on the branch with v5.1-dev merged in:

  • cargo test -p platform-wallet --all-features --locked --lib -- private_contact_request_payment_tests private_document_create::tests::create should_refuse_a_clear_while_a_private_contact_request_is_paid_for_from_the_pool spend_admission_tests: 33 passed.
  • cargo test -p platform-wallet --all-features --locked --lib -- shield private_contact private_document token_purchase platform_wallet:: tip: 755 passed, 0 failed.
  • cargo clippy -p platform-wallet --all-targets --all-features --locked -- -D warnings: clean.
  • cargo fmt --all.
  • cargo test -p platform-wallet-ffi --all-features --locked --lib -- private_contact private_document token_purchase shielded_send: 89 passed on the first two commits (crate not changed; a cross-check, not rerun after the merge).

Not yet verified

  • No iOS or Android build, and no device, simulator or emulator run.
  • No test drives a payment through its proof and broadcast with a Clear in flight: the deepest pause is with a funded note reserved, before the proof. That needs a scripted network these unit tests do not have.
  • The token purchase is not paused with a note reserved: it fetches the token's configuration before it reserves, which the unit fixture's mock does not serve. Its deepest pause is the key slot.
  • The two accept paths (accept_private_contact_request, accept_contact_request_replying_in_kind) are covered by the direct payment tests and by reading the code that calls pay; only the send path is driven end to end.

Breaking Changes

None for consensus. Callers of the Rust API see the behaviour changes listed under "Public interface changes".

Checklist:

  • I have performed a self-review of my own code
  • My Rust, FFI, WASM, Swift or Kotlin changes follow the coding conventions
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request
  • If I added or changed a system contract's document schemas, I checked the contract viewer link posted on this pull request

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

…hielded pool payments

A token purchase from the shielded pool (type 28), the payment for a
DashPay private contact request, and a private document create (type 29)
held the wallet generation's lifecycle gate but not the coordinator's
operation admission, so a shielded Clear issued while one of them was
proving or broadcasting ran under it: it could purge the notes the payment
reserved, its saved transition and, for a private contact request, its
journal record, while the payment went on to broadcast and settle into a
store that had been reset.

The three now go through `PlatformWallet::admit_shielded_spend`, as the
seven credit pool spends do: gate, liveness check, admission, then the
configuration lock for the binding check. A Clear issued meanwhile is
refused with `ShieldedOperationInProgress`, and a payment started after a
Clear is refused with `ShieldedNotBound` until the wallet is bound again.

The private contact request payment runs as the `pay` callback of the
DashPay send. The send calls it holding none of the locks it takes, which
is what keeps a bind's order; that is written down at the call site and on
the payment.

Closes #6176

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

  • 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

@github-actions github-actions Bot added this to the v5.1.0 milestone Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Nov 24, 2026
@thepastaclaw

thepastaclaw commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

⛔ Final review complete — 1 blocking finding(s) (commit 5533363) · triage: normal · Phase 2 only (queue backlog)

@thepastaclaw thepastaclaw 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.

Final validation — Phase 2 only (queue backlog)

Changes requested: 1 blocker

  • Shielded payments can hang when a rebind waits for a Core top-up — packages/rs-platform-wallet/src/wallet/platform_wallet.rs:2314-2315 (new)
    Impact: A user with spendable shielded notes who buys a token, pays for a private contact request, or creates a private document during a rebind can get neither a result nor a retryable error if a pending Core top-up never receives its ChainLock.

This PR extends the wallet lifecycle and shielded Clear guards to token purchases, DashPay private contact payments, and private document creation, holding both guards through settlement. The Linux Rust wallet tests, Kotlin SDK emulator build and tests, and Swift SDK build and tests passed in CI.

🔴 1 blocking | 🟡 3 suggestion(s)

Review provenance

Source: reviewer 1: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 8: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — The three payment methods in platform_wallet.rs reuse an unchanged admission guard, altering when a payment can proceed without changing coin selection, transaction construction, or settlement logic.
  • Phase 1 reviewers: not run (skipped for throughput: 12 PRs queued, above the 10 limit)
  • Second Phase-2 pass: on this first full review every Phase-2 reviewer also ran a second, independent time, and the verifier weighed both sets
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/rs-platform-wallet/src/wallet/platform_wallet.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/platform_wallet.rs:2314-2315: Shielded payments can hang when a rebind waits for a Core top-up
  Impact: A user with spendable shielded notes who buys a token, pays for a private contact request, or creates a private document during a rebind can get neither a result nor a retryable error if a pending Core top-up never receives its ChainLock.
  Payments from already-funded notes can now stall before note selection even when Platform is reachable. The new admission calls here and at lines 2837 and 2956 wait for `shielded_config_lock`. An ordinary same-wallet rebind, even with unchanged accounts, holds that lock while waiting for `shield_guard` at line 1369, before it enters the coordinator install transaction. Core asset-lock funding holds `shield_guard` across the ChainLock fallback, and the user-facing FFI passes `None` for the deadline. On the base revision these payments took the lifecycle read guard but did not wait for configuration, so a rebind parked at `shield_guard` did not block them. #5518 tracks the funding-side wait; this PR extends it to these payments. Keep Clear admission through settlement, but bound the configuration wait and return a retryable pre-send error on contention, or avoid holding the configuration lock while the bind waits on funding. Test the payment with the simulated funding guard left held.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/platform_wallet.rs:5326-5349: The Clear tests can pass if admission ends before notes are reserved
  Impact: A later refactor could let Clear erase a payment's reservations or recovery record during proof or settlement without failing these tests.
  These tests verify that Clear refuses at the first key or journal access and succeeds after the payment returns, but do not check the interval in which payment state is at risk. Releasing admission just after that first access would still satisfy both assertions. Drive a wallet payment to a controlled pause after a funded note is observably reserved, assert that Clear refuses, then let the payment settle and assert that Clear succeeds. The private-document rollback test in `operations.rs` demonstrates how to observe a reservation and pause rollback without a real proof or network call.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/platform_wallet.rs:5484-5505: The bind and removal tests can pass without queuing removal behind the payment
  Impact: On a loaded runner, the tests can miss a lock-order regression or fail because removal ran before the payment acquired its lifecycle guard.
  The tests observe that bind holds the configuration lock, but a sleep and an unfinished task do not prove that payment holds the lifecycle read guard or that removal is queued for the write guard. If removal has not been polled before `single_flight` is released, a second read can succeed instead of encountering the queued writer the test is meant to exercise. If payment has not been polled, removal can get ahead of it. The DashPay send test similarly uses elapsed time to order its spawned bind and removal. Poll pinned futures to the intended wait points, as `should_hold_a_removal_until_a_bind_in_flight_returns` does for teardown, or signal those points explicitly. Use timeouts only to bound failures.

In `packages/rs-platform-wallet/src/wallet/identity/network/private_contact_requests.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/private_contact_requests.rs:9349-9354: The DashPay removal test skips shielded teardown on the payment's coordinator
  Impact: The regression test can pass even if production removal hangs during shielded unregistration or leaves the deleted wallet registered for sync.
  The test exercises the generation gate but not the coordinator teardown that follows it. `wallet_on` leaves the manager's coordinator slot empty, and this separately constructed coordinator is used only by bind, send, and Clear. `remove_wallet_with_teardown` therefore skips `unregister_wallet` at `wallet_lifecycle.rs:996–998`, and the final Clear wipes the registration without verifying that removal did so. Configure the temporary store through the fixture manager, use its coordinator for bind and send, and assert that removal unregisters the wallet before the final Clear.
Out-of-scope follow-up suggestions (3)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Dropping a shielded account during payment can erase its recovery record — Bind and payment hold compatible admissions, and the binding check releases the configuration lock before settlement. A bind that drops the paying account can still purge its saved transition while the result is unknown. This overlap also existed on the base revision.
    • Follow-up: Cover the three payment paths in #6196 and prevent account-dropping binds from removing unresolved spend records.
  • Unwatching a token pool during purchase can leave the bought tokens unscanned — The manager records the watch before paying, but unwatch only checks for reserved notes in the token pool. A purchase reserves credit-pool notes, so concurrent unwatch can remove the subscription and the bought tokens will not be discovered until the pool is watched again. This ordering predates the PR, and #6177 tracks Swift operation admission rather than this Rust-side race.
    • Follow-up: Track a follow-up in rs-platform-wallet to coordinate unwatch with unresolved purchases for that token pool.
  • Clear can still erase a token purchase's recovery state when Rust callers use the public pool operation directly — Out of scope as a blocker: the generic worker and the coordinator's raw store accessor are unchanged, and the accessor is documented for tests and migration scaffolding. The only production call to the worker in this repository is the admitted wallet method, which covers the wallet path named in #6176. Deliberately composing the worker with the raw store bypasses that orchestration on both revisions; the book's layer-ownership rules place the policy in rs-platform-wallet but do not require generic store workers to own coordinator policy.
    • Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.

@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 24, 2026
…on lock

`admit_shielded_spend` took `shielded_config_lock` to check the binding and
released it at once. A bind holds that lock from its start to its return,
and takes `shield_guard` next, which an asset-lock funding holds across a
ChainLock wait with no deadline. A spend from notes the wallet already had
then waited with the bind and returned neither a result nor an error. The
three payments this branch admits did not wait there on v5.1-dev.

The lock gave the check nothing: a Clear is what invalidates a binding and
the admission keeps it out, and a bind only installs one, after it has
registered the accounts. The binding is now read without it, for the three
payments and for the seven credit pool spends, which also stop waiting
behind a token pool transfer's settlement.

Tests: a payment of each kind and the four credit pool spends that do not
queue return while a bind waits behind a held funding guard; an unbound
wallet is refused while the configuration lock is held; a private contact
request payment and a private document create still refuse a Clear with a
funded note reserved. The shield sweep pauses at the admission instead of
the configuration lock, and the fixtures use the manager's own coordinator
so a removal unregisters the wallet.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 24, 2026

@thepastaclaw thepastaclaw 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.

Re-review — Final validation — Phase 2 only (queue backlog)

Changes requested: 1 blocker

  • A rebind can delete the recovery record of a transfer that starts after it — packages/rs-platform-wallet/src/wallet/platform_wallet.rs:1810-1814 (new)
    Impact: A wallet user who sends from a funded account while a rebind is waiting to drop it can get an unconfirmed payment that the wallet can no longer retry with the original signed bytes.

New on this head: This revision removes the configuration-lock wait from shielded spend admission while retaining wallet-removal and Clear protection through settlement. It also adds reservation-stage Clear coverage and exercises coordinator teardown through the real wallet-removal path. The Linux Rust wallet tests and Kotlin emulator build and tests passed; the Swift SDK build and tests were pending at the time of review.

🔴 1 blocking | 🟡 1 suggestion(s)

Review provenance

Source: reviewer 1: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — The diff changes lock ordering and when shielded spends may proceed, but leaves coin selection, key derivation, proof construction, and payment execution unchanged.
  • Phase 1 reviewers: not run (skipped for throughput: 11 PRs queued, above the 10 limit)
  • New since the last final review (d953a139): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/rs-platform-wallet/src/wallet/platform_wallet.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/platform_wallet.rs:1810-1814: A rebind can delete the recovery record of a transfer that starts after it
  Impact: A wallet user who sends from a funded account while a rebind is waiting to drop it can get an unconfirmed payment that the wallet can no longer retry with the original signed bytes.
  The wallet can permanently lose the signed transition needed to retry an unconfirmed transfer. A host with funded accounts `[0, 1]` can start `bind_shielded` with `[0]` while a Core top-up on the same wallet holds `shield_guard`. The rebind holds `shielded_config_lock` but has not yet replaced the account map. A subsequent `shielded_transfer_to` from account 1 used to wait for that configuration lock and then reject the removed account. It now passes the coordinator and Clear-generation check, derives the still-installed key, reserves notes, and saves the signed transition before broadcasting. If the top-up finishes while the transfer awaits its result, `register_locked` skips the recovery record because it has spend nullifiers (`coordinator.rs:972–979`), then `purge_subwallet` deletes the SQLite row and the in-memory reservation (`file_store.rs:1778–1806`). A failed result wait still returns `ShieldedSpendUnconfirmed`, but rebinding account 1 cannot recover the deleted bytes. Make account removal mutually exclusive with spend admission for that account and refuse to purge unresolved spends, without making unchanged or additive binds block payments.

  _Confirmed by an independent pass: A host with shielded accounts 0 and 1 bound and spendable notes in account 1 can call `bind_shielded` with `[0]` during a Core asset-lock top-up, then start `shielded_transfer_to` from account 1 while the rebind waits on `shield_guard`. The transfer can use the still-installed key and save its signed transition before broadcasting; if the top-up finishes during the result wait, the rebind deletes the SQLite recovery row and the in-memory note reservation. If the wait then times out, the caller receives `ShieldedSpendUnconfirmed`, but rebinding account 1 cannot restore the signed bytes the wallet needs to retry that exact payment._
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/platform_wallet.rs:1810-1814: A transfer can report no spendable notes while the first bind is restoring them
  Impact: An SDK caller sending from a funded wallet during startup can receive `ShieldedNoUnspentNotes` even though the saved notes become available once binding finishes.
  A transfer can fail before broadcast because it reads an empty in-memory store, not because the account has no funds. The first bind records the coordinator at lines 1430–1436 and publishes the keys at line 1438, before restoring the persisted notes at line 1484. The old configuration lock ordered the transfer behind that restore. With that lock gone, a transfer that gets the store lock first passes admission and key derivation, then selects from the not-yet-restored store. Keep the early coordinator record so a cancelled bind cannot leave an untracked registration, but distinguish it from spend readiness and return a retryable setup error for accounts still being restored. Already-ready accounts need not wait for a routine rebind.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • An account-removing rebind can also delete the record of a transfer that started first — The base revision releases shielded_config_lock after checking the binding, before the transfer settles. A later rebind can therefore delete an already-running transfer's recovery record. This is the pre-existing ordering, distinct from the bind-first regression above.
    • Follow-up: Continue tracking the spend-first case in #6196 and cover it in the follow-up if the fix here only closes the bind-first window.

@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 24, 2026
QuantumExplorer and others added 3 commits November 24, 2026 11:15
…spends' admission

The previous commit removed `shielded_config_lock` from
`admit_shielded_spend` for all ten spends. For the seven credit pool
spends that widened a window that exists on v5.1-dev: a bind that drops an
account and waits its turn no longer held back a transfer from that
account that started after it, and the bind could then purge the
transfer's saved transition (#6196).

`admit_shielded_spend` is back to what #6178 merged, with its tests. The
three payments this branch admits use `admit_shielded_payment`, which
reads the binding without the lock: they never waited for a bind on
v5.1-dev, so they neither hang behind one queued on an asset-lock funding
nor gain or lose anything against #6196.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…es on

After the merge of v5.1-dev the install refuses to drop an account with an
unresolved spend record, or keeps its store state, so the note on
`admit_shielded_payment` no longer says a bind can purge a saved
transition.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 24, 2026
@QuantumExplorer
QuantumExplorer merged commit 53f46b5 into v5.1-dev Nov 24, 2026
23 of 25 checks passed
@QuantumExplorer
QuantumExplorer deleted the fix/platform-wallet-shielded-payments-hold-clear-admission branch November 24, 2026 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-bots Waiting for the review bots to report on this head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

platform-wallet: token purchase, private contact request and private document payments do not hold the shielded coordinator's operation admission

2 participants