Repository navigation
feat(swift-example-app): buy a token from the shielded pool (type 28) - #6090
Conversation
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
✅ Final review complete — no blockers (commit 1b38910) · triage: critical |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Changes requested: 7 blockers
- A token-pool balance proof can confirm a purchase that did not execute —
packages/rs-platform-wallet/src/wallet/shielded/operations.rs:1847-1863(new)
Impact: A buyer can see “Purchase complete” and lose access to credit notes in the wallet even though those notes remain unspent and no tokens were minted for the purchase. - Purchases outside the wire or token-count limits can leave notes stuck in recovery —
packages/rs-platform-wallet/src/wallet/shielded/operations.rs:1782-1805(new)
Impact: A buyer whose payment needs four notes, or an SDK caller who supplies an above-limit raw count that the wallet can fund, can pay the proving cost and have notes held for a purchase that cannot execute. - The wallet can reserve credits for a purchase the network version cannot accept —
packages/rs-platform-wallet/src/wallet/shielded/operations.rs:1752-1763(new)
Impact: A funded buyer on a pre-PV14 network, or a buyer using an SDK pinned to PV14 after a PV15 upgrade, can wait for proving and have notes held for recovery instead of receiving a local version error. - Shielded Buy is enabled for direct-sale tokens that have no shielded pool —
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenActions/TokenPurchaseActionView.swift:299-305(new)
Impact: A funded buyer can select shielded payment for an ordinary direct-sale token, wait for proving, and have credit notes held pending recovery even though the token cannot be minted into a pool. - An in-flight purchase can recreate activity after its wallet is removed —
packages/rs-platform-wallet/src/wallet/platform_wallet.rs:2085-2091(new)
Impact: A host that removes a wallet while a shielded purchase is waiting for a result can receive a new activity write for the removed wallet after teardown. - Immediate recovery after an unconfirmed purchase depends on which API was called —
packages/rs-platform-wallet-ffi/src/shielded_send.rs:1501-1503(new)
Impact: After the same ambiguous purchase result, a Swift or C caller can trigger an immediate rebroadcast pass, while a direct Rust caller has to wait for another sync or request one itself. - Pending and failed activity details tell the buyer that tokens were minted —
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedActivityView.swift:317-326(new)
Impact: A buyer inspecting an unresolved or failed purchase sees “Purchased Token” and a mint confirmation beside the Pending or Failed status.
This PR adds direct token purchases funded by shielded credit notes, from the Rust wallet through the C binding to SwiftExampleApp. PR Hygiene and the PastaClaw review are pending; the reported checks show no failed code check and do not record a linked or executed Swift purchase. One verified nitpick was omitted under the ten-comment cap.
🔴 7 blocking | 🟡 3 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); 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 spend path inoperations.rsand fee calculation innote_selection.rsdirectly govern funds movement through fee-aware note reservation, transaction construction, broadcast, and settlement on success or failure. - 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) - 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/operations.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/operations.rs:1847-1863: A token-pool balance proof can confirm a purchase that did not execute
Impact: A buyer can see “Purchase complete” and lose access to credit notes in the wallet even though those notes remain unspent and no tokens were minted for the purchase.
A valid balance snapshot for an existing token pool is enough for this branch to mark the activity Confirmed, persist the selected notes as spent, and retire their recovery record. The wait request names the transition hash, but Drive verifies only `VerifiedTokenShieldedPoolBalance(token_id, balance)`: the proof binds neither the fee nullifiers nor the minted output. The type 22 analogy does not hold because its proof checks the submitted credit nullifiers. Keep the purchase pending on a balance snapshot alone and return the existing unconfirmed result across FFI. Use verified evidence tied to this purchase, such as inclusion of its exact fee-bundle change commitment in the credit-pool scan, and distinguish input consumption from evidence of minting. Test that a valid pool snapshot with unspent inputs neither confirms the row nor finalizes the notes.
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/operations.rs:1782-1805: Purchases outside the wire or token-count limits can leave notes stuck in recovery
Impact: A buyer whose payment needs four notes, or an SDK caller who supplies an above-limit raw count that the wallet can fund, can pay the proving cost and have notes held for a purchase that cannot execute.
These purchases can be proved and journaled before a known limit is enforced. With four notes, the two- and four-action Orchard proofs alone take 19,072 bytes; the six serialized actions push the purchase over 20,480 bytes even before the remaining fields. Selection checks funds and fees, not wire size or the versioned action cap. The SDK rejects the oversized request locally after recovery is armed, but the wallet's delivery classifier does not recognize that size error as never sent. Separately, the public API lets counts above `MAX_DISTRIBUTION_PARAM` reach a builder that only checks against `i64::MAX`; zero is rejected only after reservation and an anchor query. Reuse DPP's count and bundle limits before proving, and check the exact signed wire size before saving recovery. Keep zero price distinct from zero count. Test the three-to-four-note boundary and invalid counts, including that rejection does not leave a reservation or recovery record.
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/operations.rs:1752-1763: The wallet can reserve credits for a purchase the network version cannot accept
Impact: A funded buyer on a pre-PV14 network, or a buyer using an SDK pinned to PV14 after a PV15 upgrade, can wait for proving and have notes held for recovery instead of receiving a local version error.
The purchase starts with note selection rather than a network compatibility check. Drive-ABCI rejects type 28 below PV14, and the SDK broadcast requirement table has no type 28 entry. A minimum-version check alone is not enough: the SDK can verify a PV15 anchor response while retaining a PV14 construction pin, and the builder then omits the fee-bundle commitment that PV15 requires in the token-bundle signature. An endpoint refusal after dispatch is treated as potentially delivered, so recovery keeps the notes. Register the PV14 activation requirement using the SDK preflight and redrive pattern from #6051, and check the signing generation against the verified network version before proving. Test that pre-activation and incompatible-pin cases fail locally, while matching PV14 and PV15 cases proceed.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/operations.rs:1765-1774: Exported diagnostics reveal shielded input and change values
Impact: Anyone who receives a buyer's diagnostic archive can learn the total value of the selected notes and the intended change, even if the purchase failed before broadcast.
The INFO event records `total_input` alongside the agreed price and fee, enough to derive the intended change and, for a single-input purchase, the exact value of that private note. SwiftExampleApp enables Rust file logging at INFO, and `LogExporter` copies complete session directories without redacting these fields. Log the operation stage and outcome without note values or unnecessary transaction-identifying fields, including in the success event.
In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenActions/TokenPurchaseActionView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenActions/TokenPurchaseActionView.swift:299-305: Shielded Buy is enabled for direct-sale tokens that have no shielded pool
Impact: A funded buyer can select shielded payment for an ordinary direct-sale token, wait for proving, and have credit notes held pending recovery even though the token cannot be minted into a pool.
A price and a positive shielded credit balance enable Buy, but neither says the selected token supports shielded purchases. The Rust operation also goes straight to note selection, while Drive's `resolve_pooled_token` rejects configurations for which `has_shielded_pool()` is false. Have the Rust wallet read the verified token configuration and check the existing DPP accessor before reserving notes. Expose that result to the form so it can keep identity funding available without offering an impossible shielded purchase. Keep an unreadable configuration distinct from a disabled pool, and test a priced token with no pool.
In `packages/rs-platform-wallet/src/wallet/platform_wallet.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/platform_wallet.rs:2085-2091: An in-flight purchase can recreate activity after its wallet is removed
Impact: A host that removes a wallet while a shielded purchase is waiting for a result can receive a new activity write for the removed wallet after teardown.
Removal can purge the wallet's shielded store while the detached purchase still holds the wallet, coordinator, and persister. When settlement resumes, `record_activity_status` finds no stored row, falls back to the captured pending row, and saves and queues it again. The retained `Arc`s keep the objects alive but do not keep that generation registered. In the Rust purchase entry point, take the generation payment guard, verify that the generation is current, and hold the guard through settlement, as the private-contact payment path does. Test both orderings: removal wins before the guarded call, and removal is requested while the result is pending.
In `packages/rs-platform-wallet-ffi/src/shielded_send.rs`:
- [BLOCKING] packages/rs-platform-wallet-ffi/src/shielded_send.rs:1501-1503: Immediate recovery after an unconfirmed purchase depends on which API was called
Impact: After the same ambiguous purchase result, a Swift or C caller can trigger an immediate rebroadcast pass, while a direct Rust caller has to wait for another sync or request one itself.
The new C export does more than map the purchase result. `poke_sync_on_unconfirmed` classifies wallet errors, looks up the sync manager, and schedules `sync_now(true)`, which can rebroadcast the saved purchase. The direct Rust entry point makes no such request. The book assigns sync orchestration and retry decisions to `rs-platform-wallet`; reusing an existing FFI helper does not make this policy marshalling. Move the recovery trigger into Rust manager orchestration, use the existing serialized sync path, and leave the export to forward arguments and map the result.
In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedActivityView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedActivityView.swift:317-326: Pending and failed activity details tell the buyer that tokens were minted
Impact: A buyer inspecting an unresolved or failed purchase sees “Purchased Token” and a mint confirmation beside the Pending or Failed status.
The token ID identifies what the buyer intended to buy, not what executed: the wallet records it before broadcast, and the detail section checks only the kind tag and the ID length. This remains wrong even after the Rust confirmation path is fixed. Show the token ID and intended destination in neutral language, and reserve completed-mint wording for a purchase with a verified outcome.
In `packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md:294-297: The purchase test reuses IDs that now identify different flows on the target branch
Impact: QA would have two meanings for SH-21 through SH-23 after conflict resolution, making the parity manifest's purchase test reference ambiguous.
The purchase verification must point to one test. Target commit `5d14854adf` already uses SH-21 for shielding from an identity, SH-22 for topping up an identity, and SH-23 for restart recovery. The head also conflicts with the target in the parity manifest, generated Kotlin parity summary, and Swift test plan. Allocate unused IDs for the purchase and its follow-ups, update cross-references and the manifest, and regenerate the parity summary with both branches' capabilities present.
In `packages/rs-platform-wallet/src/wallet/shielded/activity.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/activity.rs:126: Existing exhaustive Rust matches stop compiling when clients upgrade platform-wallet
Impact: Rust consumers that exhaustively match `ShieldedActivityKind` or `ShieldedFeeKind` must handle a new variant before they can rebuild.
Appending `TokenPurchase` preserves the old persisted tags and does not break the C ABI, but both Rust enums are public and neither is `#[non_exhaustive]`. The PR's breaking-changes section calls the change entirely additive. Document the two new match cases as a Rust source-compatibility change; this does not require a Platform protocol bump.
25af9d6 to
4d450a2
Compare
|
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
Changes requested: 2 blockers
- A purchase stays Pending after another device spends its only input —
packages/rs-platform-wallet/src/wallet/shielded/operations.rs:2075-2077(new)
Impact: A buyer using the same wallet on two devices can be told not to retry a purchase that can no longer execute, even after a complete sync and restart. - The wallet can reserve credits for a purchase the network version cannot accept —
packages/rs-platform-wallet/src/wallet/shielded/operations.rs:1905-1912(thread, carried)
Impact: A funded buyer whose wallet last verified PV14 can have credit notes held in recovery even after the purchase itself learns that the network has upgraded to PV15.
New on this head: The rebased revision adds wallet-side preflight checks and Rust-managed follow-up sync for shielded token purchases. A token-pool balance proof now leaves the purchase Pending, and Swift offers shielded funding based on Rust’s availability result and reports submission rather than minting. The Swift frozen-schema check, Rust wasm32 tests, JS build and package tests, and Kotlin emulator tests passed; Rust workspace tests are still pending.
🔴 2 blocking | 🟡 4 suggestion(s)
Still open from earlier rounds (1)
- 🔴 Blocking: The wallet can reserve credits for a purchase the network version cannot accept —
packages/rs-platform-wallet/src/wallet/shielded/operations.rs:1905-1912(thread)
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 new purchase flow in rs-platform-wallet's shielded/operations.rs changes how real funds move by selecting and reserving credit notes, broadcasting a shielded spend, and keeping the reservation pending until shielded sync confirms it. - 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) - 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 (
25af9d68): 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— 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/operations.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/operations.rs:2075-2077: A purchase stays Pending after another device spends its only input
Impact: A buyer using the same wallet on two devices can be told not to retry a purchase that can no longer execute, even after a complete sync and restart.
The losing purchase has no path to a terminal status. A buyer can tap Buy on one device while a spend from another device using the same restored wallet consumes the sole selected note. Reservations are local, and a refusal after dispatch leaves the purchase Pending. This revision now relies on scan reconciliation to settle purchases: the verified scan calls `mark_spent` for the shared nullifier, which clears the reservation and deletes the redrive record. The other spend does not contain this purchase’s change commitment, so activity derivation cannot confirm the purchase. `release_stranded_spends` also skips it because it no longer has a matching reservation, even after the anchor expires. Reconcile Pending purchases using both the stored input nullifiers and the expected change commitment. A complete verified scan that covers the input spend can distinguish a competing spend from the purchase landing; an incomplete scan must not mark it Failed.
_Confirmed by an independent pass: A user taps Buy with Shielded pool while another device restored from the same seed spends the one note selected for the purchase; the reservation is local, so the other spend can land first. The purchase is rejected for the spent nullifier, but the post-dispatch refusal leaves its activity Pending. Even after a complete verified sync and anchor expiry, Shielded Activity still shows a purchase that can never execute as Pending and tells the user the next sync will confirm it._
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/operations.rs:9787-9800: The settlement test can pass when the scan cannot confirm a purchase
Impact: A change that keys purchase activity by the minted token note instead of the credit change note could leave successful purchases Pending without failing this test.
The test proves that a pool-balance result leaves the row Pending, but it supplies the activity row by hand and uses identical placeholder actions in both bundles. It bypasses the production recorder and never feeds the credit change into scan reconciliation. Add an offline round-trip with distinct wallet-decryptable outputs in the two bundles, using the real builder or a fixed fixture. Record the row through the live path, scan only the fee-bundle change, and assert that the same row becomes Confirmed. An exact-price-plus-fee input also covers zero-valued change.
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/operations.rs:1905-1912: The wallet can reserve credits for a purchase the network version cannot accept
(carried; thread: https://github.com/dashpay/platform/pull/6090#discussion_r4660233969)
In `packages/rs-platform-wallet/src/wallet/shielded/note_selection.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/note_selection.rs:82-84: The purchase note limit can drift when Orchard changes proof size
Impact: After an Orchard update changes the proof length, the wallet could accept an oversized purchase or reject one that fits while its size test still passes.
The constants are correct for the current pin, but both wallet sizing and its synthetic test use the same local copy of Orchard’s formula. The pinned Orchard revision exposes `Proof::expected_proof_size(actions)` and tests it against the circuit output. The pinned `grovedb-commitment-tree` already re-exports `Proof`, so use that API to size the placeholder proofs without adding a dependency. Keep the three-versus-four-note test for the wallet’s wire-size decision.
In `packages/rs-platform-wallet-ffi/src/shielded_send.rs`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/shielded_send.rs:1570-1574: A worker panic in the availability check aborts the C host
Impact: On an unwind-enabled build, a host checking whether shielded funding is available loses the process if the query worker panics, even though no purchase was attempted.
`block_on_worker` calls `.expect("tokio worker panicked")` on the join result, and this new `extern "C"` export has no guard to catch the resulting unwind before the ABI boundary. Wrap the read-only export with `catch_panic_to_code` and return `ErrorWalletOperation`, as `platform_wallet_preview_data_contract_update` does. A spend-unconfirmed result would incorrectly imply a broadcast might have happened. This protection applies to unwind-enabled builds, not iOS profiles built with `panic = "abort"`.
In `packages/rs-dpp/src/state_transition/state_transitions/shielded/token_purchase_from_shielded_pool_transition/v0/state_transition_validation.rs`:
- [SUGGESTION] packages/rs-dpp/src/state_transition/state_transitions/shielded/token_purchase_from_shielded_pool_transition/v0/state_transition_validation.rs:40: The count-rule refactor has no regression test for shipped PV14
Impact: Maintainers reviewing a future edit to the shared count predicate have no test pinned to the shipped validation boundary.
The refactor is consensus-inert: the new predicate’s negation is exactly the old rejection condition, and validation order and error construction are unchanged. But the V0 structure tests run at `PlatformVersion::latest()`, while stable `v5.0.0` shipped PV14. The book’s in-place-edit checklist calls for a test at the last shipped version and a record of why the edit is inert. Exercise zero, the maximum, and one above it at `PlatformVersion::get(14)`, and record the equivalence at the edit and in the PR’s “In-place changes to shipped generations” section. No dispatcher or version-table change is needed.
Out-of-scope follow-up suggestions (1)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- Shared shielded activity logs can link a wallet to an on-chain output — The unchanged shared activity recorder logs
entry_idat INFO. For a row with one visible output, that ID is the SHA-256 of its public note commitment. A recipient of an exported diagnostic archive can match it to the chain. The purchase already used this recorder on the prior reviewed head.- Follow-up: Open a wallet privacy follow-up to remove chain-linkable activity identifiers from exported diagnostics across shielded operations.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
4d450a2 to
861b79d
Compare
|
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
Changes requested: 3 blockers
- A successful purchase can show as Failed when its fee actions span two scan chunks —
packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs:2922-2923(new)
Impact: A buyer can see “no tokens were minted” for a purchase that landed and pay again by retrying with other notes before the next sync corrects the row. - A failed multi-note purchase keeps its untouched notes reserved —
packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs:2553-2561(new)
Impact: When another device spends one input of a pending purchase, the buyer sees Failed but cannot spend the untouched credits while the original anchor remains recorded. - The wallet can reserve credits for a purchase the network version cannot accept —
packages/rs-platform-wallet/src/wallet/shielded/operations.rs:1907-1911(thread, carried)
Impact: A buyer using an SDK pinned to PV14 can have credits held for recovery after a PV15 upgrade even though the purchase itself verified that PV15 is active.
New on this head: The four new commits add coverage for the shipped PV14 count rule and zero-value purchase change, reconcile displaced shielded spends, use Orchard’s proof-size API, and guard the availability read against unwinding across the C ABI. Rust workspace and wasm32 tests, the JS build and test suites, and the Kotlin SDK build and tests passed; the Swift SDK build and tests and review checks were still pending.
🔴 3 blocking
Still open from earlier rounds (1)
- 🔴 Blocking: The wallet can reserve credits for a purchase the network version cannot accept —
packages/rs-platform-wallet/src/wallet/shielded/operations.rs:1907-1911(thread)
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 new purchase flow inwallet/shielded/operations.rs, together with changes innote_selection.rsandcoordinator.rs, introduces intricate funds-movement logic that selects and reserves shielded credit notes, broadcasts the spend, and reconciles it during sync. - 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) - 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 (
4d450a25): 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
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:2922-2923: A successful purchase can show as Failed when its fee actions span two scan chunks
Impact: A buyer can see “no tokens were minted” for a purchase that landed and pay again by retrying with other notes before the next sync corrects the row.
A normal follow-up sync can persist Failed for a purchase that already minted tokens. The SDK fetches adjacent note ranges concurrently and verifies each response at its own height. When the fee bundle crosses a range boundary, the first response can prove the action revealing the input nullifier at height H while the next response proves an empty range at H−1. Orchard shuffles spends and outputs separately, so the wallet’s change can be in the second range. Both responses pass verification, and stream exhaustion lets the wallet publish the spent mark even though `covered_height` does not establish coverage through H. This predicate ignores that distinction and treats the missing change as proof of displacement. Keep the row Pending until the wallet proves a different spend or has contiguous coverage through the height that proved the input spent. Add a test where the first pass ends normally without that coverage and the next pass confirms the original row.
_Confirmed by an independent pass: After a user submits a shielded token purchase that lands at height H, the follow-up sync can verify the range containing its spent input at H and an empty adjacent range at H−1, before the purchase's change existed. If the fee bundle straddles that range boundary, the wallet persists Failed and shows it in Shielded Activity even though the purchase minted the tokens._
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs:2553-2561: A failed multi-note purchase keeps its untouched notes reserved
Impact: When another device spends one input of a pending purchase, the buyer sees Failed but cannot spend the untouched credits while the original anchor remains recorded.
A buyer can reserve two notes on one device for a purchase while a smaller payment on another device restored from the same seed uses only the larger note. When that payment lands, `mark_spent` clears the consumed note’s reservation and drops the purchase’s entire redrive record, but leaves the other reservation in place. The new branch saves Failed without releasing that note. Both note selection and spendable balance still exclude it, and `release_stranded_spends` skips it while the anchor is recorded. Once displacement is proved, release only the reservations that still belong to that activity under the same store write lock, and take the balance snapshot afterward. Test that the untouched note is immediately selectable, the consumed note remains spent, and another attempt’s reservation is not cleared.
_Confirmed by an independent pass: A user submits a shielded token purchase that reserves two notes and gets an unconfirmed result after broadcast, while a smaller payment from a second device restored from the same seed lands using only the larger note. The next sync marks the purchase Failed but leaves the untouched note reserved, understating the spendable balance and preventing the user from spending that note while the purchase's anchor remains recorded._
In `packages/rs-platform-wallet/src/wallet/shielded/operations.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/operations.rs:1907-1911: The wallet can reserve credits for a purchase the network version cannot accept
(carried; thread: https://github.com/dashpay/platform/pull/6090#discussion_r4660233969)
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
861b79d to
af4a5f4
Compare
|
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 |
10787d0 to
1b38910
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.
Re-review — Final validation — Phase 1 + Phase 2
New on this head: This revision removes scan-based failure inference for shielded spends and updates the purchase flow to distinguish submission from confirmation. The wallet still confirms a purchase when a scan finds its fee-bundle change. Rust workspace tests and the JS build were pending at review time, with no failed code checks reported.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(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.
Follow-up candidates (optional) (1)
New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.
🟡 Suggestion: The SDK promises a result on the next sync even when a purchase stays Pending
Impact: A buyer whose only input was spent by another device can see an SDK error promising resolution on the next sync even though the purchase remains Pending.
packages/rs-platform-wallet/src/error.rs:1161-1163
Callers that display the SDK error set an expectation the wallet cannot meet. This revision removes the scan-based displacement rule, so observing only a competing spend can clear the sole reservation and saved transition without settling the purchase row. After a possibly delivered broadcast, settle_failed_spend can return ShieldedSpendUnconfirmed; map_spend_result forwards its text through C, and Swift preserves it. The example app now avoids promising a result on the next sync. Keep the do-not-resubmit guidance, but remove that promise from the shared error text, its Rustdoc, and the equivalent SPEND_PANIC_GUIDANCE. That wording change does not require implementing #6108.
"Shielded {operation} was submitted but its execution result could not be \
confirmed; it may already have executed on chain — do not re-submit: {reason}"
source: gpt-6.2-astra (phase2-reviewer: general, architecture-layering, ffi-engineer, platform-versioning, rust-quality, security-auditor)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); 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 purchase flow in wallet/shielded/operations.rs and the changes in wallet/shielded/note_selection.rs implement a multi-step funds movement path that selects and reserves shielded credit notes, accounts for fees, and builds a version-specific shielded spend. - 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) - 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 (
10787d03): 1 suggestion(s) on unchanged code listed as follow-up candidates - 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 |
Adds a wallet operation and FFI entry point for TokenPurchaseFromShieldedPool: the account's credit pool notes pay the agreed price plus the pool-paid fee, and the tokens are minted as a note to the account's own address in the token's shielded pool. Adds the TokenPurchase fee kind (also fee estimate kind 5) and activity kind (tag 10), and accepts type 28 in saved recovery records. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d pool Adds a "Pay with" choice (identity credits or shielded pool) to the Direct Purchase screen, a thin Swift wrapper over the new FFI entry point, a Token Purchase row in shielded activity, test plan rows SH-24 to SH-27 and the parity manifest capability. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…g and check it before reserving notes A token purchase from the shielded pool (type 28) is answered with a proof of the token pool's balance, which binds neither the notes it spent nor the tokens it minted. An accepted purchase is no longer confirmed or finalized from it: it stays pending, its notes reserved and its recovery record saved, and the shielded sync confirms it when it finds the fee bundle's change note. The operation returns ShieldedTokenPurchaseOutcome::Submitted. Before any note is reserved, the purchase now refuses a token count basic structure refuses (0 or above MAX_DISTRIBUTION_PARAM), a network or SDK below protocol version 14 (type 28 is registered with the SDK's broadcast gate), an SDK whose version is not the verified network version (the PV15 fee binding would not match), a token without a shielded pool or whose configuration cannot be read, and a purchase needing more than the three notes that fit the 20,480-byte transition limit. The wallet's generation payment guard is held from the liveness check through settlement. A manager-level ShieldedTokenPurchaser runs the purchase and requests the shielded sync on a submitted or unconfirmed outcome, so the FFI export only forwards arguments. A new availability query (and FFI export) tells a form whether the token can be bought from the shielded pool. INFO logs carry the stage and outcome only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nswer and report it as submitted The Direct Purchase form asks Rust whether the token can be bought from the shielded pool and offers the Shielded pool choice only then, saying why otherwise; identity funding stays available. A shielded purchase that returns is reported as submitted, confirmed by the next shielded sync. The Token Purchase activity detail shows the token id and "Tokens to: this wallet's shielded token pool", and says the tokens were minted only once the row is Confirmed. Adds the availability wrapper, updates SH-24 and the parity manifest. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The wallet's early refusal of a token count now asks DPP's is_valid_token_count, which the transition's structure validation also uses, instead of repeating the bound. Behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…sion 14 Exercises token counts 0, MAX_DISTRIBUTION_PARAM and MAX_DISTRIBUTION_PARAM + 1 through validate_structure at the shipped protocol version 14, and notes at the check that the predicate's negation is exactly the condition it replaced, so moving the rule into is_valid_token_count changed nothing that version accepts or rejects. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…er spend consumed A live spend left pending (an accepted token purchase, or any spend whose result could not be read) stayed Pending forever once another spend of one of its inputs landed, as from a second device on the same seed: the scan's mark_spent dropped its reservation and recovery record, the competing spend carries none of its outputs so activity derivation never confirmed it, and the anchor-prune release no longer saw a reservation. After a complete scan, activity reconciliation now marks Failed every pending live spend row one of whose inputs is spent while none of its wallet-visible outputs (at least the credit change every spend carries) was observed. The scan sees a transition's input nullifiers and outputs in the same pass, so the spend's own landing still confirms it. This applies to every live spend kind, not only token purchases. Also records the token purchase row through record_pending_token_purchase, which an offline round trip now drives with a transition the real builder proves: the row is keyed by the fee bundle's zero-valued change alone, and scanning only that change confirms it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…expected_proof_size The note-count bound for a shielded token purchase now takes each proof's length from the pinned Orchard's Proof::expected_proof_size, through the grovedb-commitment-tree re-export, instead of a local copy of the formula. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lity read off the C ABI platform_wallet_manager_shielded_token_purchase_availability now runs under catch_panic_to_code with ErrorWalletOperation, as the other read-only exports do, so a panic in the read or the worker join cannot unwind across the extern "C" frame. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…its spend, and free its other notes The note scan fetches adjacent position ranges concurrently and verifies each at its own height, so one pass can see the action revealing an input's nullifier at height H while the next range, proved at H-1, ends before the spending transition's outputs. Such a pass marks the input spent without having seen the change, and a pending spend that did land could be marked Failed. The scan now reports, per subwallet, the lowest batch height it saw each owned nullifier at, and the coordinator keeps that with the highest height a scan proved covered. A pending spend is judged displaced only when an input was seen spent at or below a covered height and none of its outputs was observed; otherwise it stays pending for a pass that covers the spend. The evidence is kept in memory, so after a restart such a row stays pending rather than being failed on unproved evidence. A displaced multi-note spend also released only the consumed note: its other inputs stayed reserved with no record left to resolve them. Under the same store lock the derivation now releases each reservation still carrying the displaced activity, never another attempt's, and the pass reads its balances after the derivation so they count the freed notes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… every network read The contract fetch and the recorded-anchor read could raise the network version the SDK knows after the signing version was chosen, so the purchase built and signed with the table it captured earlier. The purchase now fetches the contract and the recorded anchor set first, then checks the signing version, then reserves notes and selects their witnesses locally against the anchor set already read: nothing after the check asks the network, and a mismatch is refused with nothing reserved, saved or recorded. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Takes the scan-based displacement of pending spends out of this change: the coordinator no longer keeps spend evidence, marks a pending spend Failed when another spend of one of its inputs lands, or releases that spend's other reservations, and the note scan no longer reports spend heights. The coordinator's production code and sync.rs are back to the base branch; a pending spend that another device on the same seed displaced stays pending, as it did before, a known limitation of every spend kind that is tracked separately. A pending token purchase is confirmed when a scan finds its change once it lands, and otherwise stays pending. The two tests that show it are kept: a scan that finds the row's change confirms it, and the offline round trip of a purchase built by the real builder confirms its row from the fee bundle's zero-valued change. Docs, the app's copy, SH-24 and the parity manifest now say a shielded sync confirms the purchase once it lands, rather than promising the next sync resolves it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1b38910 to
c216f16
Compare
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
Basic explanation
SwiftExampleApp's Direct Purchase screen can now pay from the wallet's shielded balance instead of the identity's credits, using
TokenPurchaseFromShieldedPool(state transition type 28). The wallet's credit pool notes pay the price and a fee. The tokens are minted as a note to the wallet's own address in the token's shielded pool. No identity is involved.Before: the only option was "Direct purchase debits credits from this identity".
After: when Rust reports that the token has a shielded pool, a Pay with control offers Identity credits (unchanged) or Shielded pool. The shielded option shows the shielded balance, the pool fee estimate and price plus fee. A purchase that Platform accepts is reported as submitted, and a shielded sync confirms it once it lands.
This is the first of the three shielded token transitions (26, 27, 28). The other two are left out on purpose (see below).
Issue being fixed or feature implemented
Types 26 (
TokenShieldedTransferWithShieldedFee), 27 (TokenUnshieldWithShieldedFee) and 28 (TokenPurchaseFromShieldedPool) have DPP builders and Drive handling. Nothing below the Rust libraries used them: there was no wallet operation, FFI, Swift or UI.They are active in protocol version 15. They have been allowed since PV14 (
TOKEN_SHIELDED_POOL_INITIAL_PROTOCOL_VERSION = 14), and #5969 changed the token bundle to bind the fee bundle's commitment from PV15 (v15.rs note 47). The marketplace move to PV16 (#5910) did not include them. No open PR or issue covered client support.Why only type 28:
platform-walletsyncs only the credit shielded pool; it tracks no token-pool notes, anchors or nullifiers. Types 26 and 27 spend token-pool notes, so they need a token-pool note sync first. Type 28 spends only credit-pool notes, which the wallet already has.Left for follow-ups:
poke_sync_on_unconfirmed). This PR moves only the purchase's request into Rust.What was done?
rs-dppTokenPurchaseFromShieldedPoolTransitionV0::is_valid_token_countholds the token-count bound in one place. The transition's structure validation and the wallet's early refusal both call it. Behaviour is unchanged (see "In-place changes to shipped generations").rs-sdktoken_purchase_from_shielded_pool_requirement()(protocol 14) is registered intransition_protocol_requirement. A broadcast or redrive of type 28 is therefore refused locally before activation, using the preflight pattern from feat: shield from an identity and top up an identity from the shielded pool in SwiftExampleApp #6051.rs-platform-walletoperations::token_purchase_from_poolandPlatformWallet::shielded_token_purchase_from_pooldo the whole purchase in Rust. Before reserving any note they check, in order:has_shielded_pool(), and the recorded anchor set.After every network read, the signing generation: the SDK's version must equal the verified network version, because PV15 adds the fee-bundle binding.
Proof::expected_proof_size.After those checks they reserve notes for price plus fee, build at the checked version, record activity, broadcast with redrive, and settle.
Settlement: type 28's proof is only the token pool's balance, which binds neither the fee nullifiers nor the minted note. An accepted purchase therefore stays pending: the row stays Pending, the notes stay reserved and the recovery record stays. The result is
ShieldedTokenPurchaseOutcome::Submitted. The credit-pool scan confirms it when it finds the fee bundle's change note, which the activity entry is keyed by, and the nullifier sync marks the notes spent.Wallet removal: the purchase holds the wallet generation payment guard through settlement, so removing a wallet waits for a purchase in flight, and a purchase on a removed wallet is refused.
Follow-up sync:
PlatformWalletManager::shielded_token_purchaserruns the purchase and requests a shielded sync itself when the outcome is submitted or unconfirmed.token_shielded_purchase_availabilityanswers whether the form may offer the shielded option: available, no shielded pool, or configuration unreadable.New kinds:
ShieldedFeeKind::TokenPurchase(fee estimate kind 5) andShieldedActivityKind::TokenPurchase(tag 10, counterparty = token id).Saved recovery records accept type 28.
INFO logs carry the stage and outcome only, with no note values.
rs-platform-wallet-ffiplatform_wallet_manager_shielded_token_purchase_from_pool(...)andplatform_wallet_manager_shielded_token_purchase_availability(...)only marshal the arguments and map the result. Both stop a Rust panic before it reaches the C caller.platform_wallet_shielded_estimate_feeaccepts kind5.Swift SDK / SwiftExampleApp
shieldedTokenPurchaseFromPool(...),shieldedTokenPurchaseAvailability(...)andShieldedFeeKind.tokenPurchaseFromPool.TokenPurchaseActionViewoffers the shielded choice only on Rust's "available" answer. Otherwise it explains why, with Retry when the configuration couldn't be read.TEST_PLAN.mdadds SH-24 (purchase, implemented, not yet run on a device or simulator) and SH-25 to SH-27 (not implemented).docs/sdk/sdk-parity-manifest.jsonaddsshielded.token_purchase_from_pool(Swift partial, Kotlin unsupported), andPARITY_SUMMARY.mdis regenerated.Public interface changes
platform_wallet_manager_shielded_token_purchase_from_pool(...),platform_wallet_manager_shielded_token_purchase_availability(...)(0 available, 1 no pool, 2 unreadable)platform_wallet_shielded_estimate_feekinds 0 to 4kindTagPlatformWalletErrorShieldedTooManyNotes,ShieldedProtocolVersionMismatch,TokenShieldedPoolDisabled,TokenConfigurationUnavailableShieldedTokenPurchaseOutcome,ShieldedTokenPurchaseAvailability; new variantsShieldedFeeKind::TokenPurchase,ShieldedActivityKind::TokenPurchasetoken_purchase_from_shielded_pool_requirement()shieldedTokenPurchaseFromPool(...),shieldedTokenPurchaseAvailability(...),ShieldedFeeKind.tokenPurchaseFromPoolSource compatibility (Rust):
ShieldedFeeKind,ShieldedActivityKindandPlatformWalletErrorare public and not#[non_exhaustive]. Rust code that matches them exhaustively must add the new variants before it compiles again. The persisted tags and the C ABI are unaffected, and there is no protocol change.In-place changes to shipped generations
TokenPurchaseFromShieldedPoolTransitionV0::validate_structure(structure validation v0, selected by shipped PV14) now asks!Self::is_valid_token_count(self.token_count)instead ofself.token_count == 0 || self.token_count > MAX_DISTRIBUTION_PARAM. The new predicate istoken_count != 0 && token_count <= MAX_DISTRIBUTION_PARAM, so its negation is exactly the old condition. The order of checks and the error built (InvalidTokenAmountError(MAX_DISTRIBUTION_PARAM, token_count)) are unchanged, so no transition is accepted or refused differently.should_bound_the_token_count_at_the_shipped_protocol_versionpins this atPlatformVersion::get(14): counts 0 and max + 1 are refused, and max is accepted.How Has This Been Tested?
cargo fmt --all: clean.cargo test -p platform-wallet --features shielded --lib -- token_purchase pending_spend: 26 passed. They cover:should_confirm_a_built_token_purchase_from_its_fee_bundle_changebuilds a type 28 from a note worth exactly price plus fee (zero-valued change), records it through the live path, scans only the fee-bundle change, and sees the row become Confirmed.cargo test -p platform-wallet --features shielded --lib -- shielded::coordinator shielded::activity shielded::sync: 82 passed .cargo test -p platform-wallet-ffi --features shielded --lib token_purchase(4 passed) and the fee estimate tests.cargo test -p dash-sdk --lib should_refuse_a_generic_broadcast: 3 passed.cargo test -p dpp --lib token_purchase_from_shielded_pool: 9 passed.cargo clippy --all-targets --all-features --locked -- --no-deps -D warningson dpp, dash-sdk, platform-wallet and platform-wallet-ffi: clean.python3 scripts/check_sdk_parity_manifest.py --write-summary: OK.xcodebuildof SwiftExampleApp compiled with no Swift errors. Link errors appeared only for symbols missing from the borrowed xcframework.Not tested: linking and running the app against a library built from this branch, and a real broadcast accepted by Drive. SH-24 in the test plan describes the manual run.
Breaking Changes
No protocol or consensus change, and no C ABI or persisted format change. The Rust items are additive, but see "Source compatibility (Rust)" above for exhaustive matches.
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 ·
c216f16/skip-botsproceeds without the ones not yet reported/self-reviewedsdk-parity— you own itkotlin-sdk(packages/kotlin-sdk/PARITY_SUMMARY.md) — HashEngineeringdpp— you own itrs-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.rs) — HashEngineering or ZocoLini or llbartekll or romchornyirs-platform-wallet(packages/rs-platform-wallet/src/error.rs,packages/rs-platform-wallet/src/manager/mod.rs,packages/rs-platform-wallet/src/manager/shielded_token_purchase.rsand 7 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 3 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.