Repository navigation
fix(platform-wallet): hold the Clear admission across the remaining shielded pool payments - #6203
Conversation
…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]>
|
Caution Review failedThe pull request is closed.
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. |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
⛔ Final review complete — 1 blocking finding(s) (commit 5533363) · triage: normal · Phase 2 only (queue backlog) |
thepastaclaw
left a comment
There was a problem hiding this comment.
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:
normalbygpt-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— security-auditor (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— security-auditor (completed, effort high); agentphase2-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-walletto coordinate unwatch with unresolved purchases for that token pool.
- Follow-up: Track a follow-up in
- 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-walletbut do not require generic store workers to own coordinator policy.- Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
…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]>
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
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:
normalbygpt-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— security-auditor (completed, effort high); agentphase2-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_lockafter 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.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
…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]>
…et-shielded-payments-hold-clear-admission
…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]>
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
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.
ShieldedNotBoundat once. Before, it went on and failed later, on the empty store.Issue being fixed or feature implemented
Closes #6176.
NetworkShieldedCoordinator::clearexcludes 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, throughPlatformWallet::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, behindsend_private_contact_request,accept_private_contact_requestandaccept_contact_request_replying_in_kindPlatformWallet::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:WalletRemovedBeforeSendif not);ShieldedNotBoundif not).It returns the same
ShieldedSpendAdmissionasadmit_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 takeshielded_config_lockfor the binding check, and these three payments do not.payWhy these three do not take the configuration lock (from review). A bind holds
shielded_config_lockfrom its start to its return and takesshield_guardnext, 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. Onv5.1-devthese 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:register_locked, from feat(platform-wallet): shielded tips to a DashPay username, decided by the wallet #6191). A payment that has reserved its notes and not saved its record yet is not covered: platform-wallet: a bind that drops an account can purge the saved transition of that account's shielded spend in flight #6196.admit_shielded_spendand 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::purchaseand the DashPay send. None takesoperation_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
paycallback 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:pay.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_shieldedtakes them, and only then the shielded store and the wallet manager lock. Against Clear: Clear takes the admission withtry_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 thepay(...)call insend_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
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.Err(PlatformWalletError::ShieldedOperationInProgress), at once, nothing changed.Ok(())once the payment has returned.ShieldedNoUnspentNotes).Err(PlatformWalletError::ShieldedNotBound)before a key or a note is read, untilbind_shieldedruns 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_requestandaccept_contact_request_replying_in_kind(the last three when they pay privately) can now returnPlatformWalletError::ShieldedNotBoundfor a handle whose keys are not installed on the coordinator passed in, or were installed before its last Clear. Before, an unbound handle already gotShieldedNotBoundfrom 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.shielded_config_locknorshield_guard, as before.NetworkShieldedCoordinator::clearandPlatformWalletManager::clear_shieldedreturnShieldedOperationInProgresswhile one of these payments runs.FFI (
rs-platform-wallet-ffi), unchanged code: the exports for these payments already send their errors throughmap_spend_result, which mapsShieldedNotBoundtoErrorWalletOperationandWalletRemovedBeforeSendtoNotFound.platform_wallet_manager_shielded_clearalready returns code 84 for the refusal. Swift and Kotlin need no change.Internal additions:
PlatformWallet::admit_shielded_paymentandPlatformWallet::admit_current_generation(the shared first two steps). Test-only:CapturingPersistenceinwallet/shielded/viewing_key_bind_tests.rsis nowpub(crate), and the private document test fixture gainedwallet_keeping, so tests outside the shielded module can bind a wallet.Not covered here
shield_guardacross its ChainLock wait: platform-wallet: shielded funding holdsshield_guardthrough the unbounded ChainLock wait, blocking other shield-class operations #5518. A bind queued behind it waits holding the gate, the admission and the configuration lock, so a removal waits, a Clear is refused, and an account add, a tip, a token pool transfer or unshield and the seven credit pool spends of that wallet stall. Asset-lock funded shields being excluded from removal: platform-wallet: an asset-lock build is not excluded from wallet removal, so a lock can be broadcast for a wallet that is gone #5516.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()returnsShieldedOperationInProgressat 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_noteshould_refuse_a_clear_while_a_create_holds_a_reserved_noteThrough 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_requestruns 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 realremove_walletis 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_guardis 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_fundingshould_not_hold_a_token_purchase_from_the_pool_behind_a_bind_queued_on_a_fundingshould_not_hold_a_create_behind_a_bind_queued_on_a_fundingRefused after a Clear until bound again:
should_refuse_a_private_contact_request_payment_after_a_clear_until_bound_againshould_refuse_a_token_purchase_from_the_pool_after_a_clear_until_bound_againshould_refuse_a_create_after_a_clear_until_the_wallet_is_bound_againFailures seen:
v5.1-devguard (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 getShieldedNoUnspentNotes(or a token configuration fetch error) whereShieldedNotBoundis expected.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 withv5.1-devmerged 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
accept_private_contact_request,accept_contact_request_replying_in_kind) are covered by the direct payment tests and by reading the code that callspay; 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:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code