Repository navigation
feat(swift-example-app)!: send tokens within a token shielded pool (type 26) - #6132
Conversation
|
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 13 minutes. View limit details
Walkthrough
Merge Risk:
|
|
🔍 Review in progress (commit 6bdac6a) · live progress |
53d823e to
6274695
Compare
a24f75c to
465f275
Compare
6274695 to
764dc02
Compare
465f275 to
b8a127b
Compare
764dc02 to
d4641ac
Compare
b8a127b to
b281f45
Compare
d4641ac to
73d63a8
Compare
b281f45 to
93285c3
Compare
73d63a8 to
4fad076
Compare
93285c3 to
db53f05
Compare
4fad076 to
6d9d794
Compare
db53f05 to
a7ab835
Compare
6d9d794 to
f47751a
Compare
a7ab835 to
3a766bf
Compare
f47751a to
8b6d786
Compare
… 26) The wallet builds a TokenShieldedTransferWithShieldedFee from an account's notes in a watched token pool, paying the fee from its credit pool notes. Token notes are reserved in the token pool tables, largest first and bounded by what fits one transition; their Merkle paths come from the leaves the scan kept, and their root must be an anchor the token pool records. An accepted transfer stays pending: its proof shows its token nullifiers spent, which does not bind this transfer. A sync pass releases the token notes of a spend that holds no saved record and is not in flight. The SDK gates the transition at protocol version 14. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he Shielded Tokens screen FFI export platform_wallet_manager_shielded_token_transfer marshals a type 26 transfer (raw 43-byte Orchard recipient) to the manager's purchaser, which requests the follow-up sync itself. The balances row gains reserved_balance. The Swift SDK wraps the transfer, and the Shielded Tokens screen gets a Send form per token row, a Pending line for reserved tokens, and a "Token Transfer" label for activity tag 11. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
8b6d786 to
0011c08
Compare
|
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.
⚠️ DEGRADED — Final validation — Phase 1 + Phase 2
⚠️ DEGRADED review. The primary review models were unavailable (gpt-6.2-solunavailable: All credentials for model gpt-6.2-sol are cooling down (last error: usage_limit_reached: The usage limit has been reache), so this review ran on stand-in models:gpt-5.6-luna→muse-spark-1.3-contributor,gpt-5.6-sol→muse-spark-1.3-contributor,gpt-5.6-terra→muse-spark-1.3-contributor,gpt-6-astra→muse-spark-1.3-contributor,gpt-6.1-sol→muse-spark-1.3-contributor,gpt-6.2-astra→muse-spark-1.3-contributor,gpt-6.2-sol→muse-spark-1.3-contributor. Both review phases and the independent verifiers still ran, but on weaker models, with Phase 1 capped athigheffort. Treat the verdict as provisional; a full-strength re-review will run on the next push once the primary models are back.
Nothing blocks: no blocking finding stands on this head.
Adds type-26 token shielded-pool transfers end to end in rs-platform-wallet with FFI and SwiftExampleApp wiring. CI snapshot shows CodeRabbit and title checks passing with remaining checks queued or in progress and no failed code check attributable to this head.
🟡 3 suggestion(s)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: architecture-layering); reviewer 3: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: platform-versioning); reviewer 5: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: rust-quality); reviewer 6: muse-spark-1.3-contributor (standing in for gpt-6.2-astra) (agent: phase2-reviewer, role: security-auditor); reviewer 7: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 8: glm-5.3-flash (agent: phase1-reviewer, role: rust-quality); final verifier: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: sol-verifier, role: final-verifier)
- Degraded mode:
gpt-6.2-solunavailable: All credentials for model gpt-6.2-sol are cooling down (last error: usage_limit_reached: The usage limit has been reache (detected by probe, since 2026-11-23T09:07:27Z); stand-insgpt-5.6-luna→muse-spark-1.3-contributor,gpt-5.6-sol→muse-spark-1.3-contributor,gpt-5.6-terra→muse-spark-1.3-contributor,gpt-6-astra→muse-spark-1.3-contributor,gpt-6.1-sol→muse-spark-1.3-contributor,gpt-6.2-astra→muse-spark-1.3-contributor,gpt-6.2-sol→muse-spark-1.3-contributor; Phase 1 effort capped athigh - Triage:
criticalbymuse-spark-1.3-contributor(standing in forgpt-6.2-sol) (effort low) — Large intricate change adding wallet funds-movement and note selection in operations::token_shielded_transfer with Orchard proofs and anchor checks. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer,glm-5.3-flash— rust-quality (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 67% left, weekly 94% left; passed overgemini-3.8-flash-high(antigravity quota lookup failed) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
muse-spark-1.3-contributor(standing in forgpt-6.2-sol) — final-verifier; agentsol-verifier - Phase 2 reviewers:
muse-spark-1.3-contributor(standing in forgpt-6.2-astra) — general (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6.2-astra) — architecture-layering (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6.2-astra) — ffi-engineer (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6.2-astra) — platform-versioning (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6.2-astra) — rust-quality (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-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/operations.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/operations.rs:2471-2518: Type-26 transfer settlement branches that hold or release token notes have no test
Impact: A regression that releases a submitted transfer's token notes early or retires its record as failed would let the wallet double-spend or hide balances with CI staying green.
The consequence is an untested double-spend guard: every new test in mod token_shielded_transfer_tests stops before the broadcast, while settle_token_pool_spend decides whether token notes stay held under the record id on Submitted, stay held on unconfirmed, or are released on definitive failure. The sibling type-28 purchase path has exactly this harness with purchase_token_with_outcome plus should_keep_a_purchase_pending_when_platform_answers_with_the_pool_balance and should_keep_an_unconfirmed_purchase_pending_and_report_it. Add the same two mock-driven cases for the transfer past build and prove: one where the affected-state wait answers success and asserts Submitted with the activity row pending and the token notes still reserved, and one where the broadcast fails unconfirmed and asserts both fee and token reservations are retained with a retryable result.
In `packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs:874-893: Orphan sweep holds the reservation lock across SQLite writes
Impact: Concurrent token spends block in reserve, rekey, or drop for the whole post-scan sweep instead of microseconds.
The consequence is avoidable executor stalls: release_orphaned_reservations holds the process-wide IN_FLIGHT mutex guard for the entire SELECT plus per-marker UPDATE loop, so every thread needing in_flight waits on SQLite I/O. The guard is only needed for point-in-time membership. Snapshot it and drop the guard before touching SQLite.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs:784-796: Token reservation loads and deserializes every pool note to pick a few
Impact: Each transfer reads the account's full token-pool history including spent and reserved notes before discarding most of it, growing without bound as the pool accumulates history.
The consequence is wasted I/O and allocation on every spend: reserve_token_notes calls notes() which SELECTs all rows for the wallet, account, and token and deserializes every note_data blob, then filters to unspent-and-unreserved in Rust. The predicate is already known to the query. Push the filter into SQL so a reservation reads only spendable notes.
|
Bots are done — your move: post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (queue backlog)
Changes requested: 2 blockers
- A delivered token payment can show as Failed when its last scan page is one block behind —
packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs:348-350(new)
Impact: A protocol-14 sender whose payment spans two token scan pages can see Failed after the recipient was paid, with a spent input temporarily shown as available. - A failed scan-height write can leave an outgoing note out of the host store after retry —
packages/rs-platform-wallet/src/wallet/shielded/sync.rs:837-841(new)
Impact: A wallet syncing send history through a transient SQLite write failure can persist a cursor beyond an outgoing note that the host never received.
New on this head: This head distinguishes partially spent token holds from fully spent ones and persists the credit scan’s highest proof height before applying nullifiers that can retire a recovery record. No code checks had failed when checked; the Rust workspace and WASM tests, Kotlin emulator build and tests, JS and Docker builds, and PR Hygiene were still pending.
A pattern across this PR's review rounds
This is review round 7, and the PR has drawn 14 blocking findings so far. 9 of them share one underlying cause. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.
1. No durable owner for the two-pool spend (2 new in this round, 7 earlier finding(s))
A spent fee note or a pruned fee anchor can remove PendingRedrive before the wallet knows what happened to the token transfer, leaving release_orphaned_token_reservations to reconstruct the outcome from flags on token notes and pool scan metadata. The new partly-spent check treats flags committed by different pages as one complete view, so a lagging final page can make a delivered payment look like a competing spend. The patch to preserve the credit scan height after the record is gone also adds a fallible SQLite write after sync_notes_from_stream has updated its outgoing-note deduplication index but before the host receives those notes.
Already tracked: #6108
In this round: A delivered token payment can show as Failed when its last scan page is one block behind; A failed scan-height write can leave an outgoing note out of the host store after retry
Suggested decision (redesign the component): Replace the type-26 orphan sweep as the settlement authority with a durable spend record in rs-platform-wallet that owns both pools' holds and survives the end of rebroadcast. Keep whether dispatch was possible, the signing version, the input nullifiers, and the token output commitments so the wallet can decide separately whether the inputs are safe to reuse and whether this payment landed, even after a restart or a scan with pages from different heights. Leave idle-anchor cleanup, host status-write retries, and account removal behavior in their existing follow-ups. Rust workspace and wasm32 tests, the Kotlin emulator job, and the JS, Drive, and RS-DAPI builds were still pending when checked.
🔴 2 blocking | 🟡 1 suggestion(s)
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: ffi-engineer); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 6: 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) — The new funds-movement path inoperations::token_shielded_transferand note selection intoken_pool::reserve_token_notescoordinate token and fee inputs, broadcast, and persistent settlement across two shielded pools. - Phase 1 reviewers: not run (skipped for throughput: 15 PRs queued, above the 10 limit)
- New since the last final review (
651a541b): 2 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 2 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— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— platform-versioning (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
Several findings on this PR share an underlying cause (the review's "pattern" section): No durable owner for the two-pool spend. When you fix the findings below, fix the cause, not only the reported case. The review suggests (redesign the component): Replace the type-26 orphan sweep as the settlement authority with a durable spend record in `rs-platform-wallet` that owns both pools' holds and survives the end of rebroadcast. Keep whether dispatch was possible, the signing version, the input nullifiers, and the token output commitments so the wallet can decide separately whether the inputs are safe to reuse and whether this payment landed, even after a restart or a scan with pages from different heights. Leave idle-anchor cleanup, host status-write retries, and account removal behavior in their existing follow-ups. Rust workspace and wasm32 tests, the Kotlin emulator job, and the JS, Drive, and RS-DAPI builds were still pending when checked. If that decision is not yours to make, say so to the PR's author or maintainer.
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:348-350: A delivered token payment can show as Failed when its last scan page is one block behind
Impact: A protocol-14 sender whose payment spans two token scan pages can see Failed after the recipient was paid, with a spent input temporarily shown as available.
The new `partly_spent` branch turns incomplete scan coverage into a failure verdict. A sender can submit a multi-input protocol-14 transfer, have another device spend its original fee note in a credit payment by H−1, and then have the token transfer land with a different fee bundle at H. A credit scan through H−1 can retire the recovery record without seeing the token transfer. If its token actions straddle a page boundary, `apply_chunk` commits the first input’s spent flag from a full page proved at H. The next request can go to a node at H−1: the SDK accepts one block of lag, and an aligned range beyond that block’s tree end has a valid empty proof. `apply_chunk` overwrites the pool’s count and height with that answer, and `scan_pool` treats the short page as complete. H−1 meets the credit floor, so the sweep marks the payment Failed and clears both holds. Catch-up marks the second input spent, but the original fee change will never arrive to correct the verdict. Persist the highest proved token-tree count alongside applied chunks and withhold settlement until the scanned prefix covers that count and satisfies the credit-height floor, including after interruption or restart. Test a full page at H, an empty page at H−1, and catch-up at H: the lagging pass must keep the hold, and neither pass should report Failed.
_Confirmed by an independent pass: A wallet submits a multi-input transfer on protocol 14 and leaves it pending after an ambiguous broadcast; another device spends the original fee note by H−1, and the unbound token bundle lands with a different fee bundle at H. Shielded sync can retire the recovery record at H−1, mark one token input spent from a full page at H, then accept a valid empty page at H−1 when the remaining spend action is across the page boundary. The sweep marks the delivered payment Failed and releases the token hold; catching up cannot confirm the row because it is keyed to the original fee change, which never landed._
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs:4402-4406: The restart test still passes if credit sync stops saving the spend height
Impact: A regression in how credit sync records spend evidence could reopen spent token inputs after restart without failing this test.
The reopen assertion checks that SQLite retains height 11, but the fixture supplies that value directly to `note_spend_scan_height` and calls `mark_spent` itself. The test would still pass if `sync_notes_from_stream` stopped writing the floor or used the lower terminal batch’s height instead of the maximum. Use the existing synthetic stream entry point to feed a batch at 11 containing the fee nullifier followed by a terminal batch at 10. Assert that the recovery record is gone, the reopened floor is still 11, and a token scan at 10 cannot release the hold.
In `packages/rs-platform-wallet/src/wallet/shielded/sync.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/sync.rs:837-841: A failed scan-height write can leave an outgoing note out of the host store after retry
Impact: A wallet syncing send history through a transient SQLite write failure can persist a cursor beyond an outgoing note that the host never received.
A successful retry can advance the host’s scan cursor without saving an outgoing note recovered on the failed pass. During normal shielded sync, `record_outgoing_note` inserts the commitment into the file-backed store’s in-memory deduplication set and adds the outgoing note to the changeset. If the new SQLite height write then fails, for example because the device is out of space, `?` discards that changeset before the coordinator calls the host persister. Once the write succeeds on a retry in the same process, the unchanged watermark causes the scan to recover the note again, but deduplication returns `false`, so only the advanced cursor reaches the host. If the note is before the chunk the cursor resumes from, restarting loses the only copy without rescanning it. This happens before any host persistence attempt, so retrying host writes in #6157 would not recover it. Move the height write immediately after the cancellation return, before saving receipts or recording outgoing notes, while keeping it before nullifier replay. Add a fail-once write test that verifies the retry emits the outgoing note.
_Confirmed by an independent pass: During normal shielded sync, the wallet can recover an outgoing note and then hit a transient SQLite write failure, such as running out of disk space, in the new scan-height write. After space is freed, a retry in the same process can persist an advanced scan cursor without the outgoing note because the first pass already populated the in-memory deduplication set. If the note lies before the cursor's aligned resume point, normal sync after restart skips it and the persisted send history remains incomplete._
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
…the largest tree seen A page answered by a node a block behind proves a shorter tree. After a full page proved the pool larger, such a page ended the scan as if it were the pool's end, lowered the recorded height and count, and let the sweep judge holds from a scan that missed a spend. The recorded count, height and version now only rise, and a pass counts the pool complete only when it reaches the highest count a page has proved. The credit note sync keeps its highest batch height before it saves or records anything else, so a failed write leaves nothing half recorded for a retry to skip; a synthetic stream test checks the highest, not the last, batch height is kept across a reopen. Co-Authored-By: Claude Opus 5.5 <[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 1 + Phase 2
New on this head: This revision records the credit spend-observation height before saving ledger changes and requires a token scan to cover the largest proven tree before it can settle holds. In the latest CI check, the Kotlin emulator build and tests passed, no code checks were failing, and PR Hygiene and PastaClaw review were pending.
🟡 2 suggestion(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
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: ffi-engineer); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 8: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — The new transfer in rs-platform-wallet/src/wallet/shielded/operations.rs moves shielded token funds and coordinates token and fee note selection, reservation, broadcast, and settlement across two pools. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity below 15% reserve: models 0% left),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- 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— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— platform-versioning (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/token_pool.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs:1448-1449: After a lagging page, the balance reports an earlier proof as the last page
Impact: Rust, C, and Swift callers inspecting an incomplete scan can mistake an earlier page’s larger tree count and higher proof height for the final response or for completed coverage.
The balance no longer tells callers what the final page proved. The new `MAX` updates deliberately preserve the larger count and higher height from an earlier page, even when the lagging final page leaves the pool out of `completed`. The Rust, C-facing, and Swift fields still describe values from the last chunk read. Keep the maxima and document them as the highest proven values retained for the pool, distinct from `scanned_note_count`, the contiguous prefix actually checked for the account. The reported height alone does not certify completion.
In `packages/rs-platform-wallet/src/wallet/shielded/sync/cancel_tests.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/sync/cancel_tests.rs:482-496: The restart test still passes if the recovery record is deleted before the height write
Impact: A future reordering could let an interrupted sync lose the height needed to settle a pending transfer while this regression test stays green.
The test verifies that the record is gone and the maximum height survives reopen, but only after a successful scan. Moving `note_spend_scan_height` below `apply_scanned_nullifier_spends` would still satisfy both assertions. The production order is correct on this head. Keep the success case and add a failure-path test that rejects the sweep-height write, runs the real scan, and verifies that the scan returns an error, the fee note is still unspent, and its recovery record is still present before retrying.
|
Bots are done — your move: post |
…as the highest proven The recorded count and height only rise, so the Rust, C and Swift fields say so, and that neither certifies a scan reached the pool's end. A failure-path test checks a failed spend-scan height write leaves the fee note unspent and the saved spend's record in place. Co-Authored-By: Claude Opus 5.5 <[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 1 + Phase 2
New on this head: This revision documents the highest proven token-pool count and height separately from the prefix each account has scanned. It also adds a regression test that checks that a failed credit scan-height write leaves the fee note unspent and its recovery record intact. No code checks have failed; the Kotlin emulator build and tests, PR Hygiene, and the review check are still pending.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 8: 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) — The wallet'sshielded/operations.rsandshielded/token_pool.rsimplement an intricate funds-movement flow that selects and reserves token and fee notes, validates anchors before broadcast, and tracks pending spends through settlement. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity below 15% reserve: models 0% left),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- New since the last final review (
e8eb9d87): 1 finding(s) judged fixed earlier and raised again on unchanged lines kept settled - 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— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— platform-versioning (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. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
|
Bots are done — your move: post |
…e-shielded-token-spend # Conflicts: # docs/sdk/sdk-parity-manifest.json # packages/kotlin-sdk/PARITY_SUMMARY.md
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
…e-shielded-token-spend # Conflicts: # docs/sdk/sdk-parity-manifest.json # packages/kotlin-sdk/PARITY_SUMMARY.md
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
Basic explanation
A wallet can now send tokens it holds in a token's shielded pool to another Orchard address in that pool. This is a
TokenShieldedTransferWithShieldedFee, state transition type 26. The tokens never leave the pool. The fee is paid from the wallet's credit shielded pool notes, and no identity is involved.Before: the wallet could see its tokens in a token shielded pool (#6116) but could not spend them.
After:
It builds on #6116 (merged), which added the token pool scan. The token unshield to an identity (type 27) is stacked on this PR in #6133.
Issue being fixed or feature implemented
Test plan row SH-26 was blocked on the wallet tracking token pool notes. #6116 added that tracking.
What was done?
rs-sdktoken_shielded_transfer_with_shielded_fee_requirement()(protocol 14) is registered in the broadcast gate, so a broadcast or redrive of type 26 is refused locally before activation.rs-platform-walletoperations::token_shielded_transferdoes the whole transfer in Rust.Admission:
Refusals before any note is reserved:
Token notes:
token_pool::reserve_token_notesreserves the account's unspent, unreserved token notes covering the amount, largest first.Proof::expected_proof_size.TokenShieldedInsufficientBalance, and nothing stays reserved.Fee notes:
ShieldedFeeKind::TokenShieldedTransfer).Merkle paths:
token_pool::spend_pathsbuilds the token pool's tree in memory from the leaves the scan kept.ShieldedNoRecordedAnchor, and a sync fixes it.Build and broadcast:
token_bundle_binds_fee_bundle). Then the record is saved and the transition broadcast with redrive. Saving the record also marks the token hold saved, in the same transaction.What the proof binds:
ShieldedTokenSpendOutcome::Submitted):Scan evidence the settlement relies on:
ShieldedStore::note_spend_scan_height). It does this before it saves or records anything else in the pass.Reservation lifetime and settlement:
reserved_by,signed_bound,record_savedandfee_anchor_prunedcolumns, added in place when missing.settle_orphaned_token_hold):TokenShieldedPoolSpendPending).Other changes:
ShieldedTokenPoolBalancegainsreserved_balance, andbalanceexcludes reserved notes. Itspool_note_countandscanned_heightare now the highest proven values, not the last page's.TokenShieldedTransfer(tag 11).PlatformWallet::shielded_token_transferandShieldedTokenPurchaser::transfer. The latter requests the follow-up sync.rs-platform-wallet-ffi, Swift SDK, SwiftExampleAppreserved_balance. Persisted activity tag 11 is decoded.@Modelchange.shielded.token_shielded_transfer.New public interfaces
C FFI
ErrorInvalidParameter.ShieldedTokenPoolBalanceFFIgainsuint64_t reserved_balanceafterunspent_note_count. feat(swift-example-app): show a wallet's tokens in token shielded pools #6116 is not released, so nothing depends on the old layout. Itspool_note_countandscanned_heightare now documented as the highest proven values.Swift
shieldedTokenTransfer(walletId:resolver:account:dataContractId:tokenContractPosition:recipientRaw43:amount:) async throwsShieldedTokenPoolBalance.reservedBalance. Its public initializer takesreservedBalance: UInt64 = 0, so existing callers compile unchanged.Rust (
platform-wallet)PlatformWallet::shielded_token_transfer,ShieldedTokenPurchaser::transfer,ShieldedTokenSpendOutcome::SubmittedShieldedTokenPoolBalance::reserved_balancePlatformWalletError::TokenShieldedInsufficientBalance { token_id, available, required }: a transfer the account's unreserved token notes cannot cover.PlatformWalletError::TokenShieldedPoolSpendPending { token_id }: unwatch refused because some of the wallet's notes in that pool are held. Watching it again would otherwise offer them to another spend, or lose the link the sync settles a pending spend by.ShieldedStore::note_spend_scan_height(&mut self, height: u64): a new trait method with a default no-op, called by the note sync before it marks notes spent. The file store keeps the height; other stores keep nothing.ShieldedFeeKind::TokenShieldedTransfer,TokenPoolSpendNoteLimits,token_pool_spend_token_actions,compute_token_shielded_transfer_feeShieldedActivityKind::TokenShieldedTransfer(tag 11)TokenPoolChunk::protocol_version: a public field on the struct aTokenPoolNoteSourcereturns, so an implementation outside the crate must set it.Rust (
dash-sdk)token_shielded_transfer_with_shielded_fee_requirement()Persisted state
shielded_token_pool_notes, added in place:reserved_by BLOB,signed_bound INTEGER NOT NULL DEFAULT 0,record_saved INTEGER NOT NULL DEFAULT 0,fee_anchor_pruned INTEGER NOT NULL DEFAULT 0, and the partial indexshielded_token_pool_notes_by_reservation (wallet_id, account_index, reserved_by) WHERE reserved_by IS NOT NULL.shielded_token_pool_scans.scanned_protocol_version INTEGER, added in place. A scan recorded before it existed binds nothing until the next scan writes it. The row's count, height and version are now only raised.shielded_token_pool_sweep (id, credit_height), one row: the highest credit scan height kept, by the note sync before it marks notes spent and by the sweep. Clear empties it.kindTagcolumn.App accessibility identifiers
shieldedTokens.sendButton,shieldedTokens.pendingBalanceshieldedTokenSend.form,.recipient,.pasteButton,.ownAddressButton,.amount,.submit,.result,.error,.closeSource compatibility:
ShieldedFeeKind,ShieldedActivityKindandPlatformWalletErrorare public and not#[non_exhaustive]. Rust code that matches them exhaustively must add the new variants, and code that builds aTokenPoolChunkmust set its new field, hence the!. The newShieldedStoremethod has a default, so existing store implementations compile unchanged.How Has This Been Tested?
cargo test -p platform-wallet --features shielded --lib -- shielded::: 435 passed. The new ones cover:arm_redriveand their removal checked;should_bound_a_token_shielded_transfer...: the size limits and the fee match consensus.cargo test -p dash-sdk --lib should_refuse_a_generic_broadcast: 4 passed, including the type 26 gate.cargo test -p platform-wallet-ffi --features shielded --lib -- token_transfer shielded_token_pools: 17 passed, covering outcome and refusal mapping, null pointers, a bad recipient, and an unknown manager.cargo clippywith CI's flags onplatform-walletandplatform-wallet-ffi, andcargo fmt --all: clean on the latest commit.packages/swift-sdk/build_ios.sh --target sim(release): BUILD SUCCEEDED, including SwiftExampleApp built with warnings as errors, before the last review rounds. The Swift changes since are one default argument value, one label string and two doc comments.Not yet verified
PlatformWalletpast proving.Breaking Changes
Rust source only: new variants on the public
ShieldedFeeKind,ShieldedActivityKindandPlatformWalletErrorenums, which are not#[non_exhaustive], and a new field onTokenPoolChunk. Nothing changes at the protocol, consensus, C ABI (additive; the unreleased row from #6116 grows) or SwiftData level.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 ·
f07773b/skip-botsproceeds without the ones not yet reported/self-reviewedsdk-parity— you own itkotlin-sdk(packages/kotlin-sdk/PARITY_SUMMARY.md) — HashEngineeringrs-platform-wallet-ffi(packages/rs-platform-wallet-ffi/src/persistence.rs,packages/rs-platform-wallet-ffi/src/shielded_persistence.rs,packages/rs-platform-wallet-ffi/src/shielded_send.rsand 1 more) — HashEngineering or ZocoLini or llbartekll or romchornyirs-platform-wallet(packages/rs-platform-wallet/src/error.rs,packages/rs-platform-wallet/src/manager/shielded_token_purchase.rs,packages/rs-platform-wallet/src/wallet/platform_wallet.rsand 11 more) — HashEngineering or ZocoLini or llbartekll or romchornyirust-sdk(packages/rs-sdk/src/platform/transition/broadcast.rs,packages/rs-sdk/src/sdk/protocol_gate_tests.rs) — lklimek or shumkovswift-sdk(packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentShieldedActivity.swift,packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletManagerShieldedSync.swift,packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedActivityView.swiftand 4 more) — 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.