Conversation
An unbound identity top-up lock (`IdentityTopUpNotBound`) names no identity on chain, and a resume accepted any identity the caller passed, so a host recovery passing its own identity would pay an interrupted top-up of someone else's identity into the holder's. First part of #5924. - `TrackedAssetLock`/`AssetLockEntry` carry `identity_recipient`, recorded with the row and flushed before the lock is broadcast, immutable once set (merge, apply, SQLite V021 column and trigger). - The build path takes `AssetLockRecipient` (shielded address or identity). An unbound top-up lock must name its identity and is built only for a backend declaring `ASSET_LOCK_IDENTITY_RECIPIENTS` (bit 16). - A resume of an unbound lock pays only the recorded identity: another is `AssetLockIdentityRecipientMismatch` (FFI 61), none recorded is `AssetLockRecipientUnknown` (new FFI 81). - `assign_identity_top_up_recipient` / FFI `platform_wallet_assign_identity_top_up_recipient` records a recipient the user chooses for an unassigned lock (one rebuilt from the chain). - FFI: identity-recipient persistence slots appended to the extension struct; both tracked-lock lists expose the recipient and an unassigned flag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alance Second part of #5924: a wallet can now pay an identity it does not manage from its Core balance, and resume an interrupted one to the identity its lock recorded. - `IdentityWallet::top_up_external_identity_with_funding` fetches the identity from Platform (an unknown one is refused before anything is built), funds the lock from the unbound top-up account with the identity recorded on its row before the broadcast, submits with the managed top-up's IS→CL fallbacks, and writes nothing to the identity manager. - `resume_identity_top_up_to_recorded_recipient` takes no identity: it pays the one the lock recorded, through the managed path when the wallet manages it and the external path otherwise. - The managed and external top-ups share one funding/submit helper. - FFI: `platform_wallet_top_up_external_identity_with_funding_signer` and `platform_wallet_resume_identity_top_up_to_recorded_recipient_signer`, both releasing the wallet registry before awaiting. A failed identity lookup surfaces as the SDK error until #5860 adds `IdentityLookupFailed` (FFI 80); a TODO marks the switch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cleanups from review of the #5924 change, no change to what is paid: - `submit_top_up_with_funding` consumes the tracked lock itself, so both top-ups drop their copy of that cleanup. - The top-up minimum (`MIN_TOP_UP_DUFFS`) moves from the FFI into rs-platform-wallet and applies to both Core top-ups, so Rust callers can no longer build a lock below it; the FFI copies are removed. - `tracked_resume_metadata` returns `TrackedResumeMetadata` instead of a tuple; one `not_an_unbound_top_up` builds the funding-mismatch error. - FFI: the new exports use `OutPoint::from(&OutPointFFI)`; the shielded and identity recipient loaders share `load_asset_lock_recipient_sidecar`. - Storage decodes `identity_recipient` with `id32`. - Tests share one mock-SDK helper and one test module. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oor drained top-ups - Record an assigned identity recipient in memory before storing it, so a failed flush that leaves the row queued cannot be overridden by a later assignment of another identity; assigning the same identity again retries the store. - Look the identity up on Platform before assigning it (an assignment is permanent); the FFI export goes through IdentityWallet, and the manager's method is now crate-private. The lookup is shared with the external top-up. - Hold drained top-up fundings to MIN_TOP_UP_DUFFS as their floor, which the builder enforces before anything is tracked or broadcast. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
Merge Risk:
|
|
✅ Final review complete — no blockers (commit 3325d46) · triage: critical |
…p to any identity - Move ASSET_LOCK_IDENTITY_RECIPIENTS to capability bit 17 and reserve bit 16, which #5890 claims for OUTPOINT_LOCKS. - Remove a rejected lock's row durably when it records a recipient, as drains already do, so a lost removal cannot bring back a Built row resumable to that recipient while its inputs fund the next attempt. - The resume that takes no identity also resumes bound top-up locks, paying the wallet's identity at the lock's index (AssetLockIdentityNotLoaded, FFI 7, when that identity is not loaded yet), so hosts need no classifier. - Refuse unbound top-up locks in the build-only API, which tracks nothing and so cannot record a recipient. - An external top-up of an identity the wallet holds updates its local balance, through a helper shared with the managed route. - Document that the generic resume's recorded recipient is wallet policy, that a failed external top-up is resumed rather than rebuilt, and what the legacy resume returns for identities outside the wallet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… may survive A lock row stored but not flushed before the broadcast has its removal stored behind it before the inputs are released, as before. If the store refuses that removal, the row may survive a restart and be re-broadcast after the user's retry, paying its recipient twice, so the reservation and the in-broadcast fence now stay held and the error says the inputs stay reserved. A row the store refused outright needs no removal, and its inputs are still released. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The PR contains three blocking issues: wallet-generation teardown is not excluded during the new top-up flows, tracked-lock FFI array element strides change incompatibly, and a failed non-atomic persistence store can still leave a recipient row behind before inputs are released. The remaining findings are non-blocking correctness and documentation issues involving versioned fee floors, consumed-lock error precedence, stale balance reporting, and the assignment API contract.
🔴 3 blocking | 🟡 4 suggestion(s)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 8: 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) — This is a large, intricate change to wallet asset-lock orchestration and persistence that directly affects funds movement and includes a storage migration. - 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.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— platform-versioning (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 (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/identity/network/registration.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:469-481: Top-up operations can broadcast after wallet-generation removal
The new external top-up calls `submit_top_up_with_funding` without acquiring this wallet generation's payment guard or checking that the generation is still current. The FFI path clones the `IdentityWallet` and releases the registry read lock before awaiting, so wallet removal can complete while the build or broadcast is in flight. The stale operation can then broadcast its already-signed asset-lock transaction after reservations from the removed generation were discarded; re-registering the same wallet ID can also cause subsequent state mutations to target replacement state. The same generation protection is needed on the new recorded-recipient resume and assignment paths, and it belongs in the Rust wallet layer rather than by retaining the FFI registry lock.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:768-806: Top-up minimum does not follow the active protocol version
`MIN_TOP_UP_DUFFS` hard-codes the v1 minimum of 50,500 duffs, while `IdentityTopUpTransition::calculate_min_required_fee` is version-dispatched. Protocol versions selecting fee v0 require only 50,000 duffs, so an SDK configured for an older supported `PlatformVersion` rejects a funding amount that Platform accepts. Conversely, a future fee-table change could make this client-side floor stale. Derive the minimum from the SDK's effective `PlatformVersion` and the DPP fee calculation instead of maintaining a second literal in the wallet crate.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:583-603: Consumed unassigned locks report the wrong recovery error
`resume_identity_top_up_to_recorded_recipient` checks `identity_recipient` before checking the tracked lock status. A consumed unbound lock with no recorded recipient therefore returns `AssetLockRecipientUnknown`, even though `is_unassigned_identity_top_up` excludes consumed locks and `check_identity_recipient_assignable` returns `AssetLockAlreadyConsumed`. Recovery and listing consequently disagree about the state of the same lock, and the caller is directed toward assignment even though assignment is rejected. Check the consumed status first so terminal locks consistently report `AssetLockAlreadyConsumed`.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:636-647: Top-up result can report a stale cached balance
`record_top_up_balance` returns the value returned by `persist_confirmed_balance`, which is the managed identity's cached balance. If the response metadata height ties the existing watermark, `take_fetched_balance` treats the proved snapshot as a duplicate and leaves the cache unchanged. The top-up can therefore succeed with Platform returning a new balance while the FFI output reports the old balance. Persistence should remain best-effort, but the caller's result must always be the proved `new_balance`; the watermark should only control what is cached.
In `packages/rs-platform-wallet-ffi/src/asset_lock/manager.rs`:
- [BLOCKING] packages/rs-platform-wallet-ffi/src/asset_lock/manager.rs:41-53: Tracked-lock array element strides changed without ABI negotiation
`TrackedAssetLockFFI` is returned as a contiguous bare-pointer array by `asset_lock_manager_list_tracked_locks`, and `TrackedAssetLockEntryFFI` is returned the same way by `platform_wallet_tracked_asset_locks_list`. Appending the identity-recipient fields changes `sizeof` and therefore the element stride. A host compiled against the previous header will index the second and later elements using the old stride, reading fields from the middle of the newer elements and potentially displaying or resuming the wrong lock. The paired free functions receive only the pointer and count, so they cannot recover the stride. The size-gated persistence extension does not protect these arrays. Preserve the existing V1 element types and add V2 list functions, or add explicit element-size/ABI negotiation.
In `packages/rs-platform-wallet/src/wallet/asset_lock/build.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/asset_lock/build.rs:1550-1555: A failed recipient-row store can still leave a resumable row
The `Err(false, error)` branch assumes that a failed `persister.store` means the asset-lock row was not written, then releases the input reservation after the follow-up removal succeeds. The FFI persistence contract does not provide that guarantee unless the host declares atomic changesets: a non-atomic host can write the base asset-lock row and fail while writing the recipient sidecar, and an atomic host can also leave the outcome unknown if rollback fails. The identity-recipient capability only proves that the callbacks exist; it does not prove atomicity. If the row survives while the reservation is released, a retry can spend the inputs again and later recovery can resume the surviving row, paying the recipient twice. Treat an error from the initial store as an unknown/potentially stored outcome and retain the reservation unless durable removal is confirmed.
In `packages/rs-platform-wallet-ffi/src/identity_registration_funded_with_signer.rs`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/identity_registration_funded_with_signer.rs:434-454: Assignment documentation selects an incompatible resume export
The assignment API accepts any identity known to Platform, including an identity not managed by this wallet. Its documentation directs hosts to `platform_wallet_topup_identity_with_existing_asset_lock_signer`, whose implementation requires the identity to exist in the local `IdentityManager`; an externally assigned identity therefore fails with `ErrorIdentityNotFound`. The documented recovery entry point must be the recorded-recipient resume export, which dispatches to the managed or external route without requiring the host to classify the identity.
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.
- Legacy FFI top-up exports hold the registry read lock across network waits — The managed top-up export, and the analogous registration export, still execute
block_on_workerinsidePLATFORM_WALLET_STORAGE.with_item, holding the global registry read guard across signer, persistence, retry, and network waits. The new exports correctly clone the wallet data and release the registry guard first. This is a real teardown and contention issue, but the locking shape predates this PR and the diff does not introduce it; it should be corrected in a follow-up rather than blocking this feature.- Follow-up: A follow-up FFI cleanup should clone the identity wallet, wallet ID, and network from the registry, drop the registry guard, and only then call
block_on_workerin the managed top-up and registration exports.
- Follow-up: A follow-up FFI cleanup should clone the identity wallet, wallet ID, and network from the registry, drop the registry guard, and only then call
…a refused row's inputs - Asset-lock builds broadcast under the build generation's lifecycle gate, after checking that generation is still the wallet's; a wallet removed or re-created mid-build sends nothing (WalletRemovedBeforeSend). This covers every new asset-lock funding, not only the top-ups. - A recipient-carrying row whose store is refused may still be written by a host without atomic changesets, so it is handled like a failed flush: its removal is stored, and if that is refused the inputs stay reserved. - The top-up minimum comes from IdentityTopUpTransition's fee calculation for the SDK's protocol version (min_top_up_duffs) instead of a literal. - Resuming a consumed unbound lock reports AssetLockAlreadyConsumed before a missing recipient. - The assignment doc points at the recorded-recipient resume. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The recipient-binding implementation is present, but the current head still has four in-scope blocking lifecycle and durability defects: failed cleanup can release inputs before removal is durable, generation-mismatch aborts leave a durable unsent lock fenced, assignment can mutate a replacement wallet generation, and the minimum can be checked against a stale SDK protocol version. The new external route also exposes the pre-existing stale balance return, and the new FFI exports do not contain the established panic boundary. CI shows no failed code check, but the wallet tests and most package checks are skipped while PR hygiene remains pending.
🔴 4 blocking | 🟡 2 suggestion(s)
Still open from earlier rounds (2)
- 🔴 Blocking: A failed recipient-row store can still leave a resumable row —
packages/rs-platform-wallet/src/wallet/asset_lock/build.rs:1572-1605(thread) - 🟡 Suggestion: Top-up result can report a stale cached balance —
packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:640-657(thread)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 8: 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) — This large, intricate diff changes funds movement and coin-selection behavior for Core-to-identity top-ups, including asset-lock lifecycle and recipient authorization, while also introducing persistent storage schema changes. - 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)
- Code unchanged since the last final review (
3b30b1e4): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed; 1 new nitpick(s) dropped - 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— platform-versioning (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 (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/asset_lock/build.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/asset_lock/build.rs:1668-1678: WalletRemovedBeforeSend leaves a durable Built lock fenced as pending
The generation check correctly prevents the broadcaster from being called, but this early return performs no cleanup. The recipient-bearing row was flushed earlier at lines 1546–1554, so it remains a durable `Built` lock. Returning drops `InBroadcastPin` with its default pending verdict and skips `abandon_unsent_build`, leaving the shared generation fence pending and not explicitly settling the old reservation. A recreated wallet inherits the shared fence, while a caller that treats `WalletRemovedBeforeSend` as retryable can build another lock even though the original signed row remains resumable and may later be recovered. Treat this as a definitive pre-send abort by durably removing the row before release, or retain an explicit operation-level hold and require recovery of this row rather than permitting a new build.
- [BLOCKING] packages/rs-platform-wallet/src/wallet/asset_lock/build.rs:1572-1605: A failed recipient-row store can still leave a resumable row
(carried; thread: https://github.com/dashpay/platform/pull/5931#discussion_r4572750252)
In `packages/rs-platform-wallet/src/wallet/asset_lock/sync/tracking.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/asset_lock/sync/tracking.rs:171-200: Identity-recipient assignment can mutate a replacement wallet generation
The assignment path acquires the wallet manager by `wallet_id` only. The FFI export clones the `IdentityWallet`, releases the registry, awaits the Platform identity lookup, and then calls this method. During that await the wallet can be removed and recreated under the same ID; the stale handle already contains a generation, but this method does not compare it with the current `PlatformWalletInfo.generation`. It can therefore assign and persist the recipient on the replacement generation's tracked lock. Perform the mutation through the handle's generation-checked accessor, under the appropriate lifecycle guard, before persisting.
_Raised on code unchanged since the last review, and confirmed by an independent pass: After the FFI export clones an `IdentityWallet` and awaits `fetch_identity_to_pay`, the wallet can be removed and recreated with the same ID. The stale handle then calls `AssetLockManager::assign_identity_top_up_recipient`, which mutates the entry returned by `get_wallet_info_mut(&self.wallet_id)` without checking the handle's generation, so it can assign and persist a recipient on the replacement wallet's tracked lock; a subsequent resume can pay that replacement lock to the stale call's identity._
In `packages/rs-platform-wallet/src/wallet/identity/network/registration.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:474-475: External top-up minimum is checked against a stale SDK protocol version
`apply_top_up_minimum` reads `self.sdk.version()` before `fetch_identity_to_pay` performs its proved network fetch. An unpinned SDK can ratchet its protocol version during that fetch, so the amount may pass the v0 floor and then be used by transition construction at v1, whose active minimum is higher. A pinned SDK can likewise remain below the network's active version. The lock can therefore be built and broadcast from real Core funds before Platform rejects the top-up. Resolve the network version before applying the floor and keep the same stable version for the floor and transition construction, or conservatively enforce a floor valid for every supported active version.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:640-657: Top-up result can report a stale cached balance
(carried; thread: https://github.com/dashpay/platform/pull/5931#discussion_r4572750273)
In `packages/rs-platform-wallet-ffi/src/identity_top_up.rs`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/identity_top_up.rs:307-328: New top-up exports can unwind through the C ABI
The new external top-up export calls `block_on_worker`, whose worker join path uses `expect("tokio worker panicked")`. A panic in the async wallet operation therefore re-panics inside this `extern "C"` function instead of returning a `PlatformWalletFFIResult`. The recorded-recipient resume and assignment exports use the same pattern. The crate already provides `catch_panic_to_code` because a panic cannot safely unwind through the C boundary and the JNI guard is outside the Rust export. Wrap each complete new export body with the operation-appropriate panic conversion, using an ambiguous-failure result for operations that may already have caused side effects.
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.
- Resume re-broadcast is not generation-gated — The existing recovery path can re-broadcast a tracked lock after its wallet generation has been removed or replaced because it does not hold the lifecycle gate used by new asset-lock builds. This is an important lifecycle gap, but it predates this change and is already tracked separately.
- Follow-up: #5516
romchornyi
left a comment
There was a problem hiding this comment.
🟡 4 major (inline) · 12 non-blocking recommendations · no blockers — reviewed at 282c6df764
| Level | Verdict | |
|---|---|---|
| 1 · Idea | ✅ valid | The recipient lives on the lock row and is enforced in the one resolver every existing-lock resume goes through, which fixes #5924 at the root. |
| 2 · Architecture | 🟡 right layer, one cross-PR overlap | Open draft #5930 models "who a lock pays" differently (payment_intent, also V021, bit 16, also reuses 61). Two models for one fact on the same base, and neither PR mentions the other. Please settle one model, or the rule that splits them, before either lands. |
| 3 · Completeness | 🟡 untracked gaps | Swift PR C, sweep/reinstate, legacy unbound locks on a restored seed, the testnet e2e send and the host recovery changes have no tracking issue. Fixes #5924 will close the issue while its points 5–6 are partly open. |
| 4 · Code | 🟡 4 major | Phantom unassigned locks, one error code for opposite retry contracts, no outpoint from the external top-up, V021 taken three times. |
Major (inline)
tracked.rs#L173— a consumed or restored unbound lock comes back as "unassigned, recoverable"; an irreversible assignment then binds it, and a conflicting one breaks that wallet's persistence for the session.build.rs#L1593— three exits with opposite retry contracts all returnPersistence(FFI 99), and the rejected-broadcast flush arm ignoresstore_commits_inline.identity_top_up.rs#L288— the external top-up returns no outpoint, and a pre-build lookup failure and a post-broadcast transport failure share code 99.V021__asset_lock_identity_recipient.rs#L4—V021is also claimed by #5890 (ready for review) and #5930; bit 16 by both of them.
On the open thread "WalletRemovedBeforeSend leaves a durable Built lock fenced as pending" — three of our lanes reached it independently, with a concrete double payment (build.rs#L1668-L1679):
- The wallet is removed and re-created under the same id while the build awaits the signer or the persister.
- The row with recipient X is stored, flushed and tracked into the new generation (
track_asset_lockis keyed bywallet_idonly). - The gate fails and the host is told nothing was sent.
- The user re-sends from other coins (the old ones stay fenced), and host recovery later resumes the leftover
Builtrow through the ungated re-broadcast, so X is paid twice.
Taking the gate and liveness check right after the build returns, before persist_asset_lock_account_pools and the row store, and holding it through track and broadcast (as #5516 prescribes) leaves nothing published on !is_current, so abandon_unsent_build can release the inputs cleanly.
12 non-blocking recommendations
- The gate checks the build's generation, not the caller's handle —
build.rs#L448,registration.rs#L475.IdentityWalletcarriesgeneration, and contact requests refuse a replaced generation with it (contact_requests.rs#L868-L872). The top-up path doesn't: a removal and re-import duringfetch_identity_to_paylets a payment started on the removed wallet run on its replacement. The open assign thread covers onlyassign_identity_top_up_recipient. mark_asset_lock_consumption_unknownhas no consumed guard —tracking.rs#L430-L441. With two overlapping resumes of one outpoint, the later 24 reverts an in-memoryConsumedtoRecoveredFromChain, so the lock lists as resumable again until restart. The function predates this PR; the new resume export makes the overlap easier to hit.- Code 7 means "retry after sync" and "never" —
error.rs#L1085.AssetLockIdentityNotLoadedand "Platform doesn't know the identity" share 7 on the same resume export, and the bound branch returns 7 before checking consumed (registration.rs#L577-L593). Consider a separate code, or at least document both in the registry row and the enum doc. Both triggers are hard to hit. - Assignment writes memory first and stores a snapshot after releasing the lock —
tracking.rs#L166-L203. A refused conflicting value (see major 1) stays in memory, and a sweep tombstone or rejected-lock removal stored in between is resurrected by the assignment's upsert. Roll memory back on a constraint refusal; refuse assignment of aBuiltlock. asset_lock_manager_resumestill bypasses the recipient check —sync.rs#L225. The change is doc-only. A host recovery loop that still uses it and then tops up its own identity reproduces #5924. Refusing locks that carry, or lack, an identity recipient (61/81) would close it at the root.- Sweep then reinstate drops the recipient —
reconstruction.rs#L393-L424,reconstruction.rs#L236. Listed under Known limitations, but untracked. Please file an issue. - Identity index 0 doubles as a sentinel on unbound locks — it is exposed as
registration_index/identity_indexon the tracked-lock lists (accessors.rs#L1068). Hosts that filter recovery rows byidentityIndexRaw == 0without the funding type (dashwallet-ios does, in its registration coordinator) will mix an in-flight external top-up into identity #0's progress. Exposing it as optional, or a doc note for hosts, would help. - Code 81 and the 61 registry row — Swift maps 81 to
errorUnknownand loses the number (Kotlin keeps it asGeneric), and this already affects the existing managed resume.ERROR_CODE_REGISTRY.mdrow 61 still says rows without a recipient "accept the caller's", which is no longer true for unbound top-ups. - A host that wires only the identity load slot stalls persistence —
persistence.rs#L3136-L3146. Loaded rows carry recipients, and every later round with them fails. Run the load sidecar only when bit 17 is attested, or document that the slots go in pairs. - Positional column reads in SQLite —
asset_locks.rs#L341-L345. #5930 edits the same SELECTs; a merge that adds its column but keeps index 8 would decode one 32-byte blob as the other with no error. A shared column list, or reading by name, removes the hazard. top_up_identity_with_fundingwith an observed identity —registration.rs#L411-L418. It returnsIdentityIndexNotSet(99), while the export doc names 7 for "one the wallet does not hold".- Tests:
recorded_recipientshas no test for(IdentityTopUp, Some(Identity))→(None, None), the arm every managed Core top-up now takes (build.rs#L1917), nor for the catch-all refusal.- The first half of
should_durably_remove_a_rejected_lock_that_records_its_recipientpasses on the old code, because withcommits_inline: truethe queued removal also counts as stored. Re-run it withcommits_inline: false. - Not covered:
- the removed-wallet (
None) arm of!is_current, and the row, pin and reservation it leaves; - assign on a consumed lock, and assign with the wallet missing;
- resume of an unbound lock whose recorded identity the wallet holds (the managed route);
- the FFI persist callback returning non-zero, and the load sidecar through
FFIPersister::load; - the new list-row fields;
- V021 on a populated V020 database;
- the
DrainWalletBalancefloor.
- the removed-wallet (
sqlite_advertises_asset_lock_identity_recipientsdoesn't follow the repo'sshould_…naming rule.
Review details
- Layered review: idea, architecture and completeness, then code.
- Code lanes: a general correctness pass, plus specialist lanes for funds, security, concurrency, FFI and persistence, and edge-case lanes for failure injection, ordering/crash/restart, ownership and legacy data, and tests.
- Verifier: every major was re-checked against the code by a separate clean-context pass. The migration and bit collisions were checked against the heads of #5890 (
6ca3b7eede) and #5930 (9f3047d7b6). - Not repeated: findings already open from the review bot's round on this commit, for example the replacement-generation assignment, the stale protocol version and the C-ABI unwind.
- Dropped: one candidate,
create_funded_prooftype 2 as an undocumented break, because it is in Breaking Changes.
🤖 Reviewed with Claude Code
…e assignment, version-proof top-up floor - A lock built on a wallet removed or re-created before the broadcast is aborted: its durable row is removed and its fence released, or, if that removal is refused, its inputs stay fenced. Tracking inserts only on the build's generation, so a replacement wallet is never handed the lock. - Assigning a top-up recipient holds the handle's generation gate and refuses a wallet since replaced (WalletRemovedBeforeSend). - min_top_up_duffs() is the largest minimum across every supported protocol version, so an SDK version change during the identity fetch cannot let a lock below the active floor be built. - The external top-up returns the proved post-transition balance. - The three new top-up FFI exports convert a panic to a result code instead of unwinding through the C ABI. - The typed-amount drain test now expects inputs to stay reserved when the backend also refuses the abandoned row's removal (from 282c6df). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…remove abandoned rows durably - AssetLockManager keeps the generation of the wallet it was registered with, and the funded build refuses (WalletRemovedBeforeSend) when the wallet under its id is a replacement, before selecting, reserving or signing: a stale handle can no longer spend a re-created wallet's funds. - Every abandoned-lock removal (rejected broadcast, wallet replaced before send, recipient row not made durable) goes through one helper that stores and flushes it, tolerating a failed flush notification only on a backend that commits inline. Inputs are released only once the removal is durable; otherwise they stay reserved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… resume may still send The pre-send abort for a wallet removed or re-created since the build now checks, under the wallet write guard, whether a resume has claimed the row's dispatch, as the rejected-broadcast cleanup does. When a resume or the wallet now under the id may still send the lock, its row and inputs stay and the outcome is reported as TransactionBroadcastUnconfirmed, so the caller does not rebuild from other inputs and pay the recipient twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…omes, outpoint from the external top-up - SQLite keeps consumed rows that record an identity recipient, so a completed external top-up is not rebuilt as an unassigned lock after a restart. A consumption-unknown (RecoveredFromChain) lock is no longer listed as unassigned, and assigning it is refused (AssetLockConsumptionUnknown, FFI 24). A conflicting recipient for a consumed stored row is skipped instead of failing the changeset, and an assignment the backend refuses is rolled back in memory. - Build exits where the row may survive and the inputs stay reserved return TransactionBroadcastUnconfirmed (FFI 20) with the outpoint, distinct from the retry-safe exits where the row was removed. - platform_wallet_top_up_external_identity_with_funding_signer reports the built lock's outpoint (all zero when nothing was built), also on failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks — this was against
|
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
Moves the identity recipient migration to V023 (#5890 took V022), keeps capability bit 17 next to #5890's OUTPOINT_LOCKS (bit 16) and drops the RESERVED_BITS stand-in, appends the identity recipient persistence slots after the outpoint lock slots, and makes the V021 rewind test helper undo both later migrations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…kupFailed (80) #5860 merged the not-sent lookup failure. The external top-up from Core and the recipient assignment now report a lookup Platform cannot answer as IdentityLookupFailed (FFI 80) instead of the SDK's error: nothing is built or assigned, so the call may be retried as it is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The new top-up path records the intended recipient in Rust, but persistence and cleanup races can still lose that intent or make a second payment appear safe, and seed restore can leave a genuinely unused lock inaccessible through the wallet. This head is 33 commits behind v5.2-dev with seven merge conflicts; the available checks show no failed code check, with review and hygiene still pending. One verified lookup-error suggestion is omitted under the inline comment budget.
🔴 9 blocking | 🟡 1 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Persist the unbound signing path before broadcasting the lock
packages/rs-platform-wallet/src/wallet/asset_lock/build.rs:1489-1501
Bit 17 does not require ASSET_LOCK_FUNDING_INDICES, and an ordinary external top-up proceeds even when persist_asset_lock_account_pools returns an error. A restart can therefore restore the signed lock and its recipient but not the key path needed to finish the top-up. rederive_credit_output_path looks up the credit-output address in the restored unbound account; pinned key-wallet only searches addresses already in its pools. An address beyond the restored pool fails that lookup. Make the signing path part of the successful pre-send checkpoint, either by requiring and durably storing the pool or by persisting enough derivation information on the lock. Cover recovery with a credit-output index absent from the initial pool.
source: gpt-6.2-astra (phase2-reviewer: general, architecture-layering, ffi-engineer, platform-versioning, rust-quality, security-auditor)
Still open from earlier rounds (1)
- 🟡 Suggestion: Top-up result can report a stale cached balance —
packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:642-645(thread)
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: 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) — This is a large, intricate change to wallet asset-lock construction, coin selection, signing, broadcast recovery, persistence migration, and FFI error handling, directly affecting funds movement and storage of recipient-bound locks. - 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)
- Code unchanged since the last final review (
282c6df7): 3 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 3 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-ffi/src/persistence.rs`:
- [BLOCKING] packages/rs-platform-wallet-ffi/src/persistence.rs:1970-1982: Require an atomic lock-and-recipient checkpoint for the FFI sidecar
An FFI host can attest bit 17 without attesting `ATOMIC_CHANGESETS` or supplying both transaction brackets. `store` writes the signed `Built` row through `on_persist_asset_locks_fn` before invoking the recipient sidecar. If the first callback commits inline and the process dies before the second, restart sees a signed, assignable lock with no recipient. A later assignment can then pay someone other than the identity the user confirmed. Neither a final flush nor compensating cleanup on a returned error closes that crash window. Require an attested atomic round for this split write, or persist both values in one indivisible operation. Use the effective recipient capability on restore too: the current pointer-only check at lines 3985–3995 can call a wired but undeclared loader before its schema is available and abort the entire wallet load. Keep read errors fail-closed for hosts that do attest the contract.
_Raised on code unchanged since the last review, and confirmed by an independent pass: An FFI host can declare bit 17 without transaction brackets, commit the signed Built row for a top-up to identity A, and lose the process before the recipient callback runs. On restart, the wallet treats the lock as unassigned: resuming to A fails, and assigning B lets recovery broadcast the saved transaction and credit B instead._
- [BLOCKING] packages/rs-platform-wallet-ffi/src/persistence.rs:744-765: Append recipient callbacks after the target's outpoint-lock callbacks
#5890 already occupies these offsets on the target with three outpoint-lock callbacks. The SDK does not promise general cross-release C ABI compatibility, but this extension explicitly keeps the same version and uses `struct_size` to negotiate an append-only layout. A size check cannot distinguish the base's outpoint loader from the recipient loader at the same offset: the former writes an array pointer and a count where the latter supplies different arguments. Preserve the target prefix, append the recipient pair after `on_load_wallet_locked_outpoints_free_fn`, and pin that boundary so a table with exactly the target's size acquires neither recipient callback.
_Raised on code unchanged since the last review, and confirmed by an independent pass: If the recipient pair keeps its PR offsets on integration, a target-layout Swift host restoring a saved asset lock passes the version and size checks, and Rust calls its outpoint loader as the recipient loader. The Swift callback writes an array pointer through the address of the 36-byte input outpoint and a machine-word count through the address of the one-byte found flag, causing undefined behavior._
In `packages/rs-platform-wallet/src/wallet/asset_lock/build.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/asset_lock/build.rs:1489-1501: Persist the unbound signing path before broadcasting the lock
Bit 17 does not require `ASSET_LOCK_FUNDING_INDICES`, and an ordinary external top-up proceeds even when `persist_asset_lock_account_pools` returns an error. A restart can therefore restore the signed lock and its recipient but not the key path needed to finish the top-up. `rederive_credit_output_path` looks up the credit-output address in the restored unbound account; pinned key-wallet only searches addresses already in its pools. An address beyond the restored pool fails that lookup. Make the signing path part of the successful pre-send checkpoint, either by requiring and durably storing the pool or by persisting enough derivation information on the lock. Cover recovery with a credit-output index absent from the initial pool.
- [BLOCKING] packages/rs-platform-wallet/src/wallet/asset_lock/build.rs:1742-1762: Prove a lock was not sent and cannot be resumed before allowing a retry
The builder publishes a resumable `Built` row before taking its lifecycle guard. A resume can send it and advance it to `Broadcast`, which clears the dispatch claim because the row status now protects it. If teardown then removes the wallet, the `None` branch loses both pieces of evidence and can delete the row and return `WalletRemovedBeforeSend`. The same check misses a loader that has already read the durable row but has not yet published the replacement. On broadcast rejection, dropping the lifecycle guard before `untrack_asset_lock` creates another gap: cleanup can remove the replacement's `Built` row while checking only the old manager's claim map, then return code 26 while the replacement's resume sends. Finally, the best-effort removal branches can return a retry-safe verdict even when a successful initial store reached disk and the removal failed or never flushed. Keep publication, dispatch evidence and rejection cleanup tied to the same generation, and require durable removal of any potentially persisted row before reporting a safe retry. Otherwise keep the outcome unknown.
- [BLOCKING] packages/rs-platform-wallet/src/wallet/asset_lock/build.rs:1315-1322: Enforce the top-up floor at the shared funding boundary
`apply_top_up_minimum` protects the two `IdentityWallet` routes, but `asset_lock_manager_create_funded_proof` calls `AssetLockManager::create_funded_asset_lock_proof` directly. The shared builder accepts a bound `IdentityTopUp` without a recorded recipient and checks only that the exact amount is nonzero, so this route can broadcast a 40,000-duff lock that Platform will not accept for a top-up. This PR moves the minimum into Rust; enforce it where the wallet actually builds a lock of either top-up role, including on the final credit output of a drain. Reuse the DPP calculation rather than adding another rule to the binding.
In `packages/rs-platform-wallet/src/wallet/asset_lock/sync/tracking.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/asset_lock/sync/tracking.rs:214-232: Do not authorize a resume with an assignment that has not committed
The assignment publishes `Some(identity)` under the manager write lock, then drops that lock before storing or flushing it. The lifecycle guard is shared and `tracked_resume_metadata` does not wait for assignment, so a concurrent resume can use the tentative recipient and submit even if the store later refuses it. A second same-identity assignment can also commit successfully before the first caller's rollback clears the value in memory; comparing the identity does not distinguish the two writes. Serialize assignment and publication for the outpoint. An ambiguous write can reserve the recipient against reassignment without making it eligible for payment until the assignment is confirmed.
- [BLOCKING] packages/rs-platform-wallet/src/wallet/asset_lock/sync/tracking.rs:861-868: Provide an explicit recovery path for an unused, seed-restored top-up
If the Core lock reaches a ChainLocked block before the Platform top-up is submitted and local storage is lost, seed reconstruction restores the proof but no recipient. The old managed resume accepted that unbound proof with a caller-selected identity. This PR correctly removes that implicit routing, but now both resume paths require a recipient and assignment permanently rejects the `RecoveredFromChain` row. Mobile bindings do not unblock it, and FFI code 24 also collapses unknown consumption into confirmed consumption. Keep these outpoints out of automatic recovery and known-spendable balances, but provide an explicit, user-confirmed recovery for the exact outpoint, or a proved consumption check that can unblock assignment. Keep unknown consumption machine-readable and distinct from a confirmed spend.
In `packages/rs-platform-wallet-ffi/src/identity_top_up.rs`:
- [BLOCKING] packages/rs-platform-wallet-ffi/src/identity_top_up.rs:294-297: Do not tell hosts to retry a payment based on a missing local row
Code 23 says only that the current wallet does not track the outpoint. It can also occur after Platform accepted the top-up but its response was lost, if the wallet is removed and re-created and recovery runs before the row is restored. A host following this guidance can pay the identity a second time. Only an affirmative pre-send verdict from the original operation can establish that a fresh payment is safe.
In `packages/rs-platform-wallet-storage/migrations/V021__asset_lock_identity_recipient.rs`:
- [BLOCKING] packages/rs-platform-wallet-storage/migrations/V021__asset_lock_identity_recipient.rs:1-5: Allocate the recipient migration after the target's V021 and V022
Target tip `c594a4d5679f` contains `V021__core_transaction_accounting.rs` and `V022__core_locked_outpoints.rs`. Keeping this filename duplicates a Refinery migration version, and the V022 proposed in the thread is no longer free either. Preserve both target migration histories, allocate V023 at this tip, and regenerate the schema pins against the combined history. Preserve the target's `OUTPOINT_LOCKS` at bit 16 and this PR's recipient bit at 17; bit 16 is no longer merely reserved.
_Raised on code unchanged since the last review, and confirmed by an independent pass: With both V021 files embedded after integration, opening a fresh SQLite wallet fails when Refinery tries to insert the second migration history row with version 21, violating the history table's primary key._
In `packages/rs-platform-wallet/src/wallet/identity/network/registration.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:642-645: Top-up result can report a stale cached balance
(carried; thread: https://github.com/dashpay/platform/pull/5931#discussion_r4572750273)
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Updated after discussion: 1 finding(s) of this review were settled in the inline threads.
- ✅ Withdrawn: 🟡 A temporary storage failure disables retry after the unsent lock is durably removed
New on this head: This revision reformats one assertion in the FFI runtime-reentry test without changing what it checks or changing production code. GitHub shows no failed code checks on this head; PastaClaw review and PR Hygiene are pending. The current v5.2-dev tip has textual merge conflicts in the two wallet error files and the FFI registry, but #6373 uses code 92, leaving recipient codes 89 and 90 available.
🟡 3 2 suggestion(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
Still open from earlier rounds (3)
- 🟡 Suggestion: A temporary storage failure disables retry after the unsent lock is durably removed —
packages/rs-platform-wallet/src/error.rs:2343-2345(thread) — settled: ✅ Withdrawn - 🟡 Suggestion: A failed recipient lookup can report the wrong lock as held or a known lock as unsent —
packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:496-511(thread) - 🟡 Suggestion: A seed-restored top-up is reported as held before its identity loads —
packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:655-662(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 diff changes how wallet/asset_lock/build.rs reserves Core inputs, persists the recipient and signing-key index before broadcast, and handles failures that determine whether a payment can safely be retried; it also adds the V024 storage migration. - 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 (
4a8b1657): 1 finding(s) judged fixed earlier and raised again on unchanged lines kept settled - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (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/error.rs`:
- [SUGGESTION → WITHDRAWN in discussion; do not fix] packages/rs-platform-wallet/src/error.rs:2343-2345: A temporary storage failure disables retry after the unsent lock is durably removed
(carried; thread: https://github.com/dashpay/platform/pull/5931#discussion_r4763784043)
In `packages/rs-platform-wallet/src/wallet/identity/network/registration.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:496-511: A failed recipient lookup can report the wrong lock as held or a known lock as unsent
(carried; thread: https://github.com/dashpay/platform/pull/5931#discussion_r4763784040)
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:655-662: A seed-restored top-up is reported as held before its identity loads
(carried; thread: https://github.com/dashpay/platform/pull/5931#discussion_r4763784033)
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
…latform-wallet-top-up-someone-elses-identity-fr # Conflicts: # packages/rs-platform-wallet-ffi/ERROR_CODE_REGISTRY.md # packages/rs-platform-wallet-ffi/src/error.rs # packages/rs-platform-wallet-storage/SCHEMA.md # packages/rs-platform-wallet-storage/src/sqlite/migrations.rs # packages/rs-platform-wallet-storage/src/sqlite/schema/core_state.rs # packages/rs-platform-wallet-storage/tests/integration/sqlite_schema_pinning.rs # packages/rs-platform-wallet/src/error.rs
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
…latform-wallet-top-up-someone-elses-identity-fr #5210 restores every Core pool from its rows (`core_pool::restore_pools`), the asset-lock funding pools included, and fails a wallet whose used or reserved one-time funding rows it cannot restore. This branch's own row restore of those pools is dropped in its favour: run after it, it rebuilt the pools and lost their restored reservations. What remains is the step upstream has no counterpart for, moving a funding pool's window past the locks stored on chain (`extend_funding_pools_past_locks_on_chain`), run after `restore_pools`. Funding issuance floors return to upstream's empty default. The tests of the dropped restore's tolerant repair of damaged funding rows go with it; a funding index with no row is handed out again, as upstream holds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
New on this head: This head keeps the original error codes when refusing a recovered top-up but no longer reports its outpoint as held. It also integrates the target branch’s SQLite pool restore and moves the recipient migration to V025. The Linux Rust wallet, Swift SDK, and Kotlin SDK checks passed; the full Rust workspace check was skipped, and PR Hygiene and PastaClaw review were pending.
🟡 2 suggestion(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
Still open from earlier rounds (1)
- 🟡 Suggestion: A failed recipient lookup can report the wrong lock as held or a known lock as unsent —
packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:496-511(thread)
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 C documentation promises a held outpoint for a mismatch that can return none
Impact: A C caller following the code-61 documentation for a recovered top-up can offer Resume even though the result contains no held outpoint.
packages/rs-platform-wallet-ffi/src/error.rs:679-683
Code 61 is still the right diagnostic, but it no longer guarantees a lock the host can resume. Since 97e7bdaa24, a managed existing-lock top-up that requests a different identity from the one recorded on a recovered row returns MaybeSent. The FFI conversion retains code 61 from the source error and takes delivery and the held outpoint from the outer error, so held_asset_lock is empty. Tell callers to follow payment_delivery, not infer a held outpoint from the code.
/// Also an unbound identity top-up lock resumed (or assigned) to a
/// different identity than the one its row recorded
/// (`PlatformWalletError::AssetLockIdentityRecipientMismatch`). This call
/// submitted nothing new. Use `held_asset_lock` only when `payment_delivery`
/// is `LockHeld`; a recovered lock can return `MaybeSent` with no held
/// outpoint and needs reconciliation instead.
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: 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) — This is a large, intricate change that modifies Core-to-Platform funds movement, signing-key-index persistence, recovery and broadcast error handling, FFI APIs, and SQLite storage migrations, including packages/rs-platform-wallet/src/wallet/asset_lock/orchestration.rs and packages/rs-platform-wallet-storage/src/sqlite/schema/asset_locks.rs. - 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 (
5a643e4c): 1 suggestion(s) on unchanged code listed as follow-up candidates; 1 finding(s) judged fixed earlier and raised again on unchanged lines kept settled - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (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-storage/src/sqlite/schema/core_pool.rs`:
- [SUGGESTION] packages/rs-platform-wallet-storage/src/sqlite/schema/core_pool.rs:85-98: A conflicting funding snapshot can commit successfully and prevent the wallet from reopening
Impact: A SQLite persistence caller that supplies a key and address from the wrong derivation index can replace a valid row and discover the mistake only on the next wallet load.
SQLite can acknowledge a funding snapshot that its own loader rejects. `apply_pools` checks the incoming key’s width, not its derivation. If an occupied funding slot gets both a different script and different typed key, `AND script = ?11` suppresses `TypedPoolKeyConflict`, and the upsert replaces both. The merge at `7f4ab0a` removed the loader that produced verified repair snapshots; its replacement, `restore_pools`, refuses a row that disagrees with the account-derived address or key. Use the ordinary typed-key conflict check for funding snapshots too. If repair is needed later, give it a separate write path that verifies the replacement against the account derivation.
In `packages/rs-platform-wallet/src/wallet/identity/network/registration.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:496-511: A failed recipient lookup can report the wrong lock as held or a known lock as unsent
(carried; thread: https://github.com/dashpay/platform/pull/5931#discussion_r4763784040)
| let identity = match self.fetch_identity_to_pay(identity_id).await { | ||
| Ok(identity) => identity, | ||
| Err(error) => { | ||
| return Err(match &funding { | ||
| AssetLockFunding::FromExistingAssetLock { out_point, .. } | ||
| if self | ||
| .asset_locks | ||
| .tracked_resume_metadata(out_point) | ||
| .await | ||
| .is_some() => | ||
| { | ||
| self.asset_locks | ||
| .funded_lock_error(error, Some(*out_point)) | ||
| .await | ||
| } | ||
| _ => error, |
There was a problem hiding this comment.
Still applies (re-reviewed at 7f4ab0a7): #5516 records the broader lifecycle issue, but a teardown guard would not fix the wrong-recipient branch: with a stable wallet, funded_lock_error still upgrades a failed lookup for A to LockHeld based only on B’s row being live. The new external top-up route needs to establish which lock it is reporting before it returns either verdict.
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
…yment class is LockHeld Since a recovered lock's recipient mismatch reports MaybeSent with no held outpoint, the doc no longer promises a lock to resume. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
New on this head: This head changes only the FFI documentation for code 61: callers should use the held outpoint only when payment_delivery is LockHeld. The Linux Rust wallet tests, Swift SDK build and tests, Swift frozen-schema check, and Kotlin SDK build and tests passed; PR Hygiene and the automated review were pending.
🟡 2 suggestion(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
Still open from earlier rounds (2)
- 🟡 Suggestion: A conflicting funding snapshot can commit successfully and prevent the wallet from reopening —
packages/rs-platform-wallet-storage/src/sqlite/schema/core_pool.rs:85-98(thread) - 🟡 Suggestion: A failed recipient lookup can report the wrong lock as held or a known lock as unsent —
packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:496-511(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) — This large, intricate change modifies Core-to-Platform funds movement, asset-lock recipient and signing-key persistence, crash recovery, and SQLite storage migrations in functions such as asset-lock orchestration/building and tracked-lock persistence. - 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 (
7f4ab0a7): 1 finding(s) judged fixed earlier and raised again on unchanged lines kept settled - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (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-storage/src/sqlite/schema/core_pool.rs`:
- [SUGGESTION] packages/rs-platform-wallet-storage/src/sqlite/schema/core_pool.rs:85-98: A conflicting funding snapshot can commit successfully and prevent the wallet from reopening
(carried; thread: https://github.com/dashpay/platform/pull/5931#discussion_r4778400289)
In `packages/rs-platform-wallet/src/wallet/identity/network/registration.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:496-511: A failed recipient lookup can report the wrong lock as held or a known lock as unsent
(carried; thread: https://github.com/dashpay/platform/pull/5931#discussion_r4763784040)
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
romchornyi
left a comment
There was a problem hiding this comment.
🟡 1 major (inline) · 13 non-blocking recommendations · no blockers — re-reviewed at 45f4b6470f
This adds to my approval of 182cc6b04e; the approval stands.
| Level | Verdict | |
|---|---|---|
| 1 · Idea | ✅ valid | unchanged: the recipient is recorded on the lock's row before broadcast |
| 2 · Architecture | 🟡 one question open again | the reply to lklimek on rehydrate.rs points to restore_asset_lock_funding_pools, which merge 7f4ab0a765 removed; see below |
| 3 · Completeness | 🟡 untracked gaps | see below |
| 4 · Code | 🟡 1 major | the IS-timeout ChainLock fallback of a top-up can report a sent lock as NotSent |
Closed since the last review
- Code 89 claimed twice: #6373 moved to 92; this PR keeps 89 and 90, and the registry agrees.
- lklimek: stored status as an enum, the rewind helper's name,
SCHEMA.mddiagram and columns.
Major (inline)
- orchestration.rs:818 —
resolve_top_up_chain_proof_after_is_timeoutlacks thewith_funded_lockwrapper its sibling has, soAssetLockNotTrackedorAssetLockRecipientUnknownafter the ChainLock wait reaches the host asNotSent.
Architecture: the storage question is open again
lklimek asked whether the rehydrate.rs logic belongs in storage. The answer pointed to restore_asset_lock_funding_pools and its range checks, but merge 7f4ab0a765 replaced that function with #5210's core_pool::restore_pools. What stays in storage is extend_funding_pools_past_locks_on_chain (called at persister.rs:2101): it marks used every funding address a lock on chain paid and derives the gap past it. That decides wallet state, and the FFI/Swift load path does not run it. Either move it into platform-wallet next to restore_account_address_pools, or say on the thread that it only repairs what this store's older writers lost.
Untracked gaps (please file or link an issue)
- No way for a host to ask whether a recovered outpoint was already consumed, which is what code 90 asks the user to acknowledge.
- A testnet end-to-end run of Core → someone else's identity.
- Swift #6139 is 54 commits behind this head (base
7d6b70435c, before #6379): it conflicts inPlatformWalletResult.swiftand its tests have not run against the payment-class result. Its code-61 doc (PlatformWalletResult.swift:808-813) and Kotlin #5933's (DashSdkError.kt:264-268) still say "nothing was submitted; resume", without theMaybeSentcase45f4b6470fadded.
13 non-blocking recommendations
Carried from my earlier reviews, unchanged:
- A lock that was never stored or sent returns 20 and keeps its inputs fenced — build.rs:1943. When the wallet was replaced during the build,
track_asset_lockinserts nothing, yet the call returns 20 and the fence (shared across generations) waits for a spend that never comes. The replacement wallet's builds hitInputMidBroadcaston those UTXOs until restart. No double payment. - A Core-rejected lock can end as 20 with its inputs fenced — build.rs:2019. On a buffered host,
withdraw_durablyfails withOtherFlushUnsettledwhile any flush is in flight. The row is already out of memory, so no resume finishes it. Consider requiring the durable removal only where the row itself was stored durably.
New on this head:
- Pre-build refusals of the external top-up are classed
MaybeSent— build.rs:1430, via identity_top_up.rs:694. A missingIDENTITY_RECIPIENT_TOP_UPcapability, a key mismatch orWalletNotFoundbeforeon_builtruns reach the host as maybe sent with a zero outpoint, while the export's doc says nothing was built. The shielded funding already usesbefore_dispatch()for this (fund_from_asset_lock.rs:300). (not verified) - A managed top-up of a resumable lock can return
NotSent— registration.rs:413.IdentityNotFound/IdentityIndexNotSetcome back before the funded-lock seam, the managed sibling of what 78242c6 fixed on the external route. (not verified) AssetLockAbandonedBeforeSendhas no code and the opposite retry flag — it falls to the FFI's_ => ErrorUnknown(99) (error.rs:1941) andis_retryableis false, while the docs say a new call is safe.AssetLockConsumptionUnknownis classedMaybeSent— error.rs:2077. The assignment it refuses sends nothing, and the docs call it retryable with the acknowledgement.- A resume broadcasts outside the lifecycle gate — recovery.rs:1243 to 1306. A resume parked in
await_broadcast_readycan send, and advance a status (advance_asset_lock_status_ifhas no generation filter), after the wallet was removed or re-created. The build takestry_payment_guard_owned()and re-checks the generation right before its send (build.rs:1950). No double payment found. (not verified) - The 78242c6 re-check does not exclude a parallel resume —
claim_resume_dispatchis a counter, so both can broadcast until one records its advance. Same transaction, no funds impact; only the commit's wording overstates it. (not verified) - Registry rows 61, 20 and 26 are behind
error.rs— ERROR_CODE_REGISTRY.md:303: row 61 still names only the shielded recipient, and rows 20/26 lack the rejected-lock-whose-removal-was-not-durable case. - A null
identity_idleaves the outpoint out-param untouched — identity_top_up.rs:564:check_ptr!runs beforereport_built_outpointclears it, though the docs promise all zero when nothing was built. into_panic()on a cancelledJoinError— build.rs:2421: during runtime shutdown this panics instead of returning; checkis_panic()first, as the assignment path does.- Wildcards over our own enums —
AccountTypeat rehydrate.rs:291 and core_pool.rs:253 (matches!);AssetLockFundingType/AssetLockFundingat build.rs:2319, registration.rs:688 and registration.rs:913. A funding account or funding type added later silently takes the wildcard's path. The funding-account set now also exists in four places. - Tests — core_state.rs:2036 weakened
== 24to>= 22, so it would pass if V023–V025 stopped running; compare with the latest embedded version. recovery.rs:4759: the new test name does not start withshould. In Kotlin #5933,rs-unified-sdk-jni/src/credits.rs:536-540throws raw 20 withoutPWFFI_CODE_OFFSET, so Kotlin readsInternalError(the code calls the path unreachable).
Review details
Re-review of the author's commits since 182cc6b04e and the conflict resolutions of the v5.2-dev merges (#5928/#6379, #6373, #5210), against the whole PR where needed. Levels 1–3 inline; level 4: /code-review high plus funds, concurrency, persistence and FFI lanes (the companion Swift #6139 and Kotlin #5933 diffs included). The major was verified against the code; items marked (not verified) come from a lane and were not re-traced.
🤖 Reviewed with Claude Code
| /// is long, and an unbound lock must still record `identity` (and not be | ||
| /// consumed) when its proof is returned for submission. See | ||
| /// [`authorize_top_up_resume`]. | ||
| pub(crate) async fn resolve_top_up_chain_proof_after_is_timeout( |
There was a problem hiding this comment.
Major: a top-up's ChainLock fallback can report a sent lock as NotSent. Verified in code.
resolve_top_up_chain_proof_after_is_timeout (new in this PR) runs the ChainLock upgrade and the authorized resume without the with_funded_lock(Some(*out_point), …) wrapper that its sibling resolve_chain_proof_after_is_timeout (orchestration.rs:791) has, with the comment "every failure from here on leaves it held, never NotSent". The caller (registration.rs:813) only uses ?.
This runs after the lock was broadcast and the InstantSend wait timed out, so the ChainLock wait in between is long. Two errors classed NotSent (error.rs:1965, 1969) can come out of it:
AssetLockNotTracked: fromadvance_asset_lock_statusinupgrade_to_persisted_chain_lock_proof, or from the resume (recovery.rs:1058), when the row is gone by the time the ChainLock arrives;AssetLockRecipientUnknown: fromauthorize_top_up_resume.
The host then reads "nothing was sent" for a lock that is on the network, and may fund a second one. (WalletNotFound and AssetLockProofWait are already MaybeSent, so they are not affected.)
Fix: wrap the body in self.with_funded_lock(Some(*out_point), async { … }), as the sibling does, and add a test that a NotSent error from the fallback comes back as MaybeSent/LockHeld.
There was a problem hiding this comment.
Fixed in 529c41c. resolve_top_up_chain_proof_after_is_timeout now runs the ChainLock upgrade and the authorized resume inside with_funded_lock(Some(*out_point), …), as its sibling does, so AssetLockNotTracked or AssetLockRecipientUnknown after the ChainLock wait comes back MaybeSent (or LockHeld while the lock is resumable), never NotSent. New test should_never_report_a_top_up_chain_lock_fallback_failure_as_not_sent (sync/proof.rs): an unbound top-up row with no recipient goes through the fallback and the error is AssetLockRecipientUnknown classed MaybeSent.
… refuse conflicting funding snapshots - The top-up IS-timeout ChainLock fallback runs under `with_funded_lock`, like its sibling: a refusal after the broadcast (row gone, recipient unknown) is MaybeSent or LockHeld, never NotSent. - Funding snapshots use the ordinary typed-key conflict check. The looser funding check served the repair loader that the #5210 merge removed; `restore_pools` refuses a row that disagrees with the account derivation, so accepting one would stop the wallet from reopening. - An external top-up refused before its lock is built is NotSent; a managed top-up whose identity lookup fails on a tracked lock names the lock as held. - AssetLockAbandonedBeforeSend gets FFI code 93 and is retryable; AssetLockConsumptionUnknown is NotSent (an assignment sends nothing). - A cancelled settle task no longer panics through `into_panic`. - A null identity id leaves the external top-up's outpoint all zero. - Registry rows 20, 26, 61 and 90 updated; row 93 added; next free 94. - V022 recovery test compares with the latest embedded migration; a test name starts with `should`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
|
@romchornyi thanks for the re-review. Pushed 529c41c (this PR) and bff36a1 (#5933). Major: fixed; see the inline reply on Architecture ( Fixed from the recommendations:
Not in this PR: 1, 2, 7, 8 and 12. 7 and 8 belong to the lifecycle class tracked in #5516. The three completeness gaps (a consumption query for code 90, a testnet end-to-end run, Swift #6139 catching up with this head and the code-61 doc) are noted; #6139 is yours. |
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 rejects SQLite snapshots that would replace a stored funding key, preserves the post-broadcast payment class during the top-up ChainLock fallback, and adds FFI code 93 for a durably abandoned lock. The Rust workspace, Swift, and Kotlin checks passed; the dedicated Rust wallet job was skipped, and PastaClaw review and PR Hygiene are pending.
🟡 5 suggestion(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
Still open from earlier rounds (2)
- 🟡 Suggestion: A failed recipient lookup can report the wrong lock as held or a known lock as unsent —
packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:609-619(thread) - 🟡 Suggestion: A refused ChainLock fallback leaves a recovered row in a misleading settled status —
packages/rs-platform-wallet/src/wallet/asset_lock/orchestration.rs:828-837(thread)
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: Code 89 says nothing was sent even when the Core lock was broadcast
Impact: A host following the code-89 documentation can describe an already-broadcast Core payment as unsent when the ChainLock fallback finds no recipient.
packages/rs-platform-wallet-ffi/src/error.rs:969-971
Code 89 no longer implies that the Core lock was unsent. The new fallback wrapper produces AssetLockRecipientUnknown with MaybeSent after Core broadcast, and the FFI deliberately preserves both the source code and the outer payment class. The enum and registry still say unconditionally that nothing was submitted or paid. Clarify in both places that this refusal did not submit the Platform top-up; it says nothing about whether the Core lock was dispatched. Tell hosts to use payment_delivery for that distinction.
source: gpt-6.2-astra (phase2-reviewer: general, architecture-layering, ffi-engineer, rust-quality, security-auditor)
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: rust-quality); reviewer 7: 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) — This is a large, intricate change that directly alters funds movement and coin-selection orchestration, signing-key handling, durable asset-lock persistence, and recovery inpackages/rs-platform-wallet/src/wallet/asset_lock/orchestration.rsandbuild.rs, with accompanying storage migrations. - 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 (
45f4b647): 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— 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/error.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/error.rs:2282-2285: A permanent checkpoint refusal tells the host to retry the same payment
Impact: A host following `retryable` can repeatedly rebuild and sign a top-up whose checkpoint the persister will keep rejecting.
Durable abandonment makes another payment safe, but it does not mean the same request can get past the storage refusal. For example, a typed funding-key conflict rejects the combined pool-and-lock checkpoint; the compensating removal has no pool snapshot and can succeed without correcting the conflict. The next build can submit the same conflicting snapshot. The new unconditional `true` arm conflates these two guarantees, even though `is_retryable` documents that the same call must be able to get past the failure. `NotDurable::Store` and `NotDurable::Flush` still hold a typed `PersistenceError` before the builder formats the reason. Preserve that classification and only recommend retry for a known transient cause; keep code 93, `NotSent`, and the cleared external outpoint for both cases.
In `packages/rs-platform-wallet-ffi/ERROR_CODE_REGISTRY.md`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/ERROR_CODE_REGISTRY.md:304: Assigning a different recipient to a recovered lock reports it as held
Impact: A host that attempts to replace a recovered lock’s recorded recipient gets a held outpoint to resume instead of the reconciliation result promised by the registry.
The updated code-61 registry row says a recovered lock returns `MaybeSent` without a held outpoint, but assignment can return the opposite. Assigning A leaves the lock in `RecoveredFromChain`. A later attempt to assign B reaches `check_identity_recipient_assignable`, which returns a bare `AssetLockIdentityRecipientMismatch`; the FFI conversion preserves its default `LockHeld` class and outpoint. Apply the same status-aware `without_held_lock()` conversion used by resume at the wallet’s assignment mismatch sites, using the row each site checks. Keep code 61 and the recorded identity in the diagnostic.
In `packages/rs-platform-wallet-ffi/src/error.rs`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/error.rs:1007-1008: Code 93 promises a zero outpoint after a callback can already have reported one
Impact: A host draining a CoinJoin account into Shielded can receive a real outpoint through its build callback and then receive code 93 for that abandoned lock.
A callback host can retain a nonzero outpoint even though the lock was abandoned and cannot be resumed. On a backend that records shielded recipients, the CoinJoin-drain path calls `on_asset_lock_built` before the recipient checkpoint. If that checkpoint fails and durable cleanup succeeds, the export’s `e.into()` now returns 93. Only the external identity top-up clears an out-parameter in `finish_external_top_up`; there is no second callback to retract an outpoint. Narrow the zero-outpoint promise to that export and explain that code 93 invalidates an earlier callback outpoint. This does not require changing the callback signature or the ordinary shielded funding route tracked in #6413.
In `packages/rs-platform-wallet/src/wallet/identity/network/registration.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:609-619: A failed recipient lookup can report the wrong lock as held or a known lock as unsent
(carried; thread: https://github.com/dashpay/platform/pull/5931#discussion_r4763784040)
In `packages/rs-platform-wallet/src/wallet/asset_lock/orchestration.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/asset_lock/orchestration.rs:828-837: A refused ChainLock fallback leaves a recovered row in a misleading settled status
(carried; thread: https://github.com/dashpay/platform/pull/5931#discussion_r4745844911)
| // A lock removed with its inputs released, never sent: a new | ||
| // call builds another and cannot pay twice. | ||
| Self::AssetLockAbandonedBeforeSend { .. } => true, | ||
| Self::PersisterLoad(source) | Self::PersisterStore(source) => source.is_transient(), |
There was a problem hiding this comment.
✅ Resolved at
d52d22c6; see the replies below.
🟡 Suggestion: A permanent checkpoint refusal tells the host to retry the same payment
Impact: A host following retryable can repeatedly rebuild and sign a top-up whose checkpoint the persister will keep rejecting.
Durable abandonment makes another payment safe, but it does not mean the same request can get past the storage refusal. For example, a typed funding-key conflict rejects the combined pool-and-lock checkpoint; the compensating removal has no pool snapshot and can succeed without correcting the conflict. The next build can submit the same conflicting snapshot. The new unconditional true arm conflates these two guarantees, even though is_retryable documents that the same call must be able to get past the failure. NotDurable::Store and NotDurable::Flush still hold a typed PersistenceError before the builder formats the reason. Preserve that classification and only recommend retry for a known transient cause; keep code 93, NotSent, and the cleared external outpoint for both cases.
source: gpt-6.2-astra (phase2-reviewer: general, architecture-layering, ffi-engineer, rust-quality, security-auditor)
There was a problem hiding this comment.
Fixed in d52d22c. AssetLockAbandonedBeforeSend now carries retryable, set from the typed store error before it is formatted: true only for a transient PersistenceError or another flush still settling (OtherFlushUnsettled), false for a permanent refusal or a lost flush. Code 93, NotSent and the cleared external outpoint are unchanged. The non-transient flush-failure build test now asserts not retryable, and should_retry_an_abandoned_lock_only_after_a_transient_store_failure pins both values; FFI doc and registry row 93 updated.
There was a problem hiding this comment.
Resolved (re-reviewed at d52d22c6): The builder now reads the typed durability failure before formatting it and passes its retry decision through the abandonment error. A permanent refusal still returns code 93 and NotSent, but no longer recommends repeating the request.
| | 59 | `ErrorSpvProcessRestartRequired` | #5322 | Proposed — SPV startup or teardown panicked; restart the host process. Not retryable, unlike 27, which SPV start, stop and storage clear now return while an SPV teardown is still running. Typed in Rust, Swift and Kotlin (the PR also types 27 on Kotlin) | | ||
| | 60 | `ErrorAssetLockTooManyInputs` | Core-to-shielded pooled Max | Proposed — an asset lock needs more inputs than one may carry (100 on Dash Core relay policy, and in Platform consensus for an instant proof): the full drain, or since #5712 a fixed amount held only in many small coins (identity registration, top-up, invitation, platform-address funding). Two meanings. On a build: nothing was broadcast, the reservation is released, no partial drain, and a rebuild after consolidating is safe. On the resume of a tracked `Built` / `Broadcast` lock over the cap (since #5714): it is not re-sent, but an earlier attempt may have reached peers; the row stays tracked and nothing is released. Rust, Swift and Kotlin retain the typed refusal. Renumbered from 59 after #5322 claimed it | | ||
| | 61 | `ErrorAssetLockRecipientMismatch` | dashpay/platform#5603 (tracked-lock shielded recipient) | Proposed — a shielded fund-from-asset-lock resume (the generic outpoint resume or a repeated-UUID wallet drain) names a different Orchard recipient than the one the tracked lock recorded when it was built. Nothing was submitted or paid; resume with the recorded recipient, which the row and `TrackedAssetLockFFI` expose. Rows tracked before recipients were recorded carry none and accept the caller's. Typed in Rust, Swift and Kotlin | | ||
| | 61 | `ErrorAssetLockRecipientMismatch` | dashpay/platform#5603 (tracked-lock shielded recipient) | Proposed — a shielded fund-from-asset-lock resume (the generic outpoint resume or a repeated-UUID wallet drain) names a different Orchard recipient than the one the tracked lock recorded when it was built. Nothing was submitted or paid; resume with the recorded recipient, which the row and `TrackedAssetLockFFI` expose. Rows tracked before recipients were recorded carry none and accept the caller's. Since #5931 also an identity top-up resume or assignment that names another identity than the one an unbound top-up lock (`IdentityTopUpNotBound`) recorded (`PlatformWalletError::AssetLockIdentityRecipientMismatch`): resume it to the recorded identity, which the row exposes. The call submitted nothing new, but use the held lock only when `payment_delivery` is `LockHeld`; a lock recovered from the chain returns `MaybeSent` with no held outpoint and needs reconciliation instead. Typed in Rust, Swift and Kotlin | |
There was a problem hiding this comment.
✅ Resolved at
d52d22c6; see the replies below.
🟡 Suggestion: Assigning a different recipient to a recovered lock reports it as held
Impact: A host that attempts to replace a recovered lock’s recorded recipient gets a held outpoint to resume instead of the reconciliation result promised by the registry.
The updated code-61 registry row says a recovered lock returns MaybeSent without a held outpoint, but assignment can return the opposite. Assigning A leaves the lock in RecoveredFromChain. A later attempt to assign B reaches check_identity_recipient_assignable, which returns a bare AssetLockIdentityRecipientMismatch; the FFI conversion preserves its default LockHeld class and outpoint. Apply the same status-aware without_held_lock() conversion used by resume at the wallet’s assignment mismatch sites, using the row each site checks. Keep code 61 and the recorded identity in the diagnostic.
source: gpt-6.2-astra (phase2-reviewer: general, architecture-layering, ffi-engineer, rust-quality, security-auditor)
There was a problem hiding this comment.
Fixed in d52d22c. Both assignment mismatch sites (the pre-store check and the in-memory publish) go through one helper that names the lock as held only while it is resumable, as a resume does: a RecoveredFromChain lock is MaybeSent with no held outpoint, keeping code 61 and the recorded identity. Test should_name_a_lock_held_on_an_assignment_mismatch_only_while_it_is_resumable. Kotlin's code-61 doc in #5933 says the same.
There was a problem hiding this comment.
Resolved (re-reviewed at d52d22c6): Both mismatch sites now call assignment_recipient_mismatch on the row they inspect. The recovered case preserves the mismatch diagnostic but returns MaybeSent without a held outpoint.
| /// lock and cannot pay twice. An export that reports the built outpoint | ||
| /// reports it all zero for this code. |
There was a problem hiding this comment.
🟡 Suggestion: Code 93 promises a zero outpoint after a callback can already have reported one
Impact: A host draining a CoinJoin account into Shielded can receive a real outpoint through its build callback and then receive code 93 for that abandoned lock.
A callback host can retain a nonzero outpoint even though the lock was abandoned and cannot be resumed. On a backend that records shielded recipients, the CoinJoin-drain path calls on_asset_lock_built before the recipient checkpoint. If that checkpoint fails and durable cleanup succeeds, the export’s e.into() now returns 93. Only the external identity top-up clears an out-parameter in finish_external_top_up; there is no second callback to retract an outpoint. Narrow the zero-outpoint promise to that export and explain that code 93 invalidates an earlier callback outpoint. This does not require changing the callback signature or the ordinary shielded funding route tracked in #6413.
| /// lock and cannot pay twice. An export that reports the built outpoint | |
| /// reports it all zero for this code. | |
| /// lock and cannot pay twice. The external identity top-up clears its | |
| /// outpoint output; an outpoint already delivered to a build callback | |
| /// identifies the abandoned lock and must not be resumed. |
source: gpt-6.2-astra (phase2-reviewer: general, architecture-layering, ffi-engineer, rust-quality, security-auditor)
There was a problem hiding this comment.
Still applies (re-reviewed at d52d22c6): The new wording correctly qualifies retryability. The zero-outpoint sentence still includes the CoinJoin-drain export, which returns 93 through the typed conversion after its callback has already received the actual outpoint.
| let chain_proof = self | ||
| .upgrade_to_persisted_chain_lock_proof(out_point, cl_wait) | ||
| .await?; | ||
| let authorize = |current: &TrackedResumeMetadata| { | ||
| authorize_top_up_resume(*out_point, identity, current) | ||
| }; | ||
| let (_, path) = self | ||
| .resume_authorized_asset_lock(out_point, cl_wait, &authorize) | ||
| .await?; |
There was a problem hiding this comment.
Still applies (re-reviewed at 529c41c9): The new wrapper fixes the returned delivery class, but the separate proof helper still queues ChainLocked before the recipient check runs. The status-preserving proof refresh elsewhere does not guard this path, so a refusal can still change the next tracked-lock listing.
| let identity = match self.fetch_identity_to_pay(identity_id).await { | ||
| Ok(identity) => identity, | ||
| Err(error) => { | ||
| return Err(match &funding { | ||
| AssetLockFunding::FromExistingAssetLock { out_point, .. } | ||
| if self | ||
| .asset_locks | ||
| .tracked_resume_metadata(out_point) | ||
| .await | ||
| .is_some() => | ||
| { | ||
| self.asset_locks | ||
| .funded_lock_error(error, Some(*out_point)) | ||
| .await | ||
| } | ||
| _ => error, |
There was a problem hiding this comment.
Still applies (re-reviewed at 529c41c9): #5516 still covers the removal-during-lookup case, but this head newly exposes the wrong-lock verdict through the managed API: its lookup previously returned IdentityNotFound directly, and now it can report an unrelated live row as held. That part can be prevented without holding a lifecycle gate across the lookup.
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
…-up fallback, and retry an abandoned lock only after a transient failure - `upgrade_to_persisted_chain_lock_proof` keeps a `RecoveredFromChain` row in that status, as a resume does: a refused top-up fallback no longer lists a recipient-less recovered lock as an unassigned top-up. - `AssetLockAbandonedBeforeSend` carries `retryable`, true only when the store's failure was transient or another flush was still settling; a permanent refusal (a key conflict) meets the same refusal again. - An assignment that names another identity than the lock records names the lock as held only while it is resumable, as a resume does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Waiting for bot review — thepastaclaw reviewed an earlier commit, not yet this one. 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 makes retryability depend on the checkpoint failure, makes assignment mismatches status-aware, and adds a ChainLock fallback path that preserves the status of a row that stays recovered. No build or test result is listed for this head; PastaClaw review and PR Hygiene are pending. The branch conflicts with the current v5.2-dev tip.
🟡 4 suggestion(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
Still open from earlier rounds (2)
- 🟡 Suggestion: Code 93 promises a zero outpoint after a callback can already have reported one —
packages/rs-platform-wallet-ffi/src/error.rs:1009-1010(thread) - 🟡 Suggestion: A failed recipient lookup can report the wrong lock as held or a known lock as unsent —
packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:604-622(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 large, intricate changes in rs-platform-wallet/src/wallet/asset_lock/build.rs alter how Core funds are committed to an identity recipient, including when locks are persisted and broadcast and when reserved inputs can be released after a 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/asset_lock/sync/proof.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/asset_lock/sync/proof.rs:552-560: A refused ChainLock fallback leaves a recovered row in a misleading settled status
Impact: If wallet reload and Core sync interleave with a top-up fallback, a host can see a recipient-less lock whose consumption is unknown in the ordinary unassigned list, even though the fallback did not pay it.
A refused fallback can still put a recovered lock back in the ordinary unassigned list. The new test covers a row that stays `RecoveredFromChain`, but if the first write sees a recovered row and the second sees a live row, the third reacquires the manager guard through `advance_asset_lock_status`, whose predicate is `|_| true`. For example, a replacement wallet can reload a proof-less `Broadcast` row, then Core sync can mark it `RecoveredFromChain` before the third write. That write queues `ChainLocked` before the resume rejects the stale generation; the listing exposes the recipient-less row as unassigned. Select the destination status from the row under the same write guard that attaches the proof, retaining the consumed-row refusal.
In `packages/rs-platform-wallet/src/error.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/error.rs:4296-4304: The transient-abandonment test passes even if the builder disables every retry
Impact: A regression that disables retry after a temporary checkpoint failure would leave callers unable to retry the same request while the new tests still pass.
The tests would not catch a builder that always returns `retryable: false`. This test supplies the boolean itself and only checks the accessor, while the builder-level test checks a permanent failure. Exercise the public external top-up with a mock identity lookup and a persister that fails only the recipient checkpoint transiently, then accepts the withdrawal. The existing `CapturingPersistence` fixture supports a one-shot transient flush failure. Assert that the wallet returns `NotSent` with retry enabled and never calls the broadcaster.
In `packages/rs-platform-wallet-ffi/src/error.rs`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/error.rs:1009-1010: Code 93 promises a zero outpoint after a callback can already have reported one
(carried; thread: https://github.com/dashpay/platform/pull/5931#discussion_r4790456181)
In `packages/rs-platform-wallet/src/wallet/identity/network/registration.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/registration.rs:604-622: A failed recipient lookup can report the wrong lock as held or a known lock as unsent
(carried; thread: https://github.com/dashpay/platform/pull/5931#discussion_r4763784040)
| // The row left `RecoveredFromChain` in between: advanced | ||
| // as any other. | ||
| None => { | ||
| self.advance_asset_lock_status( | ||
| out_point, | ||
| AssetLockStatus::ChainLocked, | ||
| Some(chain_proof.clone()), | ||
| ) | ||
| .await? |
There was a problem hiding this comment.
🟡 Suggestion: A refused ChainLock fallback leaves a recovered row in a misleading settled status
Impact: If wallet reload and Core sync interleave with a top-up fallback, a host can see a recipient-less lock whose consumption is unknown in the ordinary unassigned list, even though the fallback did not pay it.
A refused fallback can still put a recovered lock back in the ordinary unassigned list. The new test covers a row that stays RecoveredFromChain, but if the first write sees a recovered row and the second sees a live row, the third reacquires the manager guard through advance_asset_lock_status, whose predicate is |_| true. For example, a replacement wallet can reload a proof-less Broadcast row, then Core sync can mark it RecoveredFromChain before the third write. That write queues ChainLocked before the resume rejects the stale generation; the listing exposes the recipient-less row as unassigned. Select the destination status from the row under the same write guard that attaches the proof, retaining the consumed-row refusal.
source: gpt-6.2-astra (phase2-reviewer: general, architecture-layering, ffi-engineer, rust-quality, security-auditor)
| fn should_retry_an_abandoned_lock_only_after_a_transient_store_failure() { | ||
| for retryable in [false, true] { | ||
| let error = PlatformWalletError::AssetLockAbandonedBeforeSend { | ||
| out_point: out_point(), | ||
| reason: "row not durable".into(), | ||
| retryable, | ||
| }; | ||
| assert_eq!(error.payment_delivery(), PaymentDelivery::NotSent); | ||
| assert_eq!(error.is_retryable(), retryable); |
There was a problem hiding this comment.
🟡 Suggestion: The transient-abandonment test passes even if the builder disables every retry
Impact: A regression that disables retry after a temporary checkpoint failure would leave callers unable to retry the same request while the new tests still pass.
The tests would not catch a builder that always returns retryable: false. This test supplies the boolean itself and only checks the accessor, while the builder-level test checks a permanent failure. Exercise the public external top-up with a mock identity lookup and a persister that fails only the recipient checkpoint transiently, then accepts the withdrawal. The existing CapturingPersistence fixture supports a one-shot transient flush failure. Assert that the wallet returns NotSent with retry enabled and never calls the broadcaster.
source: gpt-6.2-astra (phase2-reviewer: rust-quality)
| let chain_proof = self | ||
| .upgrade_to_persisted_chain_lock_proof(out_point, cl_wait) | ||
| .await?; | ||
| let authorize = |current: &TrackedResumeMetadata| { | ||
| authorize_top_up_resume(*out_point, identity, current) | ||
| }; | ||
| let (_, path) = self | ||
| .resume_authorized_asset_lock(out_point, cl_wait, &authorize) | ||
| .await?; |
There was a problem hiding this comment.
Still applies (re-reviewed at d52d22c6): Your regression test verifies that a row which stays recovered keeps its status. The two conditional writes do check under their guards, but the final None arm acquires a third guard with no recovery-status predicate, so a sync promotion after the second check can still be overwritten.
| // A lock removed with its inputs released, never sent: a new | ||
| // call builds another and cannot pay twice. | ||
| Self::AssetLockAbandonedBeforeSend { .. } => true, | ||
| Self::PersisterLoad(source) | Self::PersisterStore(source) => source.is_transient(), |
There was a problem hiding this comment.
Resolved (re-reviewed at d52d22c6): The builder now reads the typed durability failure before formatting it and passes its retry decision through the abandonment error. A permanent refusal still returns code 93 and NotSent, but no longer recommends repeating the request.
| | 59 | `ErrorSpvProcessRestartRequired` | #5322 | Proposed — SPV startup or teardown panicked; restart the host process. Not retryable, unlike 27, which SPV start, stop and storage clear now return while an SPV teardown is still running. Typed in Rust, Swift and Kotlin (the PR also types 27 on Kotlin) | | ||
| | 60 | `ErrorAssetLockTooManyInputs` | Core-to-shielded pooled Max | Proposed — an asset lock needs more inputs than one may carry (100 on Dash Core relay policy, and in Platform consensus for an instant proof): the full drain, or since #5712 a fixed amount held only in many small coins (identity registration, top-up, invitation, platform-address funding). Two meanings. On a build: nothing was broadcast, the reservation is released, no partial drain, and a rebuild after consolidating is safe. On the resume of a tracked `Built` / `Broadcast` lock over the cap (since #5714): it is not re-sent, but an earlier attempt may have reached peers; the row stays tracked and nothing is released. Rust, Swift and Kotlin retain the typed refusal. Renumbered from 59 after #5322 claimed it | | ||
| | 61 | `ErrorAssetLockRecipientMismatch` | dashpay/platform#5603 (tracked-lock shielded recipient) | Proposed — a shielded fund-from-asset-lock resume (the generic outpoint resume or a repeated-UUID wallet drain) names a different Orchard recipient than the one the tracked lock recorded when it was built. Nothing was submitted or paid; resume with the recorded recipient, which the row and `TrackedAssetLockFFI` expose. Rows tracked before recipients were recorded carry none and accept the caller's. Typed in Rust, Swift and Kotlin | | ||
| | 61 | `ErrorAssetLockRecipientMismatch` | dashpay/platform#5603 (tracked-lock shielded recipient) | Proposed — a shielded fund-from-asset-lock resume (the generic outpoint resume or a repeated-UUID wallet drain) names a different Orchard recipient than the one the tracked lock recorded when it was built. Nothing was submitted or paid; resume with the recorded recipient, which the row and `TrackedAssetLockFFI` expose. Rows tracked before recipients were recorded carry none and accept the caller's. Since #5931 also an identity top-up resume or assignment that names another identity than the one an unbound top-up lock (`IdentityTopUpNotBound`) recorded (`PlatformWalletError::AssetLockIdentityRecipientMismatch`): resume it to the recorded identity, which the row exposes. The call submitted nothing new, but use the held lock only when `payment_delivery` is `LockHeld`; a lock recovered from the chain returns `MaybeSent` with no held outpoint and needs reconciliation instead. Typed in Rust, Swift and Kotlin | |
There was a problem hiding this comment.
Resolved (re-reviewed at d52d22c6): Both mismatch sites now call assignment_recipient_mismatch on the row they inspect. The recovered case preserves the mismatch diagnostic but returns MaybeSent without a held outpoint.
| /// lock and cannot pay twice. An export that reports the built outpoint | ||
| /// reports it all zero for this code. |
There was a problem hiding this comment.
Still applies (re-reviewed at d52d22c6): The new wording correctly qualifies retryability. The zero-outpoint sentence still includes the CoinJoin-drain export, which returns 93 through the typed conversion after its callback has already received the actual outpoint.
…latform-wallet-top-up-someone-elses-identity-fr # Conflicts: # packages/rs-platform-wallet-ffi/ERROR_CODE_REGISTRY.md # packages/rs-platform-wallet/src/error.rs
|
Waiting for bot review — thepastaclaw reviewed an earlier commit, not yet this one. 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 head is a merge of the reviewed wallet changes with v5.2-dev, bringing in the shielded identity-create outcome and resolving error-code and registry conflicts. Rust wallet tests, Swift SDK tests, Swift schema checks, and Kotlin SDK tests pass; the full Rust workspace and broader suites are skipped, while the review and PR Hygiene checks remain pending.
🟡 3 suggestion(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
Still open from earlier rounds (3)
- 🟡 Suggestion: The transient-abandonment test passes even if the builder disables every retry —
packages/rs-platform-wallet/src/error.rs:4344-4352(thread) - 🟡 Suggestion: A refused ChainLock fallback leaves a recovered row in a misleading settled status —
packages/rs-platform-wallet/src/wallet/asset_lock/sync/proof.rs:552-560(thread) - 🟡 Suggestion: Code 93 promises a zero outpoint after a callback can already have reported one —
packages/rs-platform-wallet-ffi/src/error.rs:1031-1032(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: rust-quality); reviewer 7: 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) — This is a large, intricate change that directly alters funds movement and coin selection inwallet/asset_lock/build.rsandwallet/asset_lock/orchestration.rs, signing-key handling, and durable storage migrations such asV025__asset_lock_identity_recipient.rs. - 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— 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/error.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/error.rs:4344-4352: The transient-abandonment test passes even if the builder disables every retry
(carried; thread: https://github.com/dashpay/platform/pull/5931#discussion_r4793208514)
In `packages/rs-platform-wallet/src/wallet/asset_lock/sync/proof.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/asset_lock/sync/proof.rs:552-560: A refused ChainLock fallback leaves a recovered row in a misleading settled status
(carried; thread: https://github.com/dashpay/platform/pull/5931#discussion_r4793208510)
In `packages/rs-platform-wallet-ffi/src/error.rs`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/error.rs:1031-1032: Code 93 promises a zero outpoint after a callback can already have reported one
(carried; thread: https://github.com/dashpay/platform/pull/5931#discussion_r4790456181)
| let identity = match self.fetch_identity_to_pay(identity_id).await { | ||
| Ok(identity) => identity, | ||
| Err(error) => { | ||
| return Err(match &funding { | ||
| AssetLockFunding::FromExistingAssetLock { out_point, .. } | ||
| if self | ||
| .asset_locks | ||
| .tracked_resume_metadata(out_point) | ||
| .await | ||
| .is_some() => | ||
| { | ||
| self.asset_locks | ||
| .funded_lock_error(error, Some(*out_point)) | ||
| .await | ||
| } | ||
| _ => error, |
There was a problem hiding this comment.
Deferred (re-reviewed at 3325d467): The lookup boundary still does not retain the authorized row and generation across the await. The wrong-recipient and wallet-turnover cases remain part of the tracked lifecycle follow-up rather than a regression in this merge.
|
Bots are done — your move: address lklimek requested changes; romchornyi left a review thread unresolved, then post |
Basic explanation
What this does: A wallet can now pay Dash from its Core balance into an identity it does not own (someone else's identity). It builds an asset lock (a Core transaction that turns Dash into Platform credits) from the wallet's shared "unbound" top-up account, and saves on the lock's row which identity it is meant for before the lock is sent. If the app is killed mid-way, the top-up resumes to that saved identity, and to no other.
Value: Wallets can enable Core → any identity ID in their send flows (dash-wallet#1680, dashwallet-ios#1406–#1409). Today that pair is disabled, so Core-only users must first move funds to Shielded or Platform to pay an identity. It also closes a gap where a resume of an unbound top-up lock accepted any identity, so a host's recovery could pay an interrupted top-up of someone else's identity into the holder's own.
Risks: Low to medium. No consensus change: the
IdentityTopUptransition is unchanged. Top-ups of the wallet's own identities (bound locks) behave as before. Unbound top-up locks are stricter now (see Breaking Changes): one with no recorded identity, such as one rebuilt from the seed, is no longer resumed into any identity until the user assigns one. No test shows a confirmed external top-up end to end; the mock SDK cannot produce one for this transition, so that needs a testnet send.Issue being fixed or feature implemented
Part of #5924 (this PR is the Rust and FFI part; Kotlin is #5933, Swift #6139).
IdentityWallet::top_up_identity_with_fundingonly tops up identities in the wallet'sIdentityManager, and a tracked asset lock recorded no recipient for an identity top-up. On resume, an unbound top-up lock (IdentityTopUpNotBound) was "deliberately eligible for any target", so the identity came from the caller. A host recovery passes its own identity, so both wallets kept Core → someone else's identity disabled.What was done?
Recipient recorded on the lock (
rs-platform-wallet)TrackedAssetLock/AssetLockEntrygainidentity_recipient: Option<Identifier>, kept immutable throughAssetLockChangeSet::mergeandapply.rs, likeshielded_recipient.AssetLockRecipient(Shielded(raw)orIdentity(id)) instead ofshielded_recipient;recorded_recipientsdecides what a lock records. An unbound top-up lock must name its identity, and is built only for a persister declaringPersistenceCapabilities::IDENTITY_RECIPIENT_TOP_UP: the newASSET_LOCK_IDENTITY_RECIPIENTS(bit 17, after feat(platform-wallet): keep masternode collateral out of coin selection #5890'sOUTPOINT_LOCKSat 16) together withATOMIC_CHANGESETSandASSET_LOCK_FUNDING_INDICES, so the lock, its recipient and its signing-key index are kept together across a restart. Its row is made durable withWalletPersister::store_durablybefore the broadcast, in the same write as the funding-pool snapshot that records its signing-key index, so the two commit together or not at all. The row is removed durably if the broadcast is rejected, so a lost removal cannot bring back a lock resumable to that recipient after the user re-sent. If the row's store or flush fails, its removal is stored behind it; if that removal is refused too, the inputs stay reserved, because the row may survive (a host without atomic changesets can write it and fail on the recipient). Every exit where the row may survive returnsTransactionBroadcastUnconfirmed(FFI 20) with the outpoint: reconcile, don't retry. A removed row with its inputs released stays a retry-safePersistenceerror. The build-only API (build_asset_lock_transaction) refuses unbound top-up locks, since it tracks nothing.AssetLockManagerkeeps the generation of the wallet it was registered with. A build through a handle whose wallet was since replaced is refused (WalletRemovedBeforeSend) before anything is selected, reserved or signed, and a lock is tracked only on the generation that built it.TransactionBroadcastUnconfirmed(20).WalletPersister::store_durably. A rejected broadcast removes the row durably for every funding type before giving the retry-safe verdict (26); if the removal isn't durable, the inputs stay reserved and the result is 20. Inputs are released only once the removal is durable.store_durablyroutes through a newPlatformWalletPersistence::commit_durablywhen the backend implements it: the backend merges and writes the changeset with its buffer and answers for that write itself.SqlitePersisterimplements it under one connection guard in either flush mode, so a drain through its publiccommit_writes()cannot make a durable store succeed over a buffer that no longer holds the write. Other backends keep the flush-ledger check.PlatformWalletPersistence::release_unsent_pool_address(default no-op; SQLite clears the row's mark after writing its buffer), under the wallet lock and, for a rejected broadcast, under the build-to-persist gate, so a concurrent build's pool snapshot cannot mark the index used again on disk.AssetLockAbandonedBeforeSend(safe to retry; the external top-up export zeroes its outpoint), but only while the build's generation is still the wallet's once the removal is durable; otherwise it isTransactionBroadcastUnconfirmed, keeping the outpoint, index and inputs, as the send's generation check does.validate_existing_asset_lock_role: an unbound lock serves a top-up only of the identity it recorded. Another identity isAssetLockIdentityRecipientMismatch; no recorded identity isAssetLockRecipientUnknown. The resume checks it again on the row it claims, under the wallet guard it takes the dispatch claim under (resume_authorized_asset_lock), so a row removed and recreated at the same outpoint for another identity between the check and the claim is not paid to the first.IdentityWallet::assign_identity_top_up_recipientrecords an identity the user picks for a lock that records none. Every build of an unbound lock records its recipient, so a lock without one was rebuilt from the chain, recovered from a host's record, or built before V024: Platform may already have used it, whatever its status. It is assigned only withacknowledge_unknown_consumption, and is the newAssetLockConsumptionUnknown(FFI 90, distinct from 24, a confirmed use) otherwise.TrackedAssetLock::is_unassigned_identity_top_uplists the likely-unspent ones (live statuses); aRecoveredFromChainlock is not listed but is assigned the same way. Platform uses an outpoint once, so if it already used the lock, the resume is refused there and reports 24: the acknowledgement cannot pay twice.IdentityNotFound, a failed lookupIdentityLookupFailed(80), and nothing is assigned.WalletRemovedBeforeSend).PlatformWalletPersistence::assign_asset_lock_identity_recipient: never a snapshot of the row, so a proof or status sync recorded meanwhile stays, and a swept (missing) row is refused rather than written back.Okmeans committed. A refused backend write leaves nothing behind, so any identity may be assigned afterwards; another error (the lock found swept, consumed or recording another recipient after the commit) does not establish that, and the docs tell hosts to read the tracked lock before offering another identity. SQLite writes its buffer first, then runs a recipient-onlyUPDATEin its own transaction; FFI sends the recipient callback alone in an atomic round of its own, which a host refuses for a missing or consumed row. The call is counted in the flush ledger like a flush. A refusal or failure after the buffer's commit is marked (PersistenceError::after_buffer_committed), so the ledger does not count it as a lost flush and the handle's later durable flushes are not refused.AssetLockIdentityRecipientMismatch).IDENTITY_RECIPIENT_TOP_UPcapabilities as the build.External top-up and resume (
wallet/identity/network/registration.rs)top_up_external_identity_with_funding: fetches the identity from Platform (unknown →IdentityNotFound, failed lookup →IdentityLookupFailed(80); nothing built), funds an unbound lock recording it, submits with the managed top-up's IS→CL fallbacks, consumes the lock. Writes nothing to the identity manager.resume_identity_top_up_to_recorded_recipient: takes no identity and resumes any identity top-up lock, so hosts need no classifier. A bound lock pays the wallet's identity at its index (AssetLockIdentityNotLoaded, FFI 7, if that identity is not loaded yet); an unbound lock pays the identity it recorded. An identity the wallet holds goes through the managed path, any other through the external path.submit_top_up_with_funding(funding, submit, reconcile, lock cleanup). The external top-up and the assignment share one Platform lookup.min_top_up_duffs(): the largestIdentityTopUpTransition::calculate_min_required_feeacross every supported protocol version (50,500 duffs today), instead of a literal. It does not depend on the SDK's current version, which can change during the identity fetch. It applies to both Core top-ups. A smaller amount is refused. A drain gets the minimum as its floor. The shared builder (wallet/asset_lock/top_up_floor.rs) holds everyIdentityTopUpandIdentityTopUpNotBoundlock to it before anything is selected, soasset_lock_manager_create_funded_proofrefuses a smaller exact amount too.AssetLockAlreadyConsumed(24) before a missing recipient, as the unassigned listing and the assignment do.FFI (
rs-platform-wallet-ffi)platform_wallet_top_up_external_identity_with_funding_signer,platform_wallet_resume_identity_top_up_to_recorded_recipient_signer,platform_wallet_assign_identity_top_up_recipient(returns 7 for an identity Platform doesn't know). The external top-up's last parameter,out_asset_lock_outpoint, receives the built lock's outpoint, also when the call fails after the build; all zero means nothing was built and a retry is safe. All three read the wallet out of the registry and release it before awaiting, convert a panic to a result code instead of unwinding through the C ABI (20 for the two paying exports, 6 for the assignment), and refuse a call made from inside a wallet callback (6, outputs zeroed) instead of panicking inblock_on, which aborts under the iOS profiles.ensure_not_on_runtimeis no longer shielded-only.on_persist_asset_lock_identity_recipient_fn/on_load_asset_lock_identity_recipient_fnappended toPersistenceCallbacksExtensionafter feat(platform-wallet): keep masternode collateral out of coin selection #5890's outpoint-lock callbacks; the recipient loader is called only for a host declaring bit 17;PLATFORM_WALLET_PERSISTENCE_CAPABILITY_ASSET_LOCK_IDENTITY_RECIPIENTS(bit 17) attested when both slots, the asset-lock persist callback and the wallet-list restore pair are wired.TrackedAssetLockFFIandTrackedAssetLockEntryFFIgainhas_identity_recipient, the 32-byte recipient andidentity_recipient_unassigned.platform_wallet_assign_identity_top_up_recipienttakesbool acknowledge_unknown_consumption.on_persist_asset_lock_identity_recipient_fncan also arrive in a round of its own with no row upsert (an assignment); the host applies it to the stored row and refuses it when it stores none.ErrorAssetLockRecipientUnknown = 89andErrorAssetLockConsumptionUnknown = 90; a failed identity lookup uses feat(platform-wallet)!: top up an identity the wallet does not manage from Platform addresses #5860's 80;ErrorAssetLockRecipientMismatch(61) now also covers identity recipients. Code 23 (not tracked) is documented as not a retry verdict.ERROR_CODE_REGISTRY.mdupdated, next free 91. They were 81 and 82 untild7d22a95fc, renumbered because feat(platform-wallet): plan a shielded spend with its exact fee and spend against the plan #5865 holds 81, feat: expose the Rust identity key layout to FFI, Swift and Kotlin hosts #5647 holds 82, and 83–88 are taken onv5.2-dev; no open PR claims 89 or 90.SQLite storage (
rs-platform-wallet-storage)V024__asset_lock_identity_recipient.rs(afterv5.2-dev's V021–V023, feat(platform-wallet): keep masternode collateral out of coin selection #5890's locked outpoints the last): nullable 32-byteasset_locks.identity_recipientcolumn plus an immutability trigger;load_unconsumedkeeps consumed rows that record a recipient, so a finished top-up is not rebuilt as unassigned, and apply skips a conflicting recipient on a consumed row;SqlitePersisterdeclares bit 17;SCHEMA.mdand the migration fingerprints updated.assign_identity_recipient: the recipient-only assignment (outcome: assigned, already recorded, no row, another identity, consumed).ASSET_LOCK_FUNDING_INDICES.restore_account_address_pools, the FFI loader's restore: a missing or undecodable row is derived from the account xpub and marked used, and a pool that cannot reach its rows gets an issuance floor, now forwarded inClientWalletStartState::funding_issuance_floors, instead of failing the wallet's load. A row whose address its index does not derive is replaced by the derived address and key, marked used, and a later pool snapshot replaces the stored row's key and script together (FUNDING_POOL_CONFLICT_SQL) instead of failing as a key conflict. An undecodable used row is kept used the same way, or floors issuance where the account cannot derive.addresses_derived, as unused rows) and the ones it marks used (addresses_marked_used), so a lock found by sync, or the window it moved, survives a restart with no pool snapshot after it.load_typed_pool_entriesnow filters by every account discriminator.#5794'sstatus_ofreads the recipient column with the other recovery columns.release_unsent_pool_address: clears one funding row's used mark after writing the buffer, matched by script so another wallet's row is untouched.How Has This Been Tested?
On
95643fe88a(merged withv5.2-devata56fc48857):cargo test -p platform-wallet --lib --all-features(3000 passed),cargo test -p platform-wallet-ffi --lib(652 passed, 1 ignored),cargo test -p platform-wallet-storage(520 unit, 614 integration), andcargo clippy -p platform-wallet -p platform-wallet-ffi -p platform-wallet-storage -p rs-unified-sdk-jni --all-features --all-targets -- -D warnings(clean). New tests:asset_lock/build.rs: a build through a handle of a replaced wallet is refused with nothing reserved; a lock built on a wallet replaced before the send is removed durably with its inputs released, kept when a resume or the replacement may still send it, and kept fenced when the removal is not durable; an abandoned row's removal that cannot be flushed keeps the inputs reserved, and one removed inline survives a failed flush notification; an assignment on a replaced wallet is refused; an unbound lock is refused without a recipient, with a non-identity recipient, or on a persister without bit 17, with nothing stored or broadcast; the recipient is flushed before the broadcast and a failed flush stops it; a rejected lock's removal is flushed, and a failed one is reported; the build-only API refuses unbound locks; assigning a recipient once and refusals; a failed assignment store keeps the identity, refuses another and is retried by assigning it again.asset_lock/build.rs(review fixes): an unbound top-up is refused on a backend without atomic changesets, and when its funding pool was not stored, handing its index back however often that fails; a top-up lock below the minimum is refused at the builder; a lock built on a wallet since replaced is kept; an assignment the backend refused is not published and leaves nothing behind; the recipient alone is written, never a row snapshot; a lock the backend no longer stores is refused; a recovered lock is assigned only when acknowledged; the build-only API is held to the minimum; a rejected lock of every funding type is removed durably or reported as 20; a rejected lock hands its funding index back; the pool is stored in the row's own write.wallet/persister.rs: a backend that commits durably answers for the write, a failed commit or assignment counts as a lost flush, and an assignment refused after the buffer's commit does not.asset_lock/build.rs(later fixes): a rejected lock's funding index is released on disk, and only under the build-to-persist gate; a committed assignment is not published over a recreated row's recipient; a resume's authorization runs on the row it claims and a refusal sends nothing and leaves no claim.commit_durablyin Manual mode, and its failure classification; the recipient-only assignment keeps the stored status and refuses another identity, a consumed row and a missing one, marked as after the buffer's commit; an assignment writes the buffer first. Funding pools (sqlite_used_core_addresses.rs): a pool beyond its initial window survives a restart; a used-up pool is not extended; a released unsent address's mark is cleared; the window sync derived comes back; a sync-only used mark survives a reopen; rows without a public key load; an upgraded pool extends past a lock stored in a block but not past a mempool one; a damaged row comes back as the derived address, used.asset_lock/build.rs(second review): a lock whose funding address its key does not derive is refused with nothing sent; a recipient-less lock of every status is assigned only when acknowledged; an abandon during which the wallet turned over reports an unknown outcome. Storage: a damaged funding row with a key is repaired in the store; an unreadable used row stays used under recovery.asset_lock/top_up_floor.rs: the minimum is the largest across every protocol version.asset_lock/orchestration.rs: the validator and the funding resolver refuse another identity (61) and an unrecorded lock (89).identity/network/registration.rs: both Core top-ups refuse an amount below the minimum, and a drain gets the minimum as its floor; an assignment to an identity Platform doesn't know is refused and the lock stays unassigned; a failed identity lookup is reported (80) before anything is built or assigned; the external top-up refuses an unknown identity and a persister that cannot record, building nothing; the resume refuses untracked, registration and unassigned locks, resolves a bound lock to the wallet's identity at its index (or refuses it when none is loaded), and sends a foreign recorded identity down the external path; a top-up balance lands on an identity the wallet holds.changeset.rs,apply.rs: the recipient survives stale snapshots and a conflicting one is dropped.rs-platform-wallet-ffi: panic-to-code mapping for the new exports; persistence round trip and capability attestation, error mapping (61, 89, 90), null-pointer and handle guards on the new exports, extension layout pins.sqlite_asset_locks_filter.rs: column round trip, immutability, fail-closed load of a malformed recipient, capability advertised, consumed rows keep their recipient, a conflicting recipient on a consumed row is skipped.The plan review on #5924 was checked against this PR; six of its gaps are fixed here (capability bit, durable removal of a rejected recipient lock, bound locks in the identity-less resume, build-only refusal, balance of a held identity, docs) and the rest are handled or listed under Known limitations. Local pre-reviews with the review bot's prompts: every finding is fixed except one, which several rounds list: an unbound lock with no recorded identity gets 89 on mobile until PR B/C bind the assignment and persistence. That is deliberate; see "Release order" under Breaking Changes.
The review bot's round on
3b30b1e4b0is addressed in282c6df764: fixed the broadcast after wallet removal (in the shared build path), the inputs released after a refused row store, the protocol-versioned minimum, the consumed-lock error order and the assignment doc. Declined, with replies on the threads: the tracked-lock array layout (same decision as #5762; the bot withdrew it) and the cached balance a top-up returns. The bot's round on282c6df764is addressed in6c3548a227,93c61ac126and4cb8c71387: the unsent lock of a replaced wallet is removed (or kept when it may still be sent), the assignment is generation-gated, the minimum no longer depends on the SDK's current version, the external top-up returns the proved balance (conceding that thread), and the new exports catch panics.The bot's round on
15a8e07564(review 6002078794) is addressed in63d713bd38andecb3ee608e(merges ofv5.2-dev, including #5890 and #5929, instead of a rebase, so earlier cited commits stay valid),a2af0fd9d1(code 80),1dda6acc1a(durable recipient writes, the capability composite, no retry verdict after a wallet replacement, the builder minimum, code 82, now 90) and1bdda16c29, with replies on each thread. The seed-restored recovery is only partly addressed (code 90; see Known limitations).1bdda16c29fixes two findings of a local pre-review on1dda6acc1a: a conflicting identity after a buffered assignment failure, and funding indices used up by failed pool stores. Its third finding is the sweep limitation below.The bot's round on
1bdda16c29(its suggested redesign) is addressed inde75ae7e2b(merge ofv5.2-devwith #5794, the CI compile error),6b784421e0,79b6b9efd0,4f0c9e8596,71a0be3413,c02896ff96and775fa24b1e, with replies on each thread. A second local pre-review on775fa24b1efound two more, fixed ine6905cc7f6(assignment counted in the flush ledger) and83565ba1af(SQLite restores the asset-lock funding pools).The rest of that round, and local pre-reviews after it, are addressed in
7e5a82c8b6(publication of a committed assignment),bb4ceda640(the stored used mark of an unsent funding index is cleared),89f63b80f8(no extension of a restored pool from used marks; the rejected-broadcast release under the build gate) and84eb716fcf(sync-derived funding addresses stored).The bot's round on
84eb716fcfis addressed incad57af13d(its three SQLite blockers: sync used marks stored, rows without a key and upgraded pools restored through the shared restore),6c442fac96(a refusal after the buffer's commit is not a lost flush) andd7d22a95fc(the damaged-row suggestion, the assignment and callback docs), with replies on each thread. Two of its suggestions are follow-ups (below). Local pre-reviews oncad57af13dand6c442fac96found three more, fixed inb636eb1781: a resume authorizes the row it claims, a publication never overwrites another recipient, and the new exports refuse a call from a wallet callback.1fc6225faamergesv5.2-dev(#6288, #6276, #5767), andd7d22a95fcrenumbers the two codes.The second review on
d7d22a95fc(six threads) is addressed in63c2b7ff71(the builder's credit-key check,AssetLockAbandonedBeforeSend, the damaged and unreadable funding rows, the acknowledgement for every recipient-less lock, the code 89/90 docs), with replies on each thread. A local pre-review on it found the abandon racing a wallet turnover, fixed ind7e167df7d; the next round was clean.95643fe88amergesv5.2-dev(#5865, #6035); #6035's restore marks addresses no row restored below the highest stored row as used, which one legacy-row test now expects.The bot's round on
95643fe88aand CodeRabbit's onf4d6b5e2bb(afterf4d6b5e2bbmergedv5.2-dev) are addressed inbe70e45838, with replies on each thread. It fixes the blocker (a resume through a manager of a replaced wallet generation is refused, so it cannot send a lock the replacement's cleanup called safe to rebuild). It also fixes:The damaged-funding-row comments are left for #5789, with replies. A local pre-review on
be70e45838found a lock-order deadlock this PR had introduced (shielded funding holdingshield_guardwhile waiting on the lifecycle gate behind a queued teardown), fixed in4a5885564d. The next round (xhigh) found only the sweep-and-return limitation below.Not covered: a confirmed external top-up end to end (mock SDK limitation, as in #5860); to be checked with a testnet send.
Breaking Changes
No consensus change, so no
!. Wallet/FFI behaviour that changes for hosts:InvalidParameter), including throughasset_lock_manager_create_funded_proof. A host using that builder for type 2 gets the error before anything is broadcast. A top-up lock (types 1 and 2) below the protocol minimum is refused there too.ATOMIC_CHANGESETSandASSET_LOCK_FUNDING_INDICESas well as bit 17.platform_wallet_assign_identity_top_up_recipientgains aboolparameter, and a backend attesting bit 17 must implementPlatformWalletPersistence::assign_asset_lock_identity_recipient(FFI hosts: refuse the recipient callback for an outpoint with no row).platform_wallet_topup_identity_with_existing_asset_lock_signer); a lock with no recorded identity returns the new code 89 until a recipient is assigned. Before, any identity was accepted.platform_wallet_assign_identity_top_up_recipient, which the mobile SDKs don't bind until PR B/C. On this Rust alone, a mobile app can't move such a lock past 89.TrackedAssetLockFFI,TrackedAssetLockEntryFFIandPersistenceCallbacksExtensiongain appended fields; hosts rebuild against the new header. Older hosts' smallerstruct_sizekeeps the extension slots absent.ErrorAssetLockRecipientUnknownand 90ErrorAssetLockConsumptionUnknown; Swift and Kotlin map them in their PRs, and until then report it as unknown / generic.PlatformWalletPersistencegainsrelease_unsent_pool_address(default no-op) andPersistenceErrorgainsafter_buffer_committed/left_buffer_committed; a backend whose assignment or release writes its buffer first should mark an error raised after that commit.WalletRemovedBeforeSendwhen refused before the build,TransactionBroadcastUnconfirmed(row and inputs kept) when the wallet was replaced after it.IdentityWallet::top_up_identity_with_fundingnow refuses a new lock below the protocol's top-up minimum withInvalidParameter, and holds a drained top-up (DrainAccountBalance) to that floor. Before, only the FFI checked, and only an exact amount, so a Rust caller or a drain could broadcast a lock Platform then rejects, stranding the funds.platform_wallet_top_up_identity_with_funding_signerchecks the amount after the wallet lookup: an invalid handle with a too-small amount now returnsNotFoundinstead ofErrorInvalidParameter. With a valid handle the result is unchanged.resolve_funding_with_is_timeout_fallbackand thecreate_*_asset_lock_proof*helpers takeOption<AssetLockRecipient>instead ofOption<ShieldedRecipientRaw>;preserve_recovery_metadatatakes the recorded identity;tracked_resume_metadatareturnsTrackedResumeMetadata;restore_asset_lock_funding_poolstakes the wallet and the stored records and returns the issuance floors.Known limitations
acknowledge_unknown_consumption, after the user is told Platform may already have used it; the wallet cannot check until Platform offers a client query for an outpoint's consumption.release_unsent_pool_addressis a no-op on the FFI backend, so a Swift or Kotlin wallet restarted right after a definite pre-send rejection reloads the index as used. The base already kept it used and never handed it back; this PR hands it back in memory. Persisting the release needs a pool callback round on the FFI (follow-up).be70e45838: a resume through a manager of a replaced generation is refused, as a build is. A resume already past its claim when the wallet is removed is the remaining part of platform-wallet: an asset-lock build is not excluded from wallet removal, so a lock can be broadcast for a wallet that is gone #5516.Follow-ups
identityRecipientId(21 → 22, write-once like SQLite), bit 17, bindings for the three new exports, and codes 89 and 90.ATOMIC_CHANGESETSandASSET_LOCK_FUNDING_INDICESwith bit 17; map 89 and 90 (renumbered from 81 and 82).acknowledge_unknown_consumptionwhatever its status (90 otherwise), after telling the user it may already be spent;AssetLockAbandonedBeforeSendreaches C as 99 with a zero outpoint, which means nothing was sent.AssetLocksandCoreAddressPooldomain versions for the recipient-only assignment, the release and derived-only funding rows (the sequence accessor is test-only today).AssetLockAbandonedBeforeSendas a definite pre-send verdict on their callback results.dashpay/rust-dashcorekey-wallet: check the asset-lock builder's credit key against its output (the local guard stays until then).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 ·
3325d46/self-reviewedrs-platform-wallet-ffi(packages/rs-platform-wallet-ffi/ERROR_CODE_REGISTRY.md,packages/rs-platform-wallet-ffi/src/asset_lock/manager.rs,packages/rs-platform-wallet-ffi/src/asset_lock/sync.rsand 8 more) — ZocoLini or llbartekll or romchornyiwallet-storage(packages/rs-platform-wallet-storage/SCHEMA.md,packages/rs-platform-wallet-storage/migrations/V025__asset_lock_identity_recipient.rs,packages/rs-platform-wallet-storage/src/sqlite/migrations.rsand 15 more) — lklimekrs-platform-wallet(packages/rs-platform-wallet/src/changeset/changeset.rs,packages/rs-platform-wallet/src/changeset/core_bridge.rs,packages/rs-platform-wallet/src/changeset/flush_ledger.rsand 30 more) — ZocoLini or 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.Summary by CodeRabbit
New Features
Bug Fixes