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 17 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. |
|
🔍 Review in progress (commit 3a766bf) · live progress |
|
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: Request rejected (429) · All credentials for model gpt-6.2-sol are cooling down (last error: usage_limit_reached: The us), 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.
Changes requested: 2 blockers
- Unwatch or wallet removal mid-scan resurrects token rows and a later re-watch skips notes —
packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs:800-884(new)
Impact: A user who stops watching a pool or removes a wallet while a shielded sync is scanning it and later re-watches it sees a balance reported as fully scanned that permanently omits the deleted notes. - Clear deletes the token watch list so owned token notes stay invisible after a rebuild —
packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs:379-390(new)
Impact: A user who runs Clear and then rebinds and syncs sees an empty Shielded Tokens list even though their token notes are still on chain, until they remember and manually re-watch each pool.
Adds wallet-local token shielded-pool watching, chunk-aligned scanning after the credit-pool pass, auto-watch on type-28 purchases, and FFI plus SwiftUI surfaces. CI is still running (Rust workspace tests and Kotlin build in progress, other jobs skipped or successful).
🔴 2 blocking | 🟡 5 suggestion(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: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: phase2-reviewer, role: general); reviewer 4: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: phase2-reviewer, role: architecture-layering); reviewer 5: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: phase2-reviewer, role: rust-quality); reviewer 7: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: phase2-reviewer, role: security-auditor); reviewer 8: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: phase2-reviewer, role: general); reviewer 9: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: phase2-reviewer, role: architecture-layering); reviewer 10: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: phase2-reviewer, role: ffi-engineer); reviewer 11: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: phase2-reviewer, role: rust-quality); reviewer 12: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (agent: phase2-reviewer, role: security-auditor); 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: Request rejected (429) · All credentials for model gpt-6.2-sol are cooling down (last error: usage_limit_reached: The us (detected by lane, since 2026-11-23T09:25:39Z); 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:
normalbygpt-6.2-sol(effort low) — The scanner and its cross-language integration are intricate, but token_pool.rs uses existing cryptographic primitives and adds wallet-local tables without migrating existing records or changing how funds are spent. - 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 quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - 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:
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-sol) — general (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6.2-sol) — architecture-layering (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6.2-sol) — ffi-engineer (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6.2-sol) — rust-quality (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6.2-sol) — security-auditor (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6.2-sol) — general (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6.2-sol) — architecture-layering (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6.2-sol) — ffi-engineer (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6.2-sol) — rust-quality (completed, effort high); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-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/token_pool.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs:800-884: Unwatch or wallet removal mid-scan resurrects token rows and a later re-watch skips notes
Impact: A user who stops watching a pool or removes a wallet while a shielded sync is scanning it and later re-watches it sees a balance reported as fully scanned that permanently omits the deleted notes.
Consequence: purged notes, watermarks, leaves and scan state come back as orphans, and a later re-watch resumes from the resurrected high watermark over positions whose notes are gone, so those notes are never re-fetched without a full Clear. Mechanism: `sync_token_pools` snapshots the watch and watermark plan once up front and `scan_pool`/`apply_chunk` applies every later chunk under only the store read guard with no lifecycle lock and no per-chunk watch or registration recheck, while `unwatch_token_pool`, `unregister_wallet` and `clear` purge the same rows under the lifecycle plus store locks. A purge landing between the plan and a later chunk apply is therefore undone chunk-by-chunk: `apply_chunk` re-inserts leaves, saves notes and raises watermarks for a watch row that no longer exists, without recreating the watch, so `balances()` hides the orphans until a re-watch inherits the watermark. Fix in `rs-platform-wallet`: make the token pass respect the same lifecycle ownership, e.g. re-resolve watches or registration per chunk or per pool under the store guard and drop scanner entries whose watch or registration is gone before `apply_chunk`, or skip persisting chunks for unwatched pairs inside the apply transaction, plus a test that unwatches mid-scan, re-watches, and expects either a clean rescan or no orphan rows.
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs:379-390: Clear deletes the token watch list so owned token notes stay invisible after a rebuild
Impact: A user who runs Clear and then rebinds and syncs sees an empty Shielded Tokens list even though their token notes are still on chain, until they remember and manually re-watch each pool.
Consequence: after a Clear, token-pool funds are misreported as absent. Mechanism: `purge_all` deletes every token-pool row including `shielded_token_pool_watches`, and `FileBackedShieldedStore::purge_all_subwallets` called by `NetworkShieldedCoordinator::clear` calls it, while watches live only in the shielded-store SQLite file and are never handed to the host persister, unlike the credit pool which rescans unconditionally after Clear. Token pools scan only watched pools, so deleting the watch list breaks the cold-rebuild contract that Clear promises. Fix: keep the watch list across Clear and delete only scan cache, e.g. use a `conn.transaction()` that deletes from `shielded_token_pool_scans`, `shielded_token_pool_watermarks`, `shielded_token_pool_leaves` and `shielded_token_pool_notes` but not `shielded_token_pool_watches`, so the post-Clear sync rescans the same pools.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs:379-390: Token-pool Clear purge can leave the shared SQLite connection inside an open transaction
Impact: If one DELETE in the Clear path fails, later token-pool reads and writes on the shared shielded-store connection fail until the process restarts.
Consequence: a failed Clear reports failure but leaves some token tables already emptied and the shared `pending_conn` inside an open transaction. Mechanism: `purge_all` runs `BEGIN; DELETE...; COMMIT;` via `execute_batch`, so a mid-script error returns `Err` without reaching `COMMIT` or issuing `ROLLBACK`, unlike the siblings `purge_wallet`, `purge_subwallet` and `remove_watch` which use `conn.transaction()` with commit-on-success and RAII rollback. Fix: use the same `transaction()` shape as the sibling purges.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/token_pool.rs:563-608: Token balances load full note blobs just to add up small values
Impact: Wallets watching busy token pools pay extra SQLite I/O and per-note allocations on every balances refresh, which is the UI-facing path.
Consequence: wasted I/O and allocation on a refresh path. Mechanism: `balances()` calls `notes()`, which selects position, cmx, nullifier, value, 115-byte note_data, height and spent and hydrates a `Vec<u8>` per row, only to filter `!is_spent` and sum 8-byte values via `checked_add`. The cmx, nullifier, note bytes and heights are deserialized and discarded on this path. Fix: add a narrow totals query for `balances()` such as selecting only value and spent, or a SQL-side sum or count, and keep the full `notes()` load for the spend path that needs the blobs.
In `packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs:1754-1758: Token-only scan results do not count toward the sync cooldown decision
Impact: After a pass that finds token notes, marks token notes spent, or hits a token-pool error with no credit-pool activity, background syncs keep skipping for the cooldown window and delay token balance updates and error retries.
Consequence: stale token balances and deferred error retries even though the pass just did meaningful or failed token work. Mechanism: the token-pool call's `TokenPoolSyncSummary` is awaited and dropped, and the cooldown decision below only looks at credit-pool signals (`notes.total_scanned`, `newly_spent_per_sub`) when stamping `last_caught_up_at`, which gates the next background pass including its token-pool scan. Fix: bind the summary and fold it into `any_activity` by counting token `new_notes`/`newly_spent` and treating a non-empty `failed` map as activity so the retry is not delayed, and consider surfacing token-pool failures in the per-wallet sync outcome instead of only in the per-row `last_error`.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs:1010-1059: The network-verified token watch path has no test covering its refusals
Impact: The FFI `watch` refusal paths for a token without a shielded pool or an unreadable token configuration can regress without any test failing.
Consequence: the gate that refuses misconfigured tokens is unverified. Mechanism: the suite covers `record_token_pool_watch`, the no-network helper used by purchases and the existing coordinator test, but not `watch_token_pool` with its `ensure_token_has_shielded_pool` network read before recording; FFI tests assert error-message mapping with synthetic errors, not the actual gate. Fix: add a coordinator test with the mock SDK pinning at least the no-network refusal and the unreadable-configuration refusal produced by the mock fetch.
In `packages/rs-platform-wallet/src/manager/shielded_token_purchase.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/manager/shielded_token_purchase.rs:70-90: A failed purchase-time pool watch leaves a confirmed purchase invisible with only a log
Impact: On the rare path where recording the bought pool's watch fails, the purchase succeeds but the Shielded Tokens screen never shows the tokens until the user manually watches the pool.
Consequence: confirmed purchase with missing tokens in the UI and no user-facing signal. Mechanism: `ShieldedTokenPurchaser::purchase` only `warn!`s when `record_token_pool_watch` fails from a store error or mid-purchase unbind and still returns success plus requests a sync, while later syncs skip unwatched pools and nothing retries the watch. Fix: surface the watch failure to the host alongside the purchase outcome or reconcile desired watches before the next scan so a transient store failure does not permanently hide that purchase.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
|
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 |
93285c3 to
db53f05
Compare
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
db53f05 to
a7ab835
Compare
…'s notes A wallet now keeps the notes it holds in the shielded pools of the tokens it watches, and reports a balance per watched pool and account. Each sync pass scans the watched pools after the credit pool, chunk by chunk, advancing a per-account watermark only over chunks read whole, so a short chunk ends the pass instead of leaving a gap. Spends are seen from the nullifiers the pool's actions reveal. The state lives in new tables of the shielded store's SQLite file; a type 28 purchase watches the bought token's pool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FFI exports watch, unwatch and list a wallet's token shielded pools
(platform_wallet_manager_shielded_token_pool_{watch,unwatch,balances}
and the balances free function), marshalling the coordinator's results.
The Swift SDK wraps them, and a new Shielded Tokens screen in
SwiftExampleApp shows each watched token's balance per account, how far
the scan has got and the last scan error, refreshes through the shielded
sync, and watches or unwatches a known token. No SwiftData model changes.
Drops the manager wrappers the FFI does not use: it reaches the
coordinator directly, as the other shielded exports do.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n sound - Each chunk rechecks, inside its transaction, that the wallet still watches the pool and the account's watermark row is still what the scan last wrote, so an unwatch, a wallet's removal, a Clear or a dropped account landing mid-scan is never undone; with no account left the chunk writes nothing and the scan stops. - A Clear keeps the watch list and drops only scan state, in one transaction, so the next sync rescans the watched pools. - Token notes found or spent, or a token pool failure, count as activity for the caught-up cooldown. - A purchase records its pool watch before anything is reserved or sent; a watch that cannot be recorded refuses the purchase. - Balances read only the unspent note values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a7ab835 to
3a766bf
Compare
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
Basic explanation
A wallet can now see the tokens it holds inside a token's shielded pool. Until now the wallet scanned only the credit shielded pool. A token bought from the shielded pool (type 28, #6090) landed on chain, but the app could not show it.
The wallet now keeps a list of the token pools it watches. Each shielded sync scans those pools for the wallet's notes and reports one balance per watched pool and account. A type 28 purchase watches the bought token's pool before it buys, and the app can watch any other token that has a shielded pool.
Before: after a shielded purchase, the screen said the tokens were on chain but not shown.
After: a new Shielded Tokens screen (Wallet → Shielded Tokens) lists each watched token with:
Refresh runs a shielded sync. "Watch a token pool" picks one of the app's known tokens. Swipe to stop watching.
This is the first of three PRs. It is the foundation for the shielded token transfer (type 26) and the token unshield to an identity (type 27). Both spend these notes, and both follow in stacked PRs.
Issue being fixed or feature implemented
Test plan rows SH-25 to SH-27 were blocked:
rs-platform-wallettracked no token pool notes, and types 26 and 27 cannot be built until the wallet has them. No open PR or issue covered this.What was done?
rs-platform-walletNew module
wallet::shielded::token_pool.Tables
Scan
sync_token_poolsscans every watched pool for the registered accounts of the wallets that watch it.NetworkShieldedCoordinatorwatch_token_pool,record_token_pool_watch(no network read),unwatch_token_poolandtoken_pool_balances.syncruns the token pool scan after the credit pool. A stopped pass reads no token pool, and a token pool failure fails nothing else.FileBackedShieldedStorePurchases
ShieldedTokenPurchaser::purchaserecords the bought token's pool watch before it reserves or sends anything. A watch that cannot be recorded refuses the purchase.rs-platform-wallet-ffishielded_token_poolswith the four exports below. They only marshal.Swift SDK and SwiftExampleApp
PlatformWalletManagerShieldedSync.swift.ShieldedTokenPoolsView.swift, linked fromWalletDetailView.ShieldedActivityViewandTokenPurchaseActionVieware updated.@Modelchange.Docs
TEST_PLAN.mdSH-25 is implemented and notes it has not yet run on a simulator. SH-24's "not shown" wording is removed.sdk-parity-manifest.jsongainsshielded.token_pool_balances, andPARITY_SUMMARY.mdis regenerated.New public interfaces
C FFI (
shieldedfeature)watchunwatchbalancesShieldedTokenPoolBalanceFFIfields:token_id[32],data_contract_id[32],token_contract_position,account_index;balance: the unspent value, in the token's smallest unit;unspent_note_count;has_scanned_note_count/scanned_note_count,has_pool_note_count/pool_note_countandhas_scanned_height/scanned_height;last_error: an owned C string, or null.Swift (
PlatformWalletManager)shieldedTokenPoolWatch(walletId:dataContractId:tokenContractPosition:) async throws -> Datareturns the token id.shieldedTokenPoolUnwatch(walletId:tokenId:) async throwsshieldedTokenPoolBalances(walletId:) async throws -> [ShieldedTokenPoolBalance]public struct ShieldedTokenPoolBalance: Sendable, Hashablemirrors the row, with optionals for the flagged values andlastError.Unwatch and balances are
asyncbecause they wait for the shielded store, which a sync pass can hold. A synchronous call would block the main actor.Rust (
platform-wallet)ShieldedTokenPoolWatch { token_id, data_contract_id, token_contract_position }ShieldedTokenPoolBalance { watch, account_index, balance, unspent_note_count, scanned_note_count, pool_note_count, scanned_height, last_error }NetworkShieldedCoordinator::{watch_token_pool, unwatch_token_pool, token_pool_balances}Persisted state (Rust-owned SQLite in the shielded store file, not SwiftData)
shielded_token_pool_watchesshielded_token_pool_scansshielded_token_pool_watermarksshielded_token_pool_leavesshielded_token_pool_notesApp accessibility identifiers
walletDetail.shieldedTokensLinkshieldedTokens.list,shieldedTokens.refreshButton,shieldedTokens.watchButtonshieldedTokens.row.<tokenIdBase58>.<account>, containingshieldedTokens.balance,.noteCount,.scanState,.lastErrorand.unwatchButtonshieldedTokens.watchSheet,shieldedTokens.watchSheet.token.<contractIdBase58>.<position>How Has This Been Tested?
cargo test -p platform-wallet --features shielded --lib -- token_pool should_request_a_sync_only: 13 passed (plus the watch refusal test). They cover:should_not_undo_an_unwatch_that_lands_mid_scan);cargo test -p platform-wallet --features shielded --lib -- should_refuse_to_watch_a_token shielded::coordinator shielded::file_store shielded::sync: 88 passed after the review fixes (101 before them, withshielded::operations::token_purchaseincluded).cargo test -p platform-wallet-ffi --features shielded --lib shielded_token_pools: 13 passed. They cover:cargo clippy -p platform-wallet -p platform-wallet-ffi --all-targets --all-features --locked -- --no-deps -D warnings: clean.cargo fmt --all: clean.packages/swift-sdk/build_ios.sh --target sim(release): BUILD SUCCEEDED. The xcframework built from this branch, and SwiftExampleApp built with-warnings-as-errors.python3 scripts/check_sdk_parity_manifest.py --write-summary: OK.Not yet verified
Breaking Changes
None. There is no protocol or consensus change and no SwiftData schema change. The new SQLite tables are additive and created on open. The C ABI only gains functions.
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 ·
3a766bf/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/identity_withdrawals.rs,packages/rs-platform-wallet-ffi/src/lib.rs,packages/rs-platform-wallet-ffi/src/shielded_sync.rsand 1 more) — HashEngineering or ZocoLini or llbartekll or romchornyirs-platform-wallet(packages/rs-platform-wallet/src/manager/shielded_token_purchase.rs,packages/rs-platform-wallet/src/wallet/platform_wallet.rs,packages/rs-platform-wallet/src/wallet/shielded/coordinator.rsand 6 more) — HashEngineering or ZocoLini or llbartekll or romchornyiswift-sdk(packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletManagerShieldedSync.swift,packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedActivityView.swift,packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedTokenPoolsView.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.