Repository navigation
fix(platform-wallet): fail a pending shielded spend whose note another transition spent - #6151
Conversation
…r transition spent A shielded spend whose result the wallet could not confirm stays pending, with its notes reserved and its signed transition saved. When another transition spent one of its inputs first (a second device restored from the same seed), the spend could never execute, but its row stayed pending: for good with one input or after a restart, and until its anchor expired otherwise. The note scan now tells the two cases apart from the action it reads for the spent input. An executed action leaves one proved note item holding its nullifier and its output commitment together, and the saved transition says which commitment its own action pairs with each input. An item carrying an input's nullifier with another commitment is another transition's action: Platform records a nullifier once, so the saved transition did not execute and never can. Its row is failed and its other notes are freed in the same pass. The spend's own action changes nothing: the row is confirmed once the scan reads its change, as before. Nothing is inferred from what the scan has not seen. Closes #6108 Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 31 minutes. View limit details
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 — no blockers (commit 8c3deea) · 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: 4 blockers
- An interrupted sync can leave a displaced spend Pending after restart —
packages/rs-platform-wallet/src/wallet/shielded/sync.rs:855-868(new)
Impact: A user whose second device spent the same note can reopen the wallet to a permanently Pending payment if the app exits before the host saves the scan result. - A scan can return an already-spent note to the spendable balance —
packages/rs-platform-wallet/src/wallet/shielded/sync.rs:1101-1108(new)
Impact: When a second device spends several of the same notes across a scan-range boundary, the first device can count a spent note as available and select it for another payment. - A protocol-14 purchase can show Failed even though the tokens arrived —
packages/rs-platform-wallet/src/wallet/shielded/sync.rs:1051-1069(new)
Impact: A protocol-14 buyer whose token bundle settles with a different fee bundle can see Failed when the original fee note is spent elsewhere and pay for the purchase again. - A delayed result can show Confirmed after the scan proves a payment failed —
packages/rs-platform-wallet/src/wallet/shielded/sync.rs:1124-1135(new)
Impact: A user whose second device spends the same notes can see a displaced identity top-up or private document payment reported as confirmed.
This PR compares proof-authenticated shielded note actions with saved spends so the wallet can identify a competing spend without querying a node for wallet-specific nullifiers. Rust workspace tests and the Swift and Kotlin SDK checks passed; the dedicated Rust wallet job was skipped, and PR Hygiene and automated review were pending. This was a static review; the two-device scenario was not run.
🔴 4 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); 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 change adds a proof-based failure rule and releases wallet-local note reservations across sync and restart, but does not change coin selection, transaction execution, or proof verification. - Phase 1 reviewers: not run (skipped for throughput: 34 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/shielded/sync.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/sync.rs:855-868: An interrupted sync can leave a displaced spend Pending after restart
Impact: A user whose second device spent the same note can reopen the wallet to a permanently Pending payment if the app exits before the host saves the scan result.
The wallet can lose a failure it has already proved. `apply_scanned_nullifier_spends` calls the file store's `mark_spent`, which deletes the SQLite recovery record (`file_store.rs:1044–1069`); the new helper also explicitly clears the record. The Failed row is only saved in memory and added to the changeset. The coordinator still has network work to do before handing that changeset to the host (`coordinator.rs:1756–1766, 1827–1848`), and a host write error is logged without retaining the update for retry. Either interruption can restore the old Pending row with no saved transition to compare on rescan. For a single-input spend there is no remaining reservation for expiry to resolve. Persist a replayable, non-broadcastable failure before or atomically with retiring the recovery record, and keep it until the host durably saves the status. The existing reopen test checks that the record is gone, not that Failed survives when the host still has Pending. Test reopening with that old host snapshot and a failed first write. #6157 tracks the general write-retry problem; an app exit can lose this verdict before the host is called at all.
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/sync.rs:1101-1108: A scan can return an already-spent note to the spendable balance
Impact: When a second device spends several of the same notes across a scan-range boundary, the first device can count a spent note as available and select it for another payment.
A proved conflict rules out the saved transition, but it does not prove that the other inputs are unspent. The SDK fetches ranges independently: if the competing spend straddles a boundary, the first range can include its first action at height H while the next range returns a valid empty proof at H−1. The scan then marks only the input it saw and this loop releases the other reservation. The balance and selector immediately treat that note as available, and the builder can still use an older recorded anchor that contains it. No watermark gap is needed, so #6109 does not cover this case. Separate failing the transition from releasing its other inputs: retain those holds until verified contiguous coverage reaches the conflict proof's height, or equivalent proof establishes that the inputs remain unspent. Add a regression with a fresh first range and a stale empty tail.
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/sync.rs:1051-1069: A protocol-14 purchase can show Failed even though the tokens arrived
Impact: A protocol-14 buyer whose token bundle settles with a different fee bundle can see Failed when the original fee note is spent elsewhere and pay for the purchase again.
The scan can rule out the saved credit fee bundle without ruling out the purchase. For type 28, `shielded_actions` returns only `fee_actions()`. The existing protocol-14 Drive-ABCI test `test_a_purchase_from_shielded_pool_copy_sequenced_first_does_not_charge_the_original_payer` shows that the token bundle can mint the tokens with a different fee bundle while leaving the original fee note unspent. If a second device later spends that note, this scan reports Failed; the landed purchase never creates the original credit change that would correct the row. Protocol 15 binds the bundles, but the current network version does not establish which signing rules a saved purchase used before an upgrade. Retire the unusable fee spend separately from the purchase verdict. Leave the purchase unresolved unless the saved bundle is known to be bound or token-side proof settles it. Cover both cases with actual serialized type-28 transitions: the current split-scan fixture uses a purchase row but serializes a shielded transfer.
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/sync.rs:1124-1135: A delayed result can show Confirmed after the scan proves a payment failed
Impact: A user whose second device spends the same notes can see a displaced identity top-up or private document payment reported as confirmed.
The row can show Confirmed even though the wallet has stronger proof that the payment did not execute. The recovery record is armed before dispatch, so the scan can save Failed while the result wait is outstanding. When all action nullifiers are consumed, as in a two-input bundle with no padding, an affected-state reply from an untrusted DAPI endpoint can pass verification without attributing the spend. The top-up verifier checks spent nullifiers and the target identity snapshot; the private document verifier checks spent nullifiers, not the document. Yet both success handlers write `Confirmed` without a height (`operations.rs:1677–1690, 2548–2561`), and `record_activity_status` only protects Confirmed rows with a height. If the snapshot writes first while the recovery record is still present, this scan instead skips the heightless Confirmed row. Keep affected-state replies as snapshots and make activity settlement and publication respect the stronger scan evidence in both orderings.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/sync.rs:1124-1135: A failed private request payment still blocks sends to the same contact
Impact: A DashPay user can see a displaced private request payment marked Failed while the wallet still refuses public and private requests to that contact.
The activity row now reports a definite failure, but the contact-send gate still sees an unresolved payment. The durable private payment journal is separate from the recovery record this scan clears, and both contact send paths check the journal independently of activity status. The coordinator's negative journal resolver only checks for a missing private entry after it proves anchor expiry (`coordinator.rs:2193–2255`). Pass the proved conflict and its height to the journal resolver so it can use the existing verified private-entry read without waiting for expiry. Do not clear the pair from the Failed row alone: a landed entry still needs read-back reconciliation.
Out-of-scope follow-up suggestions (2)
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.
- A spend can be armed after sync has already marked a selected input spent — While the wallet builds a proof, sync can mark an input spent and remove its reservation before a recovery record exists. The unchanged arming path treats missing reservation metadata as a no-op and can still save and broadcast the stale spend; if the scan finished that chunk, the new comparison may never see the conflict. This precedes the saved-spend reconciliation added here.
- Follow-up: In a separate wallet PR, check that every input is unspent and still reserved by this attempt under the same guard that durably arms the transition.
- Separately proved note ranges can leave a gap in the local commitment tree — A short earlier range followed by a non-empty later range can append commitments at shifted positions and advance the watermark past missing notes. This predates the PR and does not invalidate an authenticated nullifier–commitment pair.
- Follow-up: Fix contiguous-range handling in the follow-up tracked by #6109.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
… has its row Two review findings on the scan's handling of a pending shielded spend whose input another transition spent. The scan dropped the spend's saved transition when it failed the row, but the host learns of the failure only when the pass ends. A process that exited in between restored the pending row with nothing left to compare the rescanned action against. The transition is now kept, parked with its re-broadcasts used up, until the host has stored the pass's changeset; a scan after a restart fails the row again from it, and a later pass that reads the action again hands the host the failed row again. The spend's other notes were released as soon as the row failed. The competing transition may have spent them too, in actions of a range proved before it executed. They are now released only once the pass's scan covers the height that proved the other action, and otherwise stay reserved until the spend's anchor expires, as before. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (queue backlog)
Changes requested: 4 blockers
- Retrying a Failed row can leave its spent note available after restart —
packages/rs-platform-wallet/src/wallet/shielded/sync.rs:1188-1189(new)
Impact: After a transient host save failure, a user can reopen to a correctly Failed payment whose consumed input is still counted as spendable. - A scan can return an already-spent note to the spendable balance —
packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs:2225-2227(carried)
Impact: A user who reopens the wallet after a split-range scan can see a note already spent on another device counted as available before the next sync. - An interrupted sync can leave a displaced spend Pending after restart —
packages/rs-platform-wallet/src/wallet/shielded/sync.rs:1161-1167(thread, carried)
Impact: A user whose other device spent the only input of a pending payment can reopen to a permanently Pending row if the app exits before the failure is durable. - A protocol-14 purchase can show Failed even though the tokens arrived —
packages/rs-platform-wallet/src/wallet/shielded/sync.rs:1175-1178(thread, carried)
Impact: A protocol-14 buyer whose token bundle landed with another payer can see Failed after spending the original fee note on another device and buy the tokens again.
New on this head: This revision keeps conflicting spends’ remaining inputs reserved until the scan reaches the conflict proof’s height, and parks the saved transition so a later scan can replay the Failed row. The Swift schema check and RS-DAPI image build passed; Rust workspace tests, Kotlin emulator tests, and other build jobs were still pending, with no failed code checks reported.
🔴 4 blocking | 🟡 1 suggestion(s)
Still open from earlier rounds (2)
- 🔴 Blocking: An interrupted sync can leave a displaced spend Pending after restart —
packages/rs-platform-wallet/src/wallet/shielded/sync.rs:1161-1167(thread) - 🔴 Blocking: A protocol-14 purchase can show Failed even though the tokens arrived —
packages/rs-platform-wallet/src/wallet/shielded/sync.rs:1175-1178(thread)
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) —sync.rs::fail_spends_spent_elsewherechanges which shielded notes are eligible for future coin selection by releasing reservations based on proved actions and scan coverage, with coordinated changes to rebroadcast and restart handling. - Phase 1 reviewers: not run (skipped for throughput: 21 PRs queued, above the 10 limit)
- New since the last final review (
65c174b8): 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-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— 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/shielded/coordinator.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs:2225-2227: A scan can return an already-spent note to the spendable balance
Impact: A user who reopens the wallet after a split-range scan can see a note already spent on another device counted as available before the next sync.
The new height check protects the second input only while the wallet stays open. When a competing spend crosses a range boundary and the tail proof predates it, the host can durably commit Failed and the first input’s spent mark while still holding the second input as unspent. `retire_failed_spends` deletes the record that backs the second input’s reservation without checking coverage. On reopen, `rehydrate_pending_spends` has no record to restore that hold, and `local_balance_snapshot` counts the host’s unspent note. Persist unresolved holds and their required proof height independently of the activity acknowledgement. Simply skipping retirement is not enough: `restore_locked` also calls `mark_spent` for the first input, which can delete a redrive containing both inputs. Extend the stale-tail test through host commit, retirement, reopen, and a local balance read before the catch-up pass.
In `packages/rs-platform-wallet/src/wallet/shielded/sync.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/sync.rs:1188-1189: Retrying a Failed row can leave its spent note available after restart
Impact: After a transient host save failure, a user can reopen to a correctly Failed payment whose consumed input is still counted as spendable.
The new retry can durably commit the Failed row without committing the spent mark that went missing with it. If a SwiftData save rolls back the first scan changeset, the host still has the previously received note as unspent, but Rust has already marked it spent. A later sync can reread the competing action when it rewinds to the start of the current partial chunk. `mark_spent` then returns false, so `sync.rs:985–988` omits the nullifier, while this branch re-emits Failed. The host can commit Failed and the watermark and the coordinator can retire the parked record. SwiftData updates the note from `nullifiers_spent`, not from the activity row, so the next cold restore counts the old unspent note with no reservation. Keep and replay the proved spent-note delta with the Failed row until both are durably acknowledged. Extend the replay test to apply only the retry to the pre-scan host snapshot and check the balance after reopen.
_Confirmed by an independent pass: When a Swift wallet syncs after another device using the same seed spends a note reserved by its pending transfer, a transient SwiftData save failure can roll back the host changeset while Rust keeps the note marked spent. If the next sync rereads the competing action from the partial chunk, the new retry can persist the Failed row and scan watermark without the spent mark, then delete the parked recovery record. On relaunch the wallet counts the already-spent note as spendable; if the retry advanced the watermark into the next chunk, subsequent scans skip the action that would correct it._
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/sync.rs:195-200: Existing Rust struct literals for the sync result no longer compile
Impact: Rust callers that construct or exhaustively destructure `MultiSyncNotesResult` must update their code despite the PR’s no-public-interface-change claim.
`wallet::shielded::sync::MultiSyncNotesResult` is public and was not `#[non_exhaustive]`, so adding a required field breaks complete literals and patterns. Both the scan producer and the retirement consumer are internal. Keep the retirement metadata in a private scan outcome, or document the source incompatibility if the public shape change is intentional.
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/sync.rs:1161-1167: An interrupted sync can leave a displaced spend Pending after restart
(carried; thread: https://github.com/dashpay/platform/pull/6151#discussion_r4669610235)
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/sync.rs:1175-1178: A protocol-14 purchase can show Failed even though the tokens arrived
(carried; thread: https://github.com/dashpay/platform/pull/6151#discussion_r4669610264)
…pend The previous commit kept the saved transition of a spend the scan failed, parked, until the host accepted the pass's changeset, and handed the host the failed row again on a later pass. Review showed that does not give the guarantee it was for: the record is deleted and saved again in two writes, the host accepting a changeset is not a commit, and the row handed over again travels without the spent mark a failed save lost. Delivering a status change to the host durably is one mechanism for every status change, tracked in #6157, not a second one here. The scan again drops the transition when it fails the row, as the anchor expiry release does. The release of the spend's other notes stays gated on the pass covering the height that proved the other action. The public field added to MultiSyncNotesResult is gone. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (queue backlog)
Nothing blocks: no blocking finding stands on this head.
Not counted: 1 disputed blocking finding(s) left to maintainers.
New on this head: This revision removes the parked-transition replay and host-triggered retirement paths, restores the original public sync result shape, and keeps the proof-height check before releasing the failed spend’s other notes. The static review found no failed code checks on this head; the Kotlin SDK emulator build and tests and PR Hygiene were still pending.
🟡 1 suggestion(s)
Disputed — left to maintainers (1)
- 🔴 Blocking: A protocol-14 purchase can show Failed even though the tokens arrived —
packages/rs-platform-wallet/src/wallet/shielded/sync.rs:1051-1069(thread)
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 change adds nontrivial wallet reconciliation logic for failing pending spends and releasing reservations, but it does not change how inputs are selected, transactions move funds, or proofs are verified. - Phase 1 reviewers: not run (skipped for throughput: 15 PRs queued, above the 10 limit)
- 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/shielded/sync.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/sync.rs:1123-1130: Conflict tests miss restored spends whose input note is absent
Impact: The tests would still pass if a restored wallet kept retrying a saved transition after the scan proved it could not execute.
The new explicit `clear_redrive` call has no test that would fail if it were removed. The current fixtures save or restore the conflicting input note, so `mark_spent` already deletes the record. The file store can rehydrate the saved transition independently of the host notes, and `mark_spent` returns without deleting it when that input is absent from the note index. Add a reopen test that restores the Pending row but not the conflicting input, then feeds a proved conflict above the pass’s coverage height so reservation cleanup cannot delete the record either. Assert that the scan reports Failed and that a second reopen finds no saved transition.
Not approved: 1 blocking finding(s) are disputed and left to the maintainers.
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
…tore does not hold The scan drops the saved transition of a spend it fails explicitly, because the spent mark drops it only with a note the store holds. No test failed without that call. This one restores the saved transition and the pending row without the note, on a pass short of coverage, and checks that the row fails and that no transition is restored after another reopen. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
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)
Nothing blocks: no blocking finding stands on this head.
Not counted: 1 disputed blocking finding(s) left to maintainers.
New on this head: The latest commit adds a regression test that reopens the shielded store without restoring the spent input note and verifies that the scan still reports Failed and durably removes the saved transition. This was a static review: no CI checks had failed at the time of review, and the Rust workspace tests, Kotlin emulator tests, JS and Docker builds, Swift schema check, and PR Hygiene were still pending.
🟡 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 change adds intricate wallet reconciliation across sync passes and restarts, but it changes how pending spends and note reservations are resolved, not transaction execution, coin-selection logic, cryptographic primitives, or consensus. - Phase 1 reviewers: not run (skipped for throughput: 13 PRs queued, above the 10 limit)
- 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/shielded/sync/spent_elsewhere_tests.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/sync/spent_elsewhere_tests.rs:442-467: The restored-spend test reports scan coverage the SDK stream cannot produce
Impact: Maintainers can see the regression test pass with coverage through height 999 even though the production stream would establish no coverage for those ranges.
The fixture reports `total_count: 2` for the first batch and drops it to `1` for the empty tail. The SDK keeps the maximum count seen across completed fetches and emits that value on every batch (`packages/rs-sdk/src/platform/shielded/notes_sync/sync_shielded_notes.rs:169–178, 295–306`), so the tail would still report `2`. Both fixture batches end at position `1`, and the wallet only records coverage when the batch end reaches its reported count (`sync.rs:556–561`). Keep the emitted count at `2` and expect `None`. That still skips reservation cleanup and leaves the Failed and reopen assertions to verify explicit record deletion.
Not approved: 1 blocking finding(s) are disputed and left to the maintainers.
|
Bots are done — your move: post |
…mits The SDK's note stream puts the highest tree count seen on every batch, so a tail range proved a block earlier still reports the later count. The two fixtures with such a tail lowered it, which made the pass report coverage through the tail's height. With the count the stream emits, no batch ends at the tree's end and the pass covers no height. What the tests check is unchanged: the row fails and the other notes are not released. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
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)
Nothing blocks: no blocking finding stands on this head.
Not counted: 1 disputed blocking finding(s) left to maintainers.
New on this head: This head updates two shielded-wallet tests so their stale tails retain the SDK stream’s highest note count; both fixtures now expect no covered height. This was a static review: the current GitHub checks show the Kotlin SDK emulator build and tests and PR Hygiene still pending, with no failed code checks.
🟡 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 shielded sync and coordinator changes require careful review of failure detection and note release, but they reconcile local wallet state without changing transaction execution, coin selection, or cryptography. - Phase 1 reviewers: not run (skipped for throughput: 11 PRs queued, above the 10 limit)
- 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/shielded/sync/spent_elsewhere_tests.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/sync/spent_elsewhere_tests.rs:525-545: The stale-tail test no longer checks that older scan coverage keeps notes reserved
Impact: A maintainer could change the release gate to accept any covered height, and the tests would miss that the wallet can then make an already-spent note selectable.
The revised test catches release with no coverage, but not release with coverage below the height that proved the conflict. It now returns `None`, so both this test and the full-coverage release test would pass if `sync.rs:1131` used `covered_height.is_some()` instead of comparing heights. Keep the corrected fixture and add a case with a full prefix emitted at height 999 before the newer fetch completes, when the prefix reaches the tree’s end. Then emit a full range at 1000 containing the first conflicting action and reporting a count beyond that range’s end, followed by an empty tail proved at 999 that retains the higher count. Assert that the pass reports `Some(999)` and still holds the second note.
Not approved: 1 blocking finding(s) are disputed and left to the maintainers.
|
Bots are done — your move: post |
…rs only a lower height With the stale tail fixtures corrected, no test told coverage below the height that proved the conflict from no coverage at all. This case has a first range that ends at the tree's end at 999, the competing action in a range proved at 1000, and a tail proved at 999: the pass covers 999, and the spend's other note stays reserved. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
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)
Nothing blocks: no blocking finding stands on this head.
Not counted: 1 disputed blocking finding(s) left to maintainers.
New on this head: This head adds a regression test that verifies a shielded note stays reserved when the scan covers height 999 but proves the conflicting spend at height 1000; no production code changed. This was a static review: the latest CI check showed no failures, with the Kotlin emulator build and tests and PR Hygiene still pending.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(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 change adds nontrivial wallet reconciliation and reservation-release logic, but it does not change how spends are built or executed, how inputs are selected, or how proofs are verified. - Phase 1 reviewers: not run (skipped for throughput: 14 PRs queued, above the 10 limit)
- 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. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
Not approved: 1 blocking finding(s) are disputed and left to the maintainers.
|
Bots are done — your move: post |
Basic explanation
What this does: a shielded spend whose result the wallet could not confirm stays Pending, with its notes reserved. If another transition spends one of those notes first (a second device restored from the same seed), the spend can never execute, but nothing told the wallet so and the row stayed Pending. The note scan now recognises that case, marks the row Failed in the same sync pass and frees the spend's other notes once it has scanned far enough to know the other spend did not take them too.
How it tells: every executed Orchard action leaves one proved note item in the commitment tree, and that item holds the action's nullifier and its output commitment together. The wallet keeps the signed transition of an unconfirmed spend, so it knows which commitment its own action pairs with each input's nullifier. When the scan reads an item carrying one of those nullifiers:
Nothing is inferred from what the scan has not seen. A landed spend whose change has not been scanned yet stays Pending.
Risks: medium-low. The wallet now fails a row and releases notes on a new rule, so the rule has to be sound; the reasoning is in the next section and in the doc comment on
SavedSpendInput. The change is confined tors-platform-wallet's note scan. No consensus, SDK, FFI, JNI, Swift or Kotlin code changes, and all seven note-consuming kinds are covered because they share the saved record.Where this departs from the proposal in #6108, and why
The issue proposed keeping the saved transition after a sighting and resolving it with
Sdk::state_transition_outcome. I checked that againstv5.1-devand did not use the outcome read:ExecutedOrSuperseded, which by its own contract must not fail a row or release anything. The read only decides when one of the transition's nullifiers is still unspent (a padding action, an untouched input, a purchase's token bundle). Testshould_fail_a_pending_spend_whose_every_input_another_transition_spentcovers the case it would leave Pending.v5.1-dev:Sdk::scoped_to_addressandDapiClient::with_address_listare in feat: report a shielded identity create proven to have its inputs spent without its identity #5853 (v5.2-dev), and the wallet does not record which node took a broadcast. The scan names no nullifier to anyone.What is kept from the proposal: a failure is only ever read off positive proof, never off the scan not having seen the change (the rule #6090 removed is not back in any form); the row's own outputs are what confirm it; a spend proven unable to execute fails its row and releases its remaining notes. The saved transition is not kept past a sighting because the sighting itself now decides.
Nothing here overlaps #5853: the only edit outside the scan is making
shielded_actionsvisible to it.Not yet verified
SH-28(Swift and Kotlin) describes the run. Not run.Not covered
Review
Several rounds from thepastaclaw, the later ones with no blockers. Kept from them: the release of a failed spend's other notes is gated on scan coverage, and a test uses a serialized type 28 transition. A first attempt to keep the saved transition until the host had the Failed row was reviewed as incomplete and removed again after an independent tiebreak; that problem is deferred to #6157. Also deferred: #6160 and #6161. Declined after the tiebreak: the protocol version 14 purchase case above.
Issue being fixed or feature implemented
Closes #6108.
No other open PR or issue fixes it (searched titles, bodies and the issue's cross references again on 2026-11-23). Related: #5853 (proven outcome read for a type 20 identity create,
v5.2-dev), #5837 (saves spend records before broadcast, merged), #6109 (scan watermark gap, separate and untouched).What was done?
rs-platform-walletwallet/shielded/sync.rs: before a pass streams notes,saved_spend_inputsreads the saved spends of the subwallets being scanned and maps each input nullifier to the commitment the saved transition pairs it with. The store's write guard is held for the whole pass, so no spend can save a record during it. While scanning, an item whose nullifier is one of those inputs and whose commitment differs marks that spend. After the spent marks are applied,fail_spends_spent_elsewheresettles each such spend under the same store guard:covered_heightreaches the height that proved the other action, and only while their reservation still carries the spend's activity id (another attempt's hold on a note stays). The competing transition may have spent them too, in actions of a range proved before it executed.wallet/shielded/operations.rs:shielded_actionsis nowpub(super). For a token purchase it returns the fee bundle's actions, which are the ones written to the credit pool the scan reads.store.rsandcoordinator.rsupdated.Hosts: nothing to marshal. The Failed row travels in the activity changeset the hosts already persist, and both example apps already render a Failed row (the anchor expiry release produces one today).
TEST_PLAN (Swift and Kotlin): new row
SH-28. The KotlinSH-24row no longer says the case never resolves.How Has This Been Tested?
New tests, no network:
wallet::shielded::sync::spent_elsewhere_testsshould_fail_a_pending_spend_whose_single_input_another_transition_spentshould_fail_a_restored_pending_spend_whose_single_input_another_transition_spent(file store reopened, the scan after the restart fails the row, a second reopen finds nothing saved)should_drop_the_transition_of_a_failed_spend_whose_note_the_store_does_not_hold(reopened store, the host has not restored the note, the pass is short of coverage: the row fails and no transition is restored afterwards)should_free_the_untouched_notes_of_a_spend_another_transition_took_an_input_of(several inputs, one consumed; another attempt's note and record stay)should_hold_the_other_notes_until_the_scan_covers_the_competing_spend(the competing spend straddles a range boundary and the tail range is proved a block earlier)should_hold_the_other_notes_when_the_scan_covers_only_a_lower_height(the pass covers a height below the one that proved the conflict)should_fail_a_pending_spend_whose_every_input_another_transition_spentshould_keep_a_pending_spend_pending_when_the_scan_reads_its_own_actionshould_keep_a_note_another_attempt_reserved_sinceshould_fail_the_spend_on_the_pass_after_a_cancelled_oneshould_tell_a_token_purchase_s_own_fee_action_from_another_spend_of_its_fee_note(a serialized type 28 transition)wallet::shielded::coordinator::tests::should_keep_a_landed_spend_pending_until_a_later_pass_reads_its_change(own action read first: Pending, not Failed; change read a pass later: Confirmed)Mutation checks: with the failing step removed, the tests that expect Failed fail; with the commitment comparison ignored, the two tests that expect a landed spend to stay Pending fail; with the coverage condition ignored, the range boundary test fails.
Run locally:
Breaking Changes
None. No public Rust, FFI, JNI, Swift or Kotlin interface changes. The one behaviour hosts can observe: a Pending shielded activity row can now turn Failed during a sync pass for this reason, through the same changeset that already carries status 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
PR Hygiene ·
8c3deea/self-reviewedkotlin-sdk(packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md) — HashEngineeringrs-platform-wallet(packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs,packages/rs-platform-wallet/src/wallet/shielded/operations.rs,packages/rs-platform-wallet/src/wallet/shielded/store.rsand 2 more) — HashEngineering or ZocoLini or llbartekll or romchornyiswift-sdk(packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md) — llbartekll or romchornyiWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.