Repository navigation
feat(platform-wallet): reserve DashPay payout addresses without Core funding - #4623
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change adds DashPay contact payment address reservation across wallet logic, FFI, and Swift SDK layers. It serializes contact-payment persistence, updates payment sending and rollback paths, and adds coverage for persistence and concurrency behavior. ChangesDashPay payment address reservation
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~45 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant ManagedPlatformWallet
participant DashPayFFI
participant DashPayView
participant WalletPersister
ManagedPlatformWallet->>DashPayFFI: reserveDashPayPaymentAddress
DashPayFFI->>DashPayView: reserve_payment_address
DashPayView->>WalletPersister: persist and flush consumed address
WalletPersister-->>DashPayView: persistence result
DashPayView-->>DashPayFFI: reserved address or error
DashPayFFI-->>ManagedPlatformWallet: address string or FFI error
Merge Risk: ⚪ Minimal · up to The reservation flow is mergeable based on the supplied evidence, with no actionable risk remaining. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
|
✅ Final review complete — no blockers (commit 5850e7c) |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 2 only (queue backlog)
Verified the supplied findings against the exact head and confirmed one nonblocking coverage gap: the new concurrency test checks progress during broadcast, but does not exercise overlapping pool persistence protected by the payment gate. No in-scope blocking defect was confirmed. The existing Swift persistence acknowledgement behavior is retained as a separate follow-up; independent validation here was source inspection and a passing diff whitespace check, not a rerun of the reported test suites.
Source: reviewer 1: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)
Review provenance
- Triage:
criticalbygpt-6-astra(effort low) — The change touches funds-related address derivation, durable address-consumption state, concurrent Core-send rollback ordering, seed verification, and Rust/Swift FFI ownership, where errors could cause address reuse, incorrect payment destinations, or wallet-state corruption. - Phase 1 reviewers: not run (skipped for throughput: 63 PRs queued, above the 10 limit)
- Fresh verifier:
gpt-6-astra— final-verifier; agentastra-verifier - Phase 2 reviewers:
gpt-6-astra— general (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— security-auditor (completed, effort xhigh); agentphase2-reviewer
🟡 1 suggestion(s)
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `packages/rs-platform-wallet/src/wallet/identity/network/payments.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/payments.rs:6194-6201: Exercise overlapping persistence to protect the new payment gate
The reservation completes its store and flush before this test releases the rejecting broadcaster. This verifies that reservation can proceed during broadcast and that the subsequent rollback preserves it, but does not exercise the stale-snapshot ordering that the new payment gate prevents. The default current-thread Tokio test and synchronous persistence callbacks do not overlap these snapshot/store sequences. Add a deterministic multithreaded test that pauses a pool store after snapshot capture, starts a competing reservation or rejection rollback, and verifies that the competing operation cannot persist ahead of the paused operation. Ensure the test fails when the corresponding gate acquisition is removed, so an older whole-pool snapshot cannot silently overwrite a newer reservation's used flag.
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.
- Make required address-pool persistence acknowledgements fail closed — PlatformWalletPersistenceHandler.swift:3559–3560 acknowledges a missing parent account for every account type except IdentityInvitation, and fetchAccount at lines 3763–3783 converts fetch failures into lookup misses. The address-pool callback consequently can return zero without staging a DashPay pool update, which the Rust persister treats as success. This deliberate tolerance for ordinary address sync predates the PR and already applies to Core-funded contact sends, but it can leave a payment-address used flag unpersisted and permit reuse after reload.
- Follow-up: Track a separate persistence-contract change that distinguishes required payment reservation writes from tolerant background synchronization, with Swift-backed failure-injection coverage for DashPay account lookup failures.
llbartekll
left a comment
There was a problem hiding this comment.
The design looks right to me: one shared derivation helper for Core sends and external payouts, a per-wallet gate that keeps pool snapshots ordered (released across the broadcast, re-taken for the rejection rollback), and store + flush before the address is ever exposed. Lock order is gate -> wallet-manager write lock at all three sites, the gate is a shared Arc on the once-per-wallet WalletPersister, and host persistence never runs under the manager guard. The Swift wrapper mirrors sendDashPayPayment including the extended-lifetime resolver and the string free.
Requesting changes for one thing only: the branch no longer compiles once merged into current v4.2-dev. The base bumped rust-dashcore (393b612 -> e4208c9) and Mnemonic::from_phrase now takes a single argument. Git merges this PR cleanly, but the three new tests still use the old two-argument form, so cargo test -p platform-wallet fails with 6 errors on the merge result (E0433 + E0061 at each site). PR CI is green only because it ran before the bump landed. With those three lines fixed the merged tree passes 63/63 payments tests, and clippy on both crates is clean for the touched files. Details inline. A rebase so CI runs on the current base would be good too.
Two non-blocking suggestions:
-
FFI wait pattern. Since this branch forked,
platform_wallet_pending_contact_crypto_countandplatform_wallet_drainable_contact_crypto_countwere changed to look the identity up under the registry guard andblock_on_workeroutside it, because waiting onwallet_managerinside the guard stallsplatform_wallet_destroyand every other registry reader. The newplatform_wallet_reserve_dashpay_payment_addressuses the older inside-the-guard shape. It is consistent with its siblingplatform_wallet_send_dashpay_payment, so not blocking, but this call also waits on the new payment gate and on host persistence, so it is a good candidate for the newer pattern while you are rebasing. -
The concurrent test does not exercise the gate.
reserve_payment_address_survives_concurrent_core_rejectionproves the reservation does not wait for the network broadcast and that the rollback snapshot preserves it, but on a current-thread runtime with synchronous persistence the snapshot-then-store sequences never interleave, so the test still passes withlock_contact_paymentsremoved. A multi-thread test that pauses a store after snapshot capture (e.g. a barrier inside the persister) and then starts a competing reservation would make the gate load-bearing in CI. Same point as the existing bot comment; happy for this to be a follow-up.
One pre-existing note, not caused by this PR: dashpay_account_registration_changeset in contacts.rs also persists a whole-pool snapshot of the external account and runs in the pre-gate drain. The window is tiny and only exists on first contact setup, so I would not hold this PR on it.
d7d0224 to
cadb566
Compare
|
Rebased onto
Local: 🤖 Posted autonomously by Codex on behalf of pasta. |
|
@thepastaclaw review No review for |
thepastaclaw
left a comment
There was a problem hiding this comment.
⚠️ DEGRADED — Re-review — Final validation — Phase 1 + Phase 2
⚠️ DEGRADED review. The primary review models were unavailable (gpt-6-astraunavailable: All credentials for model gpt-6-astra 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. 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.
Reserve-only DashPay payout reservation shares the Core-send pool behind a per-wallet gate with mutation-checked multithreaded coverage, and the FFI wait now runs outside the registry guard. Two in-scope suggestions remain: the gate is minted per persister handle rather than per wallet, and the new FFI entry nulls its out-param after the first null check.
🟡 2 suggestion(s)
Review provenance
Source: reviewer 1: gemini-3.8-flash-high (agent: phase1-reviewer, role: general); reviewer 2: gemini-3.8-flash-high (agent: phase1-reviewer, role: architecture-layering); reviewer 3: gemini-3.8-flash-high (agent: phase1-reviewer, role: ffi-engineer); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 5: muse-spark-1.3-contributor (agent: phase1-reviewer, role: security-auditor); reviewer 6: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: general); reviewer 7: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: architecture-layering); reviewer 8: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: ffi-engineer); reviewer 9: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: rust-quality); reviewer 10: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: security-auditor); reviewer 11: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: general); reviewer 12: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: architecture-layering); reviewer 13: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: ffi-engineer); reviewer 14: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: rust-quality); reviewer 15: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: phase2-reviewer, role: security-auditor); final verifier: muse-spark-1.3-contributor (standing in for gpt-6-astra) (agent: astra-verifier, role: final-verifier)
- Degraded mode:
gpt-6-astraunavailable: All credentials for model gpt-6-astra are cooling down (last error: usage_limit_reached: The usage limit has been reache (detected by probe, since 2026-09-18T05:22:01Z); 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; Phase 1 effort capped athigh - Triage:
criticalbymuse-spark-1.3-contributor(standing in forgpt-6-astra) (effort low) — Large intricate diff (+651/-98) adds DashPayView::reserve_payment_address in payments.rs changing HD address-pool derivation/consumption and used-flag persistence that directs where withdrawn funds go. - Phase 1 reviewers:
gemini-3.8-flash-high— general (completed, effort high); agentphase1-reviewer,gemini-3.8-flash-high— architecture-layering (completed, effort high); agentphase1-reviewer,gemini-3.8-flash-high— ffi-engineer (completed, effort high); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort high); agentphase1-reviewer,muse-spark-1.3-contributor— security-auditor (completed, effort high); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(lane failed),glm-5.3-flash(zai below 15% reserve: 5h 99% left, weekly 14% left) - Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
muse-spark-1.3-contributor(standing in forgpt-6-astra) — final-verifier; agentastra-verifier - Phase 2 reviewers:
muse-spark-1.3-contributor(standing in forgpt-6-astra) — general (completed, effort xhigh); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6-astra) — architecture-layering (completed, effort xhigh); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6-astra) — ffi-engineer (completed, effort xhigh); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6-astra) — rust-quality (completed, effort xhigh); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6-astra) — security-auditor (completed, effort xhigh); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6-astra) — general (completed, effort xhigh); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6-astra) — architecture-layering (completed, effort xhigh); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6-astra) — ffi-engineer (completed, effort xhigh); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6-astra) — rust-quality (completed, effort xhigh); agentphase2-reviewer,muse-spark-1.3-contributor(standing in forgpt-6-astra) — security-auditor (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `packages/rs-platform-wallet/src/wallet/persister.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/persister.rs:55-74: Contact-payment gate is per-persister-instance, not per-wallet
WalletPersister::new mints a fresh contact_payment_gate, so ordering holds only when every locker clones the same handle. Production PlatformWallet::new builds one handle and clones it, but payment_handler.rs:235 builds a second WalletPersister::new for the same wallet_id for event hooks, and tests do the same. Those instances never call lock_contact_payments today so there is no active race, but the per-wallet ordering this PR promises holds by accident of handle sharing rather than by construction: a future pool writer through a second handle would silently bypass reservation ordering. Centralize the gate with the per-wallet shared state that owns the pool (e.g. in the manager) or document that lockers must clone the wallet persister and never new() one.
In `packages/rs-platform-wallet-ffi/src/dashpay.rs`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/dashpay.rs:609-611: Null the string out-param before the signer null-check
platform_wallet_reserve_dashpay_payment_address nulls *out_address only after check_ptr!(core_signer_handle), so a null-signer call returns ErrorNullPointer leaving *out_address untouched. The documented contract (free only on success) and the Swift caller (nil-initialized) are safe, but a C cleanup-on-error caller that did not pre-initialize would free garbage. The file's own convention in platform_wallet_fetch_sent_contact_requests publishes the empty sentinel before any fallible work. Match it here.
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.
- Registration/teardown pool snapshots sit outside the new gate — dashpay_account_registration_changeset and the contact-rotation teardown/rebuild persist the same external-account pools without lock_contact_payments. Pre-existing first-setup/rotation-only window with privacy-only impact; author already scoped it as a follow-up.
- Follow-up: Track separately: route external-account registration/teardown persistence through the same per-wallet ordering primitive.
|
Bots are done — your move: address llbartekll requested changes, then post |
Pool snapshots are whole-pool and last-write-wins on the host, so two reservations interleaving as A: snapshot, B: snapshot, B: store, A: store would leave B's address unused in the persisted truth and a relaunch would re-hand it. The contact-payment gate holds each reservation from snapshot through store to forbid that ordering, but the existing tests ran on a current-thread runtime with synchronous persistence callbacks, so the snapshot/store sequences never overlapped and removing the gate acquisition left every test green. Add a multithreaded test whose persister parks the first external-pool store inside the host callback, after the snapshot is captured. A competing reservation must not complete while that store is parked, nothing may reach the host in the meantime, and the last persisted snapshot must carry both addresses. Waits are bounded so a regression fails instead of wedging the runtime. Dropping the gate acquisition in reserve_payment_address makes the competing reservation complete while the first is parked and fails the first assertion. Also adopt the one-argument Mnemonic::from_phrase from the rebase base. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… registry guard Look the identity up under the wallet registry guard and run the reservation on the worker outside it, the shape the base adopted for platform_wallet_pending_contact_crypto_count. The reservation waits on the wallet-manager write lock, the contact-payment gate, and the host store and flush, and a registry read guard held across those stalls platform_wallet_destroy and, through parking_lot's writer preference, every other registry reader. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…e signer check `platform_wallet_reserve_dashpay_payment_address` nulled `*out_address` only after `check_ptr!(core_signer_handle)`, so a null signer returned `ErrorNullPointer` with the slot untouched. Publish the null sentinel first, matching the file's other out-param entry points, and pin it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…g contract The gate lives on the `WalletPersister` handle, so ordering holds only for clones of the handle `PlatformWallet::new` builds. Say so on `lock_contact_payments`, and mark the incoming-payment hook's separately constructed handle as history-only. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
19e0b60 to
f689cd6
Compare
|
Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. Wait for the missing reviews, or a writer can post |
|
@thepastaclaw review No review for |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Verified the complete diff at f689cd6 and confirmed that all three prior findings are fixed. Two in-scope persistence issues remain: unsupported backends can report successful durable reservation, and store failures lose their typed classification; both are suggestions under the project's non-consensus severity policy. This was a static review: current CI reports Rust wallet tests passing, with Swift build/tests still pending.
🟡 2 suggestion(s)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 5: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The intricate changes in payments.rs to reserve_contact_payment_address, reserve_payment_address, and the existing Core send path alter payment destination derivation, durable address consumption, and concurrent broadcast-rejection rollback on a funds-movement surface. - 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: weekly 15% left, 5h 100% 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 final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `packages/rs-platform-wallet/src/wallet/identity/network/payments.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/payments.rs:1163-1165: Require durable contact-pool support before reserving an address
The new API promises that an exposed address remains consumed, but successful store/flush calls do not establish that guarantee for all supported backends. NoPlatformPersistence returns success while discarding the changeset, and FFIPersister silently skips account_address_pools when on_persist_account_address_pools_fn is absent; its flush also succeeds without a callback. Manager creation accepts these incomplete callback tables. With an external contact account already resident, reservation therefore returns an address whose used flag was never persisted. After restart and deterministic contact-account reconstruction, that destination can be issued again, including after cancellation or an unknown withdrawal outcome. Add a fail-closed preflight in this owning Rust method before the drain or pool mutation, requiring an attested contract for DashPay external-account/pool persistence and restart hydration. The existing ACCOUNT_ADDRESS_POOLS alias documents asset-lock funding semantics, so extend the capability contract if necessary rather than assuming it covers DashPay. Add native and incomplete-FFI-backend refusal coverage, including a null output address on the FFI error path.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/payments.rs:1177-1181: Preserve the typed cause of reservation store failures
Formatting the PersistenceError into PlatformWalletError::Persistence(String) discards its failure kind and source chain. The FFI conversion consequently reports these failures as ErrorUnknown instead of the existing transient, constraint, or fatal store codes, preventing native and host callers from distinguishing recovery paths without parsing text. Use WalletPersister::classify_store_failure to preserve the typed cause while enforcing the backend's retry-safety attestation, and update the injected-store-failure assertion to expect PersisterStore.
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.
- Serialize first-time external-account publication with pool snapshots — The unchanged register_external_contact_account path checks account absence, persists an initial unused pool, and only then acquires the manager write lock for insertion. Concurrent first-time registrations can both pass the check; a delayed initial snapshot can overwrite a used flag persisted after the competing registration completed. Swift's pool consumer assigns row.isUsed from each arriving snapshot, making restart address reuse a concrete risk. This sequence and its reachability through concurrent Core sends predate this PR.
- Follow-up: Track a separate issue or maintainer-requested PR for single-flight contact-account registration ordered with payment-pool persistence, with a deterministic overlapping-registration regression.
…ore failure `reserve_payment_address` formatted the store's `PersistenceError` into `PlatformWalletError::Persistence(String)`, dropping its kind and source chain, so the FFI reported every store failure as `ErrorUnknown`. Route it through `WalletPersister::classify_store_failure`, as `retry_pending_balance` does, so hosts get the transient / constraint / fatal store codes under the backend's retry attestation. The flush mapping stays a string, matching that same call site. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. 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
The shared allocator, payment gate, typed store-error propagation, and FFI ownership handling are consistent with the wallet architecture, and four prior findings are fixed. Two non-consensus correctness concerns remain: unpaid reservations can exceed the recipient's discovery window, and supported persistence backends can acknowledge reservations without preserving them across restart. This was a static review of the complete diff; the supplied exact-head CI snapshot still had build/test prerequisites queued or pending.
🟡 2 suggestion(s)
1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 6: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 7: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 8: gpt-6-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 9: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 10: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 11: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 12: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); reviewer 13: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 14: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 15: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 16: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 17: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The intricate changes in payments.rs to reserve_contact_payment_address, reserve_payment_address, and the Core send path alter payment destination allocation and its persistence and concurrent rejection rollback, directly affecting funds movement. - 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: weekly 15% left, 5h 100% 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 final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— general (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer - Model comparison: every Phase-2 reviewer also ran on
gpt-6-astra; the verifier weighed both sets without knowing which model wrote which
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `packages/rs-platform-wallet/src/wallet/identity/network/payments.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/payments.rs:1165-1173: Keep unpaid reservations within the recipient's discovery window
Reservation permanently advances the shared sender pool without requiring an on-chain payment or bounding the unpaid gap. I checked the exact pinned rust-dashcore commit, e4208c90786a6854bd498315bcb571ef24182c15: managed_account_type.rs initializes DashpayReceivingFunds with 20 addresses, account_checker.rs matches outputs against materialized scripts, and wallet_checker.rs maintains lookahead only after a matching transaction. For a fresh contact, 20 confirmed withdrawals that are subsequently canceled or rejected consume sender indices 0–19 without advancing the receiver. The next reservation, or a Core send through the shared allocator, selects index 20, which ordinary recipient synchronization does not discover. The prohibition on previews does not prevent this supported cancellation/rejection sequence, and persisting or extending the sender's pool cannot extend the receiver's pool. Preserve exposed-address consumption, but track observed-payment progress separately and prevent issuance beyond the receiver's discoverable window unless coordinated receiver advancement establishes safety. Add coverage with separate sender and receiver pools, unpaid reservations exhausting the initial window, and a subsequent payment. This is a client-wallet correctness suggestion under the project's non-consensus severity policy.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/payments.rs:1177-1185: Require durable contact-pool support before reserving an address
(existing thread: https://github.com/dashpay/platform/pull/4623#discussion_r4181960588)
The new endpoint still returns success without establishing its documented restart-safe consumption guarantee. NoPlatformPersistence explicitly discards changesets while acknowledging store and flush; FFIPersister skips account_address_pools when its callback is absent and also acknowledges a callback-free flush. With an external account already resident, reservation therefore succeeds without saving its used flag, and deterministic reconstruction can reissue the same exposed destination after restart. Swift also acknowledges missing DashPay parent accounts in persistAccountAddresses. Your explanation correctly rules out reusing ASSET_LOCK_FUNDING_INDICES: its contract is asset-lock-scoped, and existing host attestations do not establish DashPay durability. That establishes the need for a dedicated contract, not the correctness of unconditional durable success here. A reissued address still belongs to the same contact, but it breaks one-time destination privacy, particularly when a canceled or rejected withdrawal leaves no on-chain evidence of exposure. Before draining or mutating, require a truthful contact-account/pool persistence and restoration contract with fail-closed host callbacks; alternatively, explicitly distinguish session-only reservations rather than presenting them as durable. Cover native no-op and incomplete-FFI refusal, including a null output address. Coordinating the legacy Core-send contract can remain separate work; its existing limitation does not satisfy the new endpoint's guarantee.
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.
- Serialize initial external-account registration with contact-pool consumption — register_external_contact_account checks account absence under a read guard, then persists an initial unused pool before acquiring the insertion write guard. Concurrent first-time registrations can both pass the check, allowing a delayed initial snapshot to overwrite a subsequently persisted reservation's used flag. contacts.rs is unchanged by this PR, and this window already affects Core sends, so it is a separate restart-privacy follow-up rather than an in-scope finding.
- Follow-up: Track a separate issue or maintainer-requested PR ordering first-time external-account registration against pool mutation and persistence, with an overlapping-registration/store regression test.
|
@coderabbitai review No review for |
|
Bots are done — your move: post |
llbartekll
left a comment
There was a problem hiding this comment.
Re-reviewed at 5850e7c, merged locally onto current v5.1-dev (723b09e).
The blocking item from my last review is fixed: the three new tests use the one-argument Mnemonic::from_phrase, and the merged tree builds. Both non-blocking suggestions landed as well: the FFI entry point now looks the identity up under the registry guard and waits outside it, and reserve_payment_address_cannot_persist_ahead_of_a_paused_reservation makes the gate load-bearing on a real multi-thread runtime (first store parked inside the host callback, competing reservation proven unable to finish or reach the host until release).
What I checked on the merge result:
- Lock order is gate -> wallet-manager write lock at all three lockers (
reserve_payment_address,send_payment, the rejected-broadcast rollback); the drain runs before the gate; hoststore/flushnever run under the manager guard. - The gate's handle-sharing contract holds:
PlatformWallet::newbuilds oneWalletPersisterand clones it, the hook's second handle only writes payment history, and the only other external-pool snapshot writer is the pre-existing first-setup registration incontacts.rsthat we already agreed to leave for a follow-up. - Store failures surface as
PersisterStoreviaclassify_store_failure, so the FFI maps them to the typed transient/fatal/constraint codes; flush keeps thePersistence(String)shaperetry_pending_balanceuses. *out_addressis nulled before the signer null-check, and the Swift wrapper mirrorssendDashPayPayment(extended-lifetime resolver,platform_wallet_string_freeon the success path).- Locally on the merge result:
cargo fmt --checkandgit diff --checkclean; the fullplatform-walletunit suite passes (1194/1194). The FFI crate on base only changed a doc comment inerror.rssince your merge-base, so the green head CI (clippy-D warnings+ tests over the three wallet crates) covers it.
On the two findings deferred to a follow-up (backends that acknowledge a reservation they never persisted, and unpaid reservations outrunning the recipient's 20-address discovery window): I agree these are follow-ups, not blockers. The persistence gap already applies to the Core send path, and the discovery-window bound needs a paid-index watermark the sender does not track today. If you want a cheap interim for the latter in that follow-up: an explicit release call for a withdrawal that definitively failed before anything reached the network, mirroring what send_payment already does for a rejected broadcast.
Non-blocking: no Kotlin counterpart for reserveDashPayPaymentAddress yet; fine to add when Android needs it.
Supersedes #4614 (re-opened from the main repo so the Rust/Swift CI jobs run on it).
Issue being fixed or feature implemented
DashPay contact payments currently expose a combined address-resolution and Core-funded send operation. Wallets with Platform or shielded funds cannot obtain a fresh DIP-15 contact destination without selecting transparent Core inputs.
What was done?
Add
DashPayView::reserve_payment_addressand the SwiftManagedPlatformWallet.reserveDashPayPaymentAddress(fromIdentityId:toContactIdentityId:)wrapper through the C FFI. The operation completes the seed-verified deferred contact-crypto drain, consumes an address from the authoritative wallet/owner/contact external account pool, and persists and flushes its used flag before returning it.Core sends and external payout reservations share the derivation helper and a per-wallet gate that keeps their pool snapshots ordered. Core broadcasts release the gate while awaiting the network, then reacquire it before a definitive rejection's address rollback. The Swift wrapper retains its mnemonic resolver throughout the FFI call and frees the returned string.
Callers reserve only when submitting a confirmed payment. Exposed addresses stay consumed after cancellation, rejected withdrawal, or an unknown outcome; this API does not submit the withdrawal or record payment history. The companion iOS change owns the submitted-withdrawal history.
How Has This Been Tested?
cargo clippy -p platform-wallet -p platform-wallet-ffi --lib(only pre-existing upstream warnings).cargo fmt -p platform-wallet -p platform-wallet-ffi --checkandgit diff --check.Real testnet validation used two registered DashPay contacts: a 0.02 DASH Platform withdrawal with zero Transparent balance and a user-submitted 0.1 DASH Shielded withdrawal paid the reserved addresses. Recipient receipt verification used a combined test build with the separate AssetUnlock discovery fix in dashpay/rust-dashcore#1004. Screenshots and exact build provenance.
The receipt fix needs a separate upstream SDK dependency update. This PR only adds address reservation and leaves the existing rust-dashcore dependencies unchanged.
Breaking Changes
None. The existing Core-funded send API remains available.
Checklist:
For repository code-owners and collaborators only
This pull request was created by Codex.
Summary by CodeRabbit
New Features
Bug Fixes
PR Hygiene ·
5850e7c/self-reviewedrs-platform-wallet-ffi(packages/rs-platform-wallet-ffi/src/dashpay.rs) — approved by llbartekllrs-platform-wallet(packages/rs-platform-wallet/src/wallet/identity/network/payment_handler.rs,packages/rs-platform-wallet/src/wallet/identity/network/payments.rs,packages/rs-platform-wallet/src/wallet/persister.rs) — approved by llbartekllswift-sdk(packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ManagedPlatformWallet.swift) — approved by llbartekllWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.