Repository navigation
fix(platform-wallet): keep pre-derived lost funding rows ineligible after restart - #6035
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
✅ Final review complete — no blockers (commit 4f39040) · triage: normal |
a9f4c10 to
838f1a9
Compare
…fter restart Preserve the final PR scope, including merge resolutions, on the updated native stack. Co-Authored-By: Codex <[email protected]>
838f1a9 to
b30b4b5
Compare
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Changes requested: 1 blocker
- A corrupt stored index can leave the wallet unable to issue invitations after restart —
packages/rs-platform-wallet/src/wallet/address_pool_restore.rs:96-98(new)
Impact: A wallet user who restarts with an out-of-range invitation row and no valid unused rows in storage cannot send an invitation, even though the wallet pre-derived unused keys.
The patch retires missing funding addresses on restore, including addresses pre-derived at startup, so they cannot be handed out again. Swift and Kotlin SDK checks passed; the Linux Rust wallet tests did not run because GitHub Actions cancelled the original Tests run in favor of a queued run, which was skipped.
🔴 1 blocking | 🟡 1 suggestion(s) | 💬 1 nitpick(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: A partially failed gap fill marks the same addresses used twice
Impact: A wallet loading a partially derivable funding pool scans and marks its newly derived addresses twice, leaving two paths for maintainers to keep consistent.
packages/rs-platform-wallet/src/wallet/address_pool_restore.rs:103-110
The early mark_used_from call no longer changes the result. A partial fill derives only indices below the failed row, starting above the pool's previous highest index. None of those indices was restored earlier, and later rows cannot restore them because the input is sorted. The final sweep therefore marks the same entries, and mark_used is idempotent. Remove the early marking and its helper so the final sweep owns the rule; the existing partial-fill regression checks that these addresses still end up used.
source: glm-5.3-flash (phase1-reviewer: general, rust-quality)
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.2-sol(effort low) — The fix is confined to wallet address-pool restoration, where one eligibility rule now covers both pre-derived and gap-filled rows, with a regression test for each case. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer,glm-5.3-flash— rust-quality (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 96% left, weekly 23% left; passed overgemini-3.8-flash-high(lane failed) - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.2-sol— architecture-layering (completed, effort medium); agentphase2-reviewer,gpt-6.2-sol— rust-quality (completed, effort medium); agentphase2-reviewer,gpt-6.2-sol— security-auditor (completed, effort medium); 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/address_pool_restore.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/address_pool_restore.rs:96-98: A corrupt stored index can leave the wallet unable to issue invitations after restart
Impact: A wallet user who restarts with an out-of-range invitation row and no valid unused rows in storage cannot send an invitation, even though the wallet pre-derived unused keys.
The next invitation fails before the wallet builds its asset lock. The Swift loader forwards the stored `UInt32` index unchanged, and the FFI decoder preserves it if the rest of the row decodes. With a valid used row at index 0 and a corrupt row at `u32::MAX`, gap filling refuses the corrupt row, but `rows.last()` has already made it the cutoff. The final sweep marks pre-derived indices 1–4 used; the base left them available. The manager already excludes non-normal indices from the issuance floor, but that does not help because the invitation builder calls `next_address(None)` and cannot derive a replacement. Use one highest valid normal index for both the sweep and the floor. Keep counting invalid rows as refused and keep valid indices in the cutoff even when their rows are refused. Add a restore regression that checks both the refusal count and the next available invitation key.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/address_pool_restore.rs:103-110: A partially failed gap fill marks the same addresses used twice
Impact: A wallet loading a partially derivable funding pool scans and marks its newly derived addresses twice, leaving two paths for maintainers to keep consistent.
The early `mark_used_from` call no longer changes the result. A partial fill derives only indices below the failed row, starting above the pool's previous highest index. None of those indices was restored earlier, and later rows cannot restore them because the input is sorted. The final sweep therefore marks the same entries, and `mark_used` is idempotent. Remove the early marking and its helper so the final sweep owns the rule; the existing partial-fill regression checks that these addresses still end up used.
- [NITPICK] packages/rs-platform-wallet/src/wallet/address_pool_restore.rs:82-85: The restore docs can be read as stopping at the highest refused row
Impact: A maintainer reading the restore contract can mistake a refused row for the sweep boundary and miss that a successfully restored higher row also establishes that boundary.
The phrase “the highest row that no row restored” reads as though the cutoff is itself a refused row. In the code, the cutoff comes from the input rows; the successful-restore check applies separately to each address below or at that cutoff. State those two conditions separately here, on `GapRows`, and in the manager's restore docs.
Out-of-scope follow-up suggestions (2)
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.
- An unreadable highest invitation row can hide an issued key — The existing FFI decoder counts unreadable rows as dropped without forwarding their indices. If a row with a valid index and malformed payload is above every decoded row, neither the sweep nor the issuance floor sees it, and an exported key can remain available after restart. A rejected row below a later decoded row is covered by this patch.
- Follow-up: Open a follow-up PR to forward identifiable account, pool, and index information for unreadable rows to
rs-platform-wallet, where the restore policy belongs. Cover an unreadable highest used row in a load-path regression.
- Follow-up: Open a follow-up PR to forward identifiable account, pool, and index information for unreadable rows to
- A later refill can hide the gap that established an issuance floor — The issuance floor is recomputed on load. If a refill persists available rows that obscure the original gap, a later restart can accept them as restored and lose the earlier protection.
- Follow-up: Cover the refill-and-restart sequence in #6102.
…lost-row-in-window
…valid row index - Derive one cutoff, the highest valid normal index among the persisted rows (counted even when its row is refused), and use it for both the final sweep and the funding issuance floor, so an out-of-range stored index no longer marks the pre-derived unused window used. - Refuse rows with an invalid index before any gap fill. - Drop the early marking after a partial gap fill; the final sweep covers it. - Clarify the restore documentation of the cutoff. <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub> Co-Authored-By: Codex (gpt-6.2-sol) <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
New on this head: The follow-up uses the highest valid normal persisted index for both the restore sweep and the funding issuance floor, and the final sweep alone marks missing addresses used. Linux wallet CI passed, including the lost-row and invalid-index invitation regressions. The Swift SDK check failed when the simulator could not launch the example-app test runner, and the Kotlin emulator check failed on a voting-key authentication assertion outside the restore path.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.2-sol(effort low) — The fix is localized, but verifying invitation-key eligibility requires tracing how index validation, refused rows, and partial gap fills affect both the restore sweep and the issuance floor. - 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) - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-sol— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
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.
- An unreadable funding row can hide the highest recorded invitation index — The existing FFI loader counts an unreadable row as dropped but passes neither the row nor its index to wallet restore. If that row holds the highest recorded invitation index, the wallet can still offer a key already exported in a voucher. This change does not alter the decoder.
- Follow-up: In a separate PR, pass recoverable pool and index metadata from unreadable rows to rs-platform-wallet so it can apply the issuance cutoff.
|
Ready for review — |
|
Re: review summary, finding "🔴 Blocking: A corrupt stored index can leave the wallet unable to issue invitations after restart" Duplicate of #6035 (comment) 🤖 Co-authored by Claudius the Magnificent AI Agent |
llbartekll
left a comment
There was a problem hiding this comment.
Reviewed at 4f39040. The sweep covers the whole pool (entries are merged per pool before restore), funding pools are persisted as whole-pool snapshots so a healthy store is dense below its highest row, and the early index check matches what AddressPool::insert already refused. No issues found.
|
Policy satisfied — this can merge. |
…latform-wallet-top-up-someone-elses-identity-fr Registry: v5.2-dev's rows for 77-81 (#5865) taken; #5931 no longer holds 81, and rows 89 and 90 say the acknowledgement covers every recipient-less lock. The legacy funding-rows test expects index 0 used: #6035 keeps an address no row restored below the highest stored row ineligible. Co-Authored-By: Claude Opus 5.5 <[email protected]>
TL;DR: After a restart, the wallet no longer hands out an invitation key that was already given away in an earlier voucher, even when the record of that key was lost from storage.
User story
As a wallet user sending identity invitations, I want every invitation to use a fresh key, so that someone holding an older invitation link cannot claim a new one.
Scenario
Base flow
Actual behavior
If the lost record sits among the first few keys the wallet always prepares in advance, the wallet treats that key as unused and offers it for the next invitation, so two vouchers share a key.
Expected behavior
Any key at or below the highest one the wallet has recorded, but missing from storage, is treated as used and is never offered again.
Detailed discussion
What was done
restore_address_rows(rs-platform-walletwallet/address_pool_restore.rs) records which indices persisted rows restored. WithGapRows::Used(asset-lock funding pools), it then marks used every pool address at or below the cutoff that no row restored, whether pre-derived byManagedWalletInfo::from_walletor gap-filled.restore_account_address_pools, so a stored row with an out-of-range index is refused without retiring the unused pre-derived addresses.GapRows::Available) and the gap-fill budget are unchanged.fill_gap_below; the final sweep alone marks the addresses a partially failed gap fill derived.Stacked on #5951; this bug predates the rust-dashcore bump and was split out of it. Rows the FFI decoder rejects are dropped before restore and are not covered here (follow-up).
Testing
should_not_reissue_a_lost_invitation_row_below_the_highest_persisted_row: lost index inside and just above the pre-derived window (RED before the fix).should_issue_the_next_invitation_key_despite_an_invalid_persisted_index: a used row plus au32::MAXrow; one refusal, no floor, next invitation key is index 1 (RED before the fix).cargo test -p platform-wallet --lib address_pool_restorepasses; clippy for the wallet crate passes with theshieldedfeature.Breaking changes
None.
Checklist
🤖 Co-authored by Claudius the Magnificent AI Agent
🤖 Generated with Claude Code
https://claude.ai/code/session_01WunYYhpfoE88XJoyRt4hcR
PR Hygiene ·
4f39040rs-platform-wallet(packages/rs-platform-wallet/src/manager/load.rs,packages/rs-platform-wallet/src/wallet/address_pool_restore.rs) — approved by llbartekllWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.Summary by CodeRabbit