Repository navigation
perf(wallet): stop re-copying wallet funding state for Max quotes and snapshots - #1167
Claudius-Maginificent wants to merge 8 commits into
Conversation
Every probe of the reservation-aware Core send Max search cloned all pooled funding accounts again under the wallet-manager write lock. PooledScratch clones them once per quote and derives the change address once, as a fresh pooled build would, so every probe makes the same build; each successful build still releases its own reservation through the owner guard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mpute Every snapshot recompute deep-cloned all asset-lock funding accounts before trying the observation lock, discarded the copy on contention, and cloned each account again for the observation's scratch builder. The recompute now takes the try-lock first and reads the pooled accounts in place, so only that per-account scratch clone remains. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…splay list Every shield-Max quote lookup, several per frame, rebuilt the Bech32m display list of Platform addresses (string-keyed dedupe map, sort, and an extra Vec) only to hash it. funded_platform_addresses dedupes by PlatformAddress with the same highest-nonce rule; the revision hashes it in place and the display list is built from it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
✅ Final review complete — no blockers (commit beee9f6) · triage: normal · Phase 2 only (no Phase 1 for this repository) |
…ervation lock snapshot_observation_matches_the_cloned_asset_lock_pool observed through the try-lock, which a parallel test holding the global observation lock makes return None, failing the test. Both observations now run through observe_asset_lock_inputs_locked under a single lock() hold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Waiting for bot review — coderabbitai ✓ · 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 2 only (no Phase 1 for this repository)
Static verification of head b9e230c confirms two non-blocking suggestions: strengthen the scratch-build equivalence test with an independent reference and eliminate a second map allocation from the balance-fingerprint path. No blocking correctness issue was confirmed. Current CI reports successful Test Suite, Clippy, and Platform pin guard checks; PR Hygiene remains pending.
🟡 2 suggestion(s)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.1-sol(effort low) — The diff is a contained performance refactor of funding-state copies, quote probes and balance fingerprints, with reservation and change-address handling to verify, but it does not clearly meet the large-or-intricate threshold for critical. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `src/wallet_backend/payments.rs`:
- [SUGGESTION] src/wallet_backend/payments.rs:1906-1907: Compare scratch builds against an independent funding path
The reference transaction comes from `dry_build_pooled`, which now delegates to `PooledScratch::new(...).dry_build(...)`. Both sides therefore use the new change-address preselection logic. The 64 comparisons verify repeated-use stability, and the final ordinary build checks reservation cleanup, but a consistently incorrect initial change-address choice would still pass. Construct the reference by cloning the pooled accounts and folding `TransactionBuilder::add_funding` over them without pre-setting change, then release its returned reservation. The neighboring `pooled_build_charge` helper already demonstrates that independent path; retaining its transaction would allow this test to verify outputs and change against ordinary upstream funding as well as repeated scratch reuse.
In `src/ui/wallets/send_screen.rs`:
- [SUGGESTION] src/ui/wallets/send_screen.rs:5337-5341: Consume the deduplicated tree without collecting a second map
This pipeline consumes `latest` and allocates another `BTreeMap` for the funded entries solely to filter zero balances and remove the nonce from each value. `live_platform_balances_revision` calls this helper on the repeated quote-lookup path while retaining the wallet read guard, so large funded wallets still pay for a second tree allocation and traversal on every lookup. The first tree already supplies deterministic iteration order. Return an owning filtered iterator over that tree, or retain the nonce in the returned map and filter in place, so hashing and display-list construction can consume the same deduplicated entries without materializing another tree.
|
Ready for review — files with no dedicated owner: lklimek. |
…ference The reference build came from dry_build_pooled, which runs through PooledScratch itself, so a consistently wrong change-address choice would have passed. The reference is now funded on fresh clones with add_funding picking the change, like pooled_build_charge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
funded_platform_addresses collected a second BTreeMap only to drop empty entries and the nonce. It now returns a filtered iterator over the deduplicated tree, consumed directly by the balance revision and the display list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
Verified the complete diff at beee9f6 against the relevant pinned and default upstream implementations; no actionable in-scope issues were found. Both prior suggestions are fixed: funded addresses stream directly from the deduplicated tree, and repeated scratch builds are compared against an independent funding path. Validation was static only; current CI shows Platform pin guard passing, with Clippy and Test Suite still pending.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.1-sol(effort low) — The diff makes moderately scoped performance changes to funding snapshots, balance fingerprints, and Max-quote dry builds, including scratch-account and reservation reuse in payments.rs, but does not clearly meet the large-or-intricate threshold for critical. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (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.
|
Ready for review — files with no dedicated owner: lklimek. |
TL;DR
The wallet does less repeated copying when it works out the Max amount you can send and when it refreshes a wallet's state. Amounts, fees and what you see on screen stay the same.
User story
As a wallet user with a large wallet, I want the Send screen and wallet updates to stay responsive, so that working out Max and showing fresh balances doesn't hold up the app.
Scenario
Actual behavior
Expected behavior
The same results with far less copying: one funding copy per Max quote, no copy at all when the state refresh finds the wallet busy, and a balance fingerprint computed without building display strings.
Detailed discussion
This PR follows up three cost-only findings raised on #1107 (merged). None of them needs an upstream change. Behavior is unchanged; only redundant work goes away.
wallet_backend/snapshot.rs): the asset-lock observation try-lock is taken first. Pooled accounts are then read in place through the newAssetLockFundingPool::borrowed_from_wallet, andfrom_walletclones from the same list. Only the observation's own per-account scratch clone remains, and nothing is cloned on contention.wallet_backend/payments.rs): the newPooledScratchclones the pooled send accounts once per quote and derives the change address once, the same wayadd_fundingdoes.largest_core_payment_at_mostreuses that scratch set for every probe. Each successful probe still releases its own reservation through the owner guard, anddry_build_pooledstays a one-shot wrapper.ui/wallets/send_screen.rs): the newfunded_platform_addressesdeduplicates byPlatformAddresswith the same highest-nonce rule. The revision hashes it in place, without Bech32m encoding, strings, sorting or an extraVec.get_platform_addressesbuilds the display list from the same helper. A lookup still takes the wallet read lock. A per-frame cache or a wallet-maintained revision was left out, because either could keep a stale key after a mid-frame wallet update.Testing
pooled_scratch_builds_like_a_fresh_pooled_build_every_time: 64 builds on one scratch set match a fresh pooled build in fee, outputs and change, and leave no reservation behind.snapshot_observation_matches_the_cloned_asset_lock_pool.funded_platform_addresses_keep_the_latest_entry_of_each_address.platform_balances_revision_follows_the_funded_balances.shield_from_platform_max_is_requoted_when_live_balances_change,a_shield_in_flight_moves_the_shield_from_platform_max_key).wallet_backend::payments+wallet_backend::snapshot(86 passed),ui::wallets::send_screen(93 passed), clippy-D warningsclean,cargo fmtapplied.Breaking changes
None.
🤖 Generated with Claude Code
🤖 Co-authored by Claudius the Magnificent AI Agent
PR Hygiene ·
beee9f6src/ui/wallets/send_screen.rs,src/wallet_backend/payments.rs,src/wallet_backend/snapshot.rs) — lklimekWhen 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