Repository navigation
fix(wallet): make every Max and fee match what the upstream builders accept - #1107
Conversation
Walkthrough
Pre-merge checks:
|
|
✅ Final review complete — no blockers (commit 2d99079) · triage: critical · Phase 2 only (no Phase 1 for this repository) |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 2 only (no Phase 1 for this repository)
The PR improves builder-derived Max calculations, but two in-scope funds-safety issues remain. Core Max can be rejected by a stale display-only balance before reaching the live pooled builder, and the asset-lock input-cap preflight is separated from the real build, allowing concurrent wallet changes to invalidate the cap check. Two additional non-blocking findings identify misleading user-facing error messages. CI checks for this head are green.
🔴 2 blocking | 🟡 2 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Do not reject the live Core Max using the stale display balance
src/ui/wallets/send_screen.rs:1253-1261
The Core Max value is now supplied by the live upstream pooled_max_sendable quote at lines 3072-3080, but send_core_to_core() still rejects the amount against get_core_balance(), which reads the display-only wallet snapshot. That snapshot can lag the wallet state used by the pooled quote, including being zero before the first snapshot update or temporarily stale during recomputation. The UI can therefore offer a positive live Max, but clicking Send immediately returns the old insufficient-balance error without reaching WalletBackend::send_payment and its pooled builder. The backend builder should be authoritative for this route; retain the snapshot for display and ordinary informational checks, but do not use it to reject an amount accepted by the live quote.
source: gpt-6.1-sol (phase2-reviewer: general)
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:
criticalbygpt-6.1-sol(effort low) — This is a large, intricate change to wallet funds movement and coin selection across Core sends, asset locks, shielding, and username-registration payments, including transaction-building and fee enforcement in functions such assrc/wallet_backend/payments.rsandsrc/backend_task/identity/register_dpns_name.rs. - 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 xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `src/ui/wallets/send_screen.rs`:
- [BLOCKING] src/ui/wallets/send_screen.rs:1253-1261: Do not reject the live Core Max using the stale display balance
The Core Max value is now supplied by the live upstream `pooled_max_sendable` quote at lines 3072-3080, but `send_core_to_core()` still rejects the amount against `get_core_balance()`, which reads the display-only wallet snapshot. That snapshot can lag the wallet state used by the pooled quote, including being zero before the first snapshot update or temporarily stale during recomputation. The UI can therefore offer a positive live Max, but clicking Send immediately returns the old insufficient-balance error without reaching `WalletBackend::send_payment` and its pooled builder. The backend builder should be authoritative for this route; retain the snapshot for display and ordinary informational checks, but do not use it to reject an amount accepted by the live quote.
In `src/wallet_backend/payments.rs`:
- [BLOCKING] src/wallet_backend/payments.rs:708-728: Make the asset-lock input-cap check atomic with the real build
`ensure_asset_lock_amount_within_input_cap` holds the wallet-manager write lock only through the unsigned dry run and explicitly drops it at line 725. The callers then open the secret session and invoke the real upstream asset-lock builder, for example at lines 933-990. A concurrent spend, reservation change, or wallet sync can alter the selectable UTXO set in that gap: an amount that fit within the cap during the dry run may require more than the protocol's allowed number of inputs during the real build. The pinned upstream exact-amount asset-lock builder enforces the standard transaction limit but not the protocol asset-lock cap, so the resulting oversized lock can be broadcast and dropped by Core while its inputs remain reserved. Enforce the cap inside the same serialized build operation, or add an upstream builder primitive that makes the cap authoritative, and cover the preflight/build interleaving with a regression test.
In `src/backend_task/error.rs`:
- [SUGGESTION] src/backend_task/error.rs:453-456: Do not display gross Platform balance as the maximum shieldable amount
The upstream `available` field used here is not the planner's maximum shieldable amount. When usable candidates exist, it is `usable_balance_credits`, which still includes the fee reserve; the actual maximum is `max_shieldable_credits` after subtracting that reserve. When no usable candidate exists, `available` is the entire account balance even though the maximum is zero. The current message can therefore tell the user that an amount is shieldable when the planner will reject it. Use operation-neutral guidance or carry and display the planner's actual maximum instead.
- [SUGGESTION] src/backend_task/error.rs:437-442: Use operation-neutral wording for asset-lock input-limit errors
`AssetLockTooManyInputs` is emitted by the shared cap guard used by identity registration, identity top-up, Platform-address funding, shielding, and direct asset-lock paths. Its message describes every failure as a transfer to Platform and calls the transaction a deposit, which is incorrect for several of those operations and gives the user the wrong explanation. Keep this shared variant operation-neutral, or introduce operation-specific variants before displaying it.
|
Non-inline finding ( 🤖 Co-authored by Claudius the Magnificent AI Agent |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
The complete PR diff correctly implements the reviewed Max, shielding, asset-lock, and DPNS fee changes. The remaining non-atomic Exact asset-lock input-cap gap is accurately documented and tracked by dashpay/platform#5513; no new in-scope issues were found. Clippy and policy checks passed, while the Test Suite was still running in the supplied CI snapshot.
🔴 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:
criticalbygpt-6.1-sol(effort low) — The large and intricate diff changes wallet payment construction, coin selection, asset-lock funding, shielding limits, and pre-signing fee validation in src/wallet_backend/payments.rs and related backend tasks, directly affecting funds movement and transaction acceptance. - 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 xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); 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.
thepastaclaw
left a comment
There was a problem hiding this comment.
CI failed after approval — commit e025d91
The standing review approved this commit; this follow-up moves the verdict to COMMENT: checks that failed after the review look related to this change.
Failing checks:
Test Suite(failure)
Why they look related: The failing test is send_screen::routes_core_wallet_to_core_address, and the PR substantially changes Core send routing and wallet payment construction in src/ui/wallets/send_screen.rs and src/wallet_backend/payments.rs. Its failure reports that the offline Core wallet has no spendable snapshot balance, indicating a plausible regression in the changed send behavior or its test fixtures.
Nothing was re-reviewed: the findings of the standing review are unchanged. The next push gets a full review; a re-run that passes does not restore the approval.
Review provenance
Source: CI-check lane gpt-6.1-sol (agent: triage); no reviewer or verifier lanes ran for this follow-up
- Verdict moved because CI failed on this commit after the review; failure logs read: 1 GitHub Actions job(s)
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
One blocking stale-cache issue remains in Platform-to-shielded Max handling. The selected Platform address snapshot is not refreshed when live balances change, so Max can remain higher than the current planner limit and fail during the actual shield operation. CI checks for this head are successful.
🔴 1 blocking
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:
criticalbygpt-6.1-sol(effort low) — This is a large, intricate diff that directly changes funds movement and coin-selection behavior in wallet payment, asset-lock, shielding, and username-registration flows, including transaction finalization and fee enforcement in src/wallet_backend/payments.rs and related backend tasks. - 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 xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `src/ui/wallets/send_screen.rs`:
- [BLOCKING] src/ui/wallets/send_screen.rs:896-900: Invalidate Platform shielding Max when live balances change
The spend-limit revision is calculated from the balances captured in `selected_source`, but that vector is only rebuilt when the user selects the Platform source. Live `platform_address_info` is updated both by explicit balance fetches and by `PlatformAddressSyncPushed`; the latter is applied by `AppState` without being delivered to this screen, and `refresh_form_inputs` only clears the address-input signature. After a balance decreases, the cached planner quote can therefore remain higher than the wallet's current `shielded_shield_preflight` maximum. Max then offers an amount that the shield operation rejects after opening the wallet session, violating the PR's goal that Max match what the builder accepts. Derive the revision from the current wallet Platform-address snapshot or rebuild/invalidate the selected source whenever Platform balances are refreshed.
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
The PR improves builder-derived Max values and username fee validation, but two blocking issues remain. Core Max does not account for UTXOs reserved by another in-flight build, and the new regression tests commit deterministic wallet seeds and a plaintext password. The username pagination and user-story documentation issues are non-blocking; CI Test Suite and Clippy checks are still in progress.
🔴 2 blocking | 🟡 3 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: Update user-story acceptance criteria for dynamic username fees and builder-quoted Max
docs/user-stories.md:852-855
DPN-001 still documents only the fixed base community vote fee and omits the separate name-admission reserve, although the implementation now quotes the current crowded-contest fund, rejects full contests, and checks the reserve. SND-014 still says Core Max is the balance minus an estimated fee, while this PR changes it to an upstream pooled-builder quote that accounts for account pools, fees, and input limits. Update the acceptance criteria to describe the shipped behavior.
source: gpt-6.1-sol (phase2-reviewer: general)
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:
criticalbygpt-6.1-sol(effort low) — This is a large, intricate change that directly modifies wallet payment construction, coin selection, asset-lock funding, shielding, and transaction fee handling in src/wallet_backend/payments.rs and related backend tasks, all of which affect funds movement. - 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 xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `src/wallet_backend/payments.rs`:
- [BLOCKING] src/wallet_backend/payments.rs:661-669: Invalidate Core Max when wallet reservations change
The Core Max quote calls upstream `pooled_max_sendable`, whose pinned implementation explicitly does not model UTXOs reserved by another in-flight build. In contrast, `ensure_core_payment_builds` and `finalize_transaction` use reservation-aware selection. The UI keys this quote to the snapshot generation at `send_screen.rs:901-905`, but a reservation can be created or released without advancing that generation, so a previously quoted Max can remain available after another operation reserves its inputs. The subsequent real build can then fail for insufficient unreserved funds even though the UI offered Max as buildable. Add a reservation-aware quote or a reservation revision that invalidates the cached quote.
- [BLOCKING] src/wallet_backend/payments.rs:1952-1963: Do not commit deterministic wallet seeds and test passwords
The new tests embed deterministic 64-byte HD seed material through `[seed_byte; 64]`, register those bytes as wallets, and repeat the pattern at lines 2217-2226 and 2352-2364. The cap-race test also commits the plaintext password `cap-race-password` at line 2190 and stores it in the protected seed fixture at lines 2232-2234. Repository policy forbids committing recovery seeds or passwords in source and tests, except for the separately documented historical migration fixture. Generate test credentials at runtime through test support or use a secret-free test seam instead.
In `src/backend_task/identity/dpns_usernames.rs`:
- [SUGGESTION] src/backend_task/identity/dpns_usernames.rs:141-152: Avoid contender pagination when the protocol uses a fixed contest fund
When `username_contest_max_contenders` returns `None`, the pinned Platform implementation states that every contender pays the base fund and `required_vote_resolution_fund_to_join` does not vary with the contender count. This code still performs proved contender pagination up to the configured limit and propagates any pagination failure as an availability-check failure. Return the fixed base fund immediately on those protocol versions; only count contenders when the active protocol both varies the fund and enforces a contest cap.
In `src/ui/wallets/send_screen.rs`:
- [SUGGESTION] src/ui/wallets/send_screen.rs:3118-3125: Do not expose zero shield capacity as a usable Max amount
When the shield planner reports `can_shield == false`, `spend_limit_credits` returns `Some(0)`, and this branch passes that value to `AmountInput`. The Max button then fills the field with zero, while `validated_send_route` rejects zero amounts. The associated capacity error also tells the user to use Max even though no positive amount is available. Treat a zero quote as no available Max and use zero-capacity guidance instead.
In `docs/user-stories.md`:
- [SUGGESTION] docs/user-stories.md:852-855: Update user-story acceptance criteria for dynamic username fees and builder-quoted Max
DPN-001 still documents only the fixed base community vote fee and omits the separate name-admission reserve, although the implementation now quotes the current crowded-contest fund, rejects full contests, and checks the reserve. SND-014 still says Core Max is the balance minus an estimated fee, while this PR changes it to an upstream pooled-builder quote that accounts for account pools, fees, and input limits. Update the acceptance criteria to describe the shipped behavior.
|
Docs finding (non-inline) addressed in 0321c6d: 🤖 Co-authored by Claudius the Magnificent AI Agent |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
The PR improves builder-derived fee and Max calculations, but three blocking freshness races remain: Core Max and asset-lock Max can outlive local UTXO reservations, and Platform-to-shielded sending still validates against a stale source-selection balance list. Clippy and Test Suite checks were still in progress in the supplied CI snapshot, with no failed code check reported.
🔴 3 blocking
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Use live Platform balances for the shield send preflight
src/ui/wallets/send_screen.rs:2194-2203
The shielding Max quote is keyed from the wallet's live Platform balances, but this preflight still sums the addresses vector captured when the Platform source was selected. A sync or balance update can increase an existing balance or add an address while the form remains open; the planner then returns a valid larger Max, but clicking Send rejects it locally against the stale total and never reaches the backend planner. Read the current Platform-address snapshot for this guard or remove the gross-balance check and let the planner remain authoritative.
let total_available: u64 = self
.get_platform_addresses()
.into_iter()
.map(|(_, _, balance)| balance)
.sum();
source: gpt-6.1-sol (phase2-reviewer: general)
1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); 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 that directly modifies wallet payment construction, coin selection, asset-lock funding, shielding, and username-registration fee handling in files such as src/wallet_backend/payments.rs and src/backend_task/identity/register_dpns_name.rs. - 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 xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— rust-quality (completed, effort xhigh); agentphase2-reviewer - Model comparison: every Phase-2 reviewer also ran on
gpt-6-astra; the verifier weighed both sets without knowing which model wrote which
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `src/ui/wallets/send_screen.rs`:
- [BLOCKING] src/ui/wallets/send_screen.rs:901-905: Invalidate Core Max when wallet reservations change
The Core Max cache is keyed by the wallet snapshot generation, but creating or releasing a reservation for another in-flight build does not advance that generation. The quote is reservation-aware when created, yet a later reservation can remove inputs that the quote relied on; pressing Send then reaches the reservation-aware dry run and rejects the previously offered Max as unaffordable. Track reservation ownership in the quote revision or perform an authoritative reservation-aware check immediately before accepting the amount.
- [BLOCKING] src/ui/wallets/send_screen.rs:2194-2203: Use live Platform balances for the shield send preflight
The shielding Max quote is keyed from the wallet's live Platform balances, but this preflight still sums the `addresses` vector captured when the Platform source was selected. A sync or balance update can increase an existing balance or add an address while the form remains open; the planner then returns a valid larger Max, but clicking Send rejects it locally against the stale total and never reaches the backend planner. Read the current Platform-address snapshot for this guard or remove the gross-balance check and let the planner remain authoritative.
In `src/wallet_backend/payments.rs`:
- [BLOCKING] src/wallet_backend/payments.rs:732-796: Invalidate asset-lock Max when wallet reservations change
(existing thread: https://github.com/dashpay/dash-evo-tool/pull/1107#discussion_r4366962036)
The asset-lock Max quote is validated against the published asset-lock input composition, but local reservations created by another in-flight build are not included in that cache key unless a new wallet snapshot is published. A quote made before another Core payment or asset lock reserves its inputs can therefore remain available as Max. The later cap guard treats insufficient-funds results as acceptable because the exact builder is responsible for reporting shortfalls, so the upstream exact-amount build can fail after the wallet has been unlocked. Include reservation state in the quote revision or perform a reservation-aware buildability check immediately before entering the secret/build path.
|
Addressed the two remaining freshness findings (not shown inline).
🤖 Co-authored by Claudius the Magnificent AI Agent |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
The current head fixes the previously reported Core, shielding, DPNS, messaging, and secret-fixture issues, but asset-lock Max quotes can still become stale after the upstream build takes reservations. Core Max is also conservative for accepted P2SH destinations because the quote always prices a synthetic P2PKH output. Test Suite and Clippy checks were still in progress in the supplied CI snapshot.
🔴 1 blocking | 🟡 1 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Asset-lock operations do not invalidate Max quotes after reservations are taken
src/wallet_backend/identity_ops.rs:811-817
The revision is advanced at spend.mark() immediately before the upstream asset-lock call, but it is not advanced again when that call actually acquires reservations. For fund_from_asset_lock, upstream first validates recipients and only later enters resolve_funding_with_is_timeout_fallback, where the Core inputs are selected and reserved; the same hand-off pattern is used by identity registration, identity top-up, create_asset_lock_proof, and shielding from an asset lock. A concurrent Max request can therefore start after spend.mark(), obtain the wallet-manager lock and quote against the new revision before the asset-lock build reserves its inputs. That quote remains current while those inputs are unavailable because the next revision change is only the guard drop after the operation completes, potentially after broadcast and proof finality. The UI can consequently offer a Max value that the subsequent builder rejects. The revision must be advanced or otherwise made invalid for the entire reservation hand-off, or the quote must be prevented from completing while a reserving operation is between its hand-off and reservation acquisition.
source: gpt-6.1-sol (phase2-reviewer: general)
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-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); 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 that directly modifies wallet payment construction, coin selection, asset-lock funding, shielding, fee calculation, and signing-related preflight paths in files including src/wallet_backend/payments.rs and src/backend_task/wallet/mod.rs, all of which govern funds movement. - 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 xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— general (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer - Model comparison: every Phase-2 reviewer also ran on
gpt-6-astra; the verifier weighed both sets without knowing which model wrote which
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `src/wallet_backend/identity_ops.rs`:
- [BLOCKING] src/wallet_backend/identity_ops.rs:811-817: Asset-lock operations do not invalidate Max quotes after reservations are taken
The revision is advanced at `spend.mark()` immediately before the upstream asset-lock call, but it is not advanced again when that call actually acquires reservations. For `fund_from_asset_lock`, upstream first validates recipients and only later enters `resolve_funding_with_is_timeout_fallback`, where the Core inputs are selected and reserved; the same hand-off pattern is used by identity registration, identity top-up, `create_asset_lock_proof`, and shielding from an asset lock. A concurrent Max request can therefore start after `spend.mark()`, obtain the wallet-manager lock and quote against the new revision before the asset-lock build reserves its inputs. That quote remains current while those inputs are unavailable because the next revision change is only the guard drop after the operation completes, potentially after broadcast and proof finality. The UI can consequently offer a Max value that the subsequent builder rejects. The revision must be advanced or otherwise made invalid for the entire reservation hand-off, or the quote must be prevented from completing while a reserving operation is between its hand-off and reservation acquisition.
In `src/wallet_backend/payments.rs`:
- [SUGGESTION] src/wallet_backend/payments.rs:1225-1232: Quote Core Max against the actual destination script
The reservation-aware Core Max search always builds a synthetic P2PKH recipient. The UI accepts both P2PKH and P2SH Core addresses, and the real `core_payment_builder` prices the concrete destination script. A P2SH output has a smaller output script than P2PKH, so the quoted Max is lower than the amount the real build can accept for a P2SH destination. Because the spend-limit cache key contains only the wallet, operation kind, and revision—not the destination—the same conservative quote can also survive a change between Core destination addresses. Pass the validated destination/output shape into the quote and cache key, or explicitly use and test a documented conservative bound for all supported Core address kinds.
|
Re the non-inline finding on 🤖 Co-authored by Claudius the Magnificent AI Agent |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
The PR substantially aligns Max and fee calculations with the upstream builders and resolves the prior quote, reservation, balance, contest, wording, and fixture findings. One blocking correctness issue remains: after a successful Platform-to-shielded operation, the cached Platform-address balances used for the next Max quote are not refreshed, so Max can remain stale and the next shield can be rejected by the upstream planner. Clippy and Test Suite checks were still in progress at the captured head.
🔴 1 blocking | 🟡 1 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Refresh Platform balances after a successful Platform-to-shielded operation
src/backend_task/shielded/mod.rs:144-160
The successful ShieldFromBalance path refreshes only the shielded balance snapshot. The send form keys SpendLimitKind::ShieldFromPlatform to live_platform_balances_revision(), which hashes the cached per-address balances in wallet.platform_address_info; neither this task nor the upstream shield operation updates that cache after the source balance is consumed. Until the next Platform-address sync, the revision can remain unchanged and the cached Max quote can still be offered. A subsequent Max shield can then reach the upstream planner with a stale amount and be rejected. After confirmed success, refresh the authoritative Platform-address state and its DET snapshot, or invalidate/withhold Max until that refresh completes; the refresh must be best-effort so it cannot turn a completed shield into a retryable failure.
source: gpt-6.1-sol (phase2-reviewer: general, rust-quality)
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:
criticalbygpt-6.1-sol(effort low) — This is a large, intricate change that directly modifies wallet coin selection, transaction construction, fee calculation, asset locking, shielding, and username-registration payments in src/wallet_backend/payments.rs and related backend task code, all of which affect funds movement. - 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 xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `src/backend_task/shielded/mod.rs`:
- [BLOCKING] src/backend_task/shielded/mod.rs:144-160: Refresh Platform balances after a successful Platform-to-shielded operation
The successful `ShieldFromBalance` path refreshes only the shielded balance snapshot. The send form keys `SpendLimitKind::ShieldFromPlatform` to `live_platform_balances_revision()`, which hashes the cached per-address balances in `wallet.platform_address_info`; neither this task nor the upstream shield operation updates that cache after the source balance is consumed. Until the next Platform-address sync, the revision can remain unchanged and the cached Max quote can still be offered. A subsequent Max shield can then reach the upstream planner with a stale amount and be rejected. After confirmed success, refresh the authoritative Platform-address state and its DET snapshot, or invalidate/withhold Max until that refresh completes; the refresh must be best-effort so it cannot turn a completed shield into a retryable failure.
In `src/wallet_backend/payments.rs`:
- [SUGGESTION] src/wallet_backend/payments.rs:1284-1296: Preserve typed insufficient-funds errors when pooled finalization reports no UTXOs
`map_core_finalize_error` maps `CorePooledInsufficientFunds` to the actionable `TaskError::InsufficientFunds` only when both `available` and `required` are present. The pinned upstream finalizer emits the same variant with `available: Some(0)` and `required: None` for `NoUtxosAvailable`, so a normal finalization race can fall through to the generic `WalletBackend` error. Add a typed insufficient-funds variant that does not require both figures, or map the missing-value form to an equivalent actionable error instead of losing the classification.
Out-of-scope follow-up suggestions (3)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- Make the asset-lock input-cap check atomic with the real build — The cap guard and the upstream exact-amount asset-lock build still use separate wallet-manager lock acquisitions, so a concurrent spend or sync can change input selection between the final guard and the build. The DET limitation is explicitly tracked by dashpay/platform#5513, and the current PR adds the closest available second check before the upstream call.
- Follow-up: Resolve dashpay/platform#5513 so exact-amount asset-lock builds enforce the input cap inside the same serialized operation.
- Avoid synchronous asset-lock observation from wallet event callbacks —
SnapshotStore::recomputeperforms an unbounded asset-lock input observation at lines 925-933, andEventBridge::on_wallet_eventcalls it directly. For wallets with many UTXOs this can consume substantial CPU in the synchronous callback and delay subsequent wallet events. Move the observation off the callback path or replace it with an incremental bounded publication mechanism.- Follow-up: Track as a separate wallet-event performance follow-up.
- Do not hold the wallet-manager write lock while waiting for spawn_blocking capacity — The asset-lock and Core quote paths acquire the wallet-manager write guard before enqueueing
spawn_blockingwork. If Tokio's blocking pool is saturated, the queued task can retain the wallet-manager lock while waiting for a worker, and the probe deadline starts only after the closure begins. This can delay unrelated wallet-manager operations beyond the intended probe timeout.- Follow-up: Refactor the quote probes so blocking-pool queueing does not occur while holding the wallet-manager write guard.
…ername DPNS contract v3 picks the first preorder of a name, and Platform admits the name document only while the balance also holds the chooseFirst scan budget (0.001 DASH) on top of the fee. The registration guard and the confirm step now ask for it, read from the platform version and only when the contract declares chooseFirst, so a low balance is turned away before the preorder is paid for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 8c16867)
…nput cap The asset-lock Max probe priced BIP-44 account 0 alone while the real build pools BIP-44, BIP-32 and DashPay-receiving funds, and it stopped only at the 500-input standard-transaction limit although Dash Core relays at most 100 asset-lock inputs. The probe and its composition key now cover the pooled accounts, a dry run above the protocol's max_asset_lock_transaction_inputs counts as unbuildable, and every exact-amount asset lock is refused with a typed error before building when it would need more inputs than that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 953de07)
The Max for shielding from Platform addresses was the balance minus a one-fee headroom, while the upstream planner orders addresses, drops inputs below the minimum, caps their count and keeps twice the fee on its fee-paying input. A Max could therefore name an amount the planner refuses. The send screen now asks the backend for the planner's preflight quote (a new spend-limit query with a small per-screen cache) and offers nothing until it arrives; the fee hint uses the planner's reserve, and a shield above the planner's capacity surfaces as a typed error instead of the generic wallet failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 1675025)
…x upstream Core sends were built from BIP-44 account 0 alone while their Max came from UI arithmetic over the whole-wallet snapshot, so funds in BIP-32 or DashPay receiving accounts could not be sent and Max could name an amount no build reaches. Payments now go through platform-wallet's atomic finalize_transaction with SEND_FUNDING_SOURCES (CoinJoin excluded, change back to BIP-44) and broadcast_finalized_transaction, and Max is upstream's pooled_max_sendable through the spend-limit query. A dry run of the same pooled build runs before signing so shortfalls and too-many-inputs refusals stay typed and never prompt for a passphrase. The UI-side Max helpers are removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 5073008)
From protocol 14 a contest's fund doubles once it holds 250 requests and again for every 50 more, and a request stating less is turned away after its preorder was already paid for. The availability check now quotes the fund to join through the SDK's paged contender count, the review and consent show that amount, and the backend re-quotes it before any document is sent and refuses a stale approval as changed terms. The generic contested document cap now uses its contest's own base fund, the moderation fund for a moderation election. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit bac64a7)
From protocol 14 a contest accepts at most max_contenders_per_contest requests and turns any further one away after its preorder was paid. DET counts the vote's requests in proved pages, reports a full vote in the live availability check, and refuses registration before anything is sent with a dedicated UsernameContestFull error. The cap comes from the platform version's limit table and applies only where the network's create validation enforces it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 4c31933)
…dable The send form refused a Core payment whenever it exceeded the display-only balance snapshot, even though Max now comes from the live pooled quote. A lagging or not-yet-populated snapshot could reject the very amount Max had just offered. The backend's pooled dry run already refuses a real shortfall with a typed error before any prompt, so the form no longer second-guesses it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q (cherry picked from commit b767c89)
`AssetLockTooManyInputs` comes from the shared cap guard that identity registration, identity top-up, Platform-address funding, shielding and direct asset locks all go through, yet its message called every refusal a transfer to Platform and the transaction a deposit. It now names no single operation, only the input counts and how to fix it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q (cherry picked from commit af79e7d)
…city Upstream's capacity refusal reports the usable balance with the fee reserve still in it, or the whole account balance when no address can keep the reserve back, and the banner presented that figure as the most the user could shield. Shielding from Platform now intercepts the refusal, takes a fresh plan and states its `max_shieldable_credits` (zero when nothing can be shielded). Without a plan the refusal keeps the generic envelope rather than guessing a number. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q (cherry picked from commit 907b0cb)
The input-cap guard ran once, before the secret session, and then released the wallet-manager lock. The wallet could change while the user typed the password, so an amount that fit the cap could reach the upstream exact-amount builder needing more inputs than an asset lock may carry. Upstream would then build and broadcast a lock Dash Core drops, with its inputs left reserved. Every asset-lock path (direct locks, identity registration and top-up, Platform-address funding, shielding) now runs the guard a second time inside the session, immediately before the upstream call. The pre-session check stays, so a doomed lock still never prompts. True atomicity needs upstream: it takes the wallet-manager lock itself and builds and broadcasts in one call, and its cap check covers only drain builds. That gap is recorded as a TODO at the guard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q (cherry picked from commit f4e302b)
With the send form no longer pre-checking the display balance, the pooled build's `InsufficientFunds` is the message a user sees for an unaffordable Core send. It quoted raw duff counts; it now shows both amounts in Dash and offers a smaller amount as well as adding funds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q (cherry picked from commit 08c7e29)
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
Core Max still offers relayable amounts below the form's hard-coded minimum, so clicking Max can leave Send disabled. The reservation-expiry cache issue remains a non-blocking upstream follow-up without linked tracking; the live DPNS balance check and final destination-dust guard are fixed. Static verification only: Clippy now passes, while Test Suite remains pending.
🔴 1 blocking | 🟡 1 suggestion(s)
1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The large, intricate changes in src/wallet_backend/payments.rs directly alter funds movement and coin selection by pooling funding sources, finalizing Core sends, and enforcing asset-lock input limits. - 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 xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `src/ui/wallets/send_screen.rs`:
- [BLOCKING] src/ui/wallets/send_screen.rs:3158-3159: Align the Core amount minimum with the builder-quoted Max
This branch offers every positive Core quote, but `min_output_amount()` still requires 5,460 duffs for Core-to-Core sends. The backend now publishes relayable quotes down to the destination's dust threshold, which is 546 duffs for P2PKH. For example, a single spendable 5,000-duff P2PKH coin can quote a Max of 4,808 duffs with a 192-duff fee. Clicking Max fills that value, but `AmountInput::validate_amount()` rejects it against the higher minimum; the component response clears `self.amount`, leaving Send disabled. This contradicts the new builder-quoted Max contract even though the UI minimum predates the PR. Derive the Core minimum and quote eligibility from one shared model policy using the upstream destination rules, and add a UI regression for a positive, relayable Max below 5,460 duffs.
In `src/wallet_backend/mod.rs`:
- [SUGGESTION] src/wallet_backend/mod.rs:2925-2928: Invalidate Core Max when wallet reservations change
(existing thread: https://github.com/dashpay/dash-evo-tool/pull/1107#discussion_r4466881202)
The upstream-owned signal is the appropriate fix: both the pinned and current key-wallet implementations keep `ReservationSet` private and expose no reservation-expiry revision for DET to consume. However, expiry still changes what the builder can spend without changing this quote key. With otherwise unchanged spendable coins, a residual reservation swept after 24 blocks leaves `SpendLimitCache` retaining its reduced Max or `Unavailable` result; the unavailable branch also has no Retry control. This only under-offers and remains non-blocking. Link a follow-up covering the key-wallet/platform-wallet expiry signal and its DET consumer before recording the deferral as tracked; the supplied PR discussion currently links none. No local reservation mirror is needed.
The send form required a fixed 5,460 duffs for a Core payment while the backend quotes any relayable Max down to the destination's dust threshold, so a Max like 4,808 duffs filled an amount the field refused and left Send disabled. CoreDestinationScript::dust_threshold_duffs (upstream's dust rule) is now the one minimum for both the form and the backend's Max guard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Waiting for bot review — coderabbitai not yet · thepastaclaw requested changes — dismiss the review or push a fix, 1 thread unresolved — resolve it. 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)
The Core dust-policy fix and the earlier fee, live-balance, and active-operation reservation fixes are confirmed. One blocking mismatch remains: a positive Platform-to-Shielded Max below 500,000 credits is offered but rejected by the amount field; passive Core reservation expiry also remains an untracked, non-blocking follow-up. This was a static verification only; Clippy and Test Suite were still pending in the current CI checks.
🔴 1 blocking | 🟡 1 suggestion(s)
1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The large, intricate changes in src/wallet_backend/payments.rs directly alter pooled coin selection, transaction finalization and broadcasting, and asset-lock input limits, meeting the critical funds-movement bar. - 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 xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `src/ui/wallets/send_screen.rs`:
- [BLOCKING] src/ui/wallets/send_screen.rs:3201-3202: Accept small positive Platform shielding Max quotes in the amount field
This branch offers every positive planner quote, but min_output_amount() applies the transparent Platform-address output minimum of 500,000 credits to Platform-to-Shielded sends. At the pinned upstream revision, an address holding the shield reserve plus 100,000 credits produces a Max of 100,000 credits: the planner accepts that positive claim, the execution path adds the fee to input 0 separately, and ShieldTransitionV0::validate_structure requires a positive shield amount rather than the transparent-output minimum. Clicking Max therefore fills an amount that AmountInput::validate_amount() rejects, clearing self.amount and leaving Send disabled. Define the operation-specific minimum in the shared model policy using the upstream shield rules, and add a UI regression that clicks Max for a positive quote below 500,000 credits. This is separate from the fixed zero-capacity case.
In `src/wallet_backend/mod.rs`:
- [SUGGESTION] src/wallet_backend/mod.rs:2925-2928: Invalidate Core Max when wallet reservations change
(existing thread: https://github.com/dashpay/dash-evo-tool/pull/1107#discussion_r4466881202)
The key combines pooled coin composition and DET spend activity, neither of which changes when an otherwise unchanged coin becomes selectable after a residual reservation expires. Both the pinned and supplied default key-wallet sources keep ReservationSet private and expire entries after 24 blocks; SpendLimitCache retains a loaded or unavailable result for the unchanged key, and unavailable results offer no Retry control. Your upstream-ownership explanation is correct: DET should consume an expiry/revision notification from key-wallet/platform-wallet rather than duplicate reservation bookkeeping. This safely under-offers and can be deferred, but the supplied discussion and PR description do not link a tracker covering that upstream signal and DET's consumption of it. Link that follow-up so the limitation is a tracked deferral.
…nt field The form held Platform-to-Shielded sends to the 500,000-credit minimum of a transparent Platform-address output, so a smaller planner quote filled an amount the field refused. Upstream's shield transition and planner only require a positive amount. SpendLimitKind::min_amount_credits is now the one minimum for every backend-quoted Max: the Core payment's dust threshold, or one credit for a shield from Platform. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Waiting for bot review — coderabbitai not yet · thepastaclaw requested changes — dismiss the review or push a fix, 1 thread unresolved — resolve it. 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)
The current head fixes the previously reported amount-minimum, live username-balance, and fee-multiplier defects, but introduces a received-deposit validation bypass while the wallet is busy. Three non-blocking suggestions remain concerning reservation-expiry recovery and quote-path performance. Verification was static only: no builds or tests were run; Test Suite and Clippy remain pending, and the Platform pin guard passed.
🔴 1 blocking | 🟡 3 suggestion(s)
1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: 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:
criticalbygpt-6.1-sol(effort low) — The large, intricate changes in src/wallet_backend/payments.rs directly alter pooled coin selection, transaction finalization and broadcasting, and asset-lock input limits, meeting the critical funds-movement bar. - 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 xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `src/ui/identity/add_new_identity_screen/mod.rs`:
- [BLOCKING] src/ui/identity/add_new_identity_screen/mod.rs:1127-1142: Preserve the deposit-address limit when the wallet is busy
This branch handles both UseWalletBalance and ReceiveDeposit, but the busy exception removes the deposit-address limit as well as the unavailable builder ceiling. current_validation_ceiling_duffs() returns None before intersecting the quote with funding_address_balance_duffs, and asset_lock_amount_refusal(..., None, ...) checks only the network minimum. The receive-deposit renderer explicitly keeps the field editable while busy and clears its maximum. Consequently, a user with a 0.1 DASH deposit and additional wallet funds can enter 0.2 DASH and dispatch it while another operation is in progress. FundWithWallet carries no deposit-address restriction, so the pooled backend can fund the request from unrelated wallet funds. This also contradicts the received-deposit boundary documented in SND-017. Preserve the known deposit-address ceiling independently of the optional builder quote, using the shared model amount policy even while Max is withheld. Add a busy ReceiveDeposit regression with an explicit amount above the deposit balance; the existing deposit-bound regression covers only a loaded quote.
In `src/wallet_backend/payments.rs`:
- [SUGGESTION] src/wallet_backend/payments.rs:1370-1375: Reuse a pooled funding snapshot across Core Max probes
Every candidate in largest_core_payment_at_most reaches this call and clones all resolved ManagedCoreFundsAccount values again. At the pinned key-wallet revision these clones copy the address pools, UTXO maps, transaction bookkeeping, and spent-output collections; only the reservation set is shared. Reservation-aware narrowing can therefore repeat a full funding-state copy dozens of times while holding the wallet-manager write lock, consuming the five-second search budget on historical state unrelated to selection and delaying other wallet work. Prepare scratch funding accounts once per quote and reuse them across candidates, with a fixed change address and the existing owner-guarded reservation release so probe reuse does not advance the scratch change pool.
In `src/ui/wallets/send_screen.rs`:
- [SUGGESTION] src/ui/wallets/send_screen.rs:963-971: Avoid rebuilding formatted address lists for each quote-cache lookup
spend_limit_target calls this helper during status rendering, Max rendering, and request scheduling, so an unchanged Platform-to-Shielded form repeats the work several times per frame. get_platform_addresses takes the wallet read lock, Bech32m-encodes every tracked Platform address, allocates a string-keyed deduplication map, and sorts the result; this helper then allocates another vector just to hash the addresses and balances. These repeated encodings and allocations run on the egui thread even when the cached quote is valid. Maintain a balance revision alongside wallet updates, or compute the canonicalized fingerprint once per frame and share it across quote lookups, preserving live-balance invalidation.
In `src/wallet_backend/mod.rs`:
- [SUGGESTION] src/wallet_backend/mod.rs:2925-2928: Invalidate Core Max when wallet reservations change
(existing thread: https://github.com/dashpay/dash-evo-tool/pull/1107#discussion_r4466881202)
The upstream ownership constraint is confirmed: key-wallet's ReservationSet and its height-based expiry observation remain crate-private at both the pinned rust-dashcore revision and current dev tip. Nevertheless, this key contains only pooled-coin state and DET spend activity, neither of which necessarily changes when a residual reservation expires after 24 blocks. SpendLimitCache retains loaded and unavailable answers for that unchanged revision, and the unavailable state has no inline Retry control, so a reduced or unavailable Max can persist after the coins become selectable again. An explicit recheck could reuse the existing reservation-aware backend without mirroring reservations. If recovery remains deferred to an upstream revision/expiry API, link a tracking issue covering the owning key-wallet/platform-wallet API and its DET consumer; the supplied thread and PR description explain the limitation but provide no tracking reference.
…llet is busy Withholding Max while another transaction is in progress also dropped the deposit address bound, so a received-deposit registration could be dispatched above the deposit and funded from other wallet coins. Only the wallet-wide ceiling now waits for the quote; the deposit balance still bounds the amount. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Waiting for bot review — coderabbitai not yet · 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 2 only (no Phase 1 for this repository)
At the assigned head, the received-deposit regression is fixed, but the new quote probes still omit platform-wallet's persistent pending-spend fences and can offer a Max that the real finalizer rejects. Four nonblocking concerns remain around repeated quote work, reservation-expiry invalidation, and discarded builder diagnostics. Clippy passed; Test Suite failed with disk-exhaustion errors, so it does not establish a passing test gate. No local builds or tests were run.
🔴 1 blocking | 🟡 4 suggestion(s)
3 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: 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:
criticalbygpt-6.1-sol(effort low) — The large, intricate changes in src/wallet_backend/payments.rs directly alter pooled coin selection, transaction finalization, and broadcasting for funds movement, meeting both critical-tier requirements. - 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 xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `src/wallet_backend/payments.rs`:
- [BLOCKING] src/wallet_backend/payments.rs:1380-1386: Quote through platform-wallet's full spending policy, including pending-spend fences
This dry run proves key-wallet buildability, but not acceptance by the real platform-wallet finalizer. At the pinned Platform revision, `CoreWallet::finalize_transaction_with_options` additionally checks `info.generation.in_broadcast_conflict(&unsigned)` and returns `InputMidBroadcast` for fenced inputs (`packages/rs-platform-wallet/src/wallet/core/transaction.rs:733-755`). An ambiguous or cancelled broadcast retains those fences until an observed spend; they do not expire with key-wallet's 24-block reservations. After a reservation expires, a fresh quote can therefore build successfully against a still-fenced coin and publish Max, while the actual send rejects it after opening the secret session. The operation-lifetime guard has already closed and cannot represent this pending-spend state. Asset-lock probes omit the same policy, which upstream's real asset-lock builder also enforces. Expose and consume a read-only quote/admissibility operation from platform-wallet, where reservations and fences are owned, rather than duplicating another part of its spending policy in DET. Add a regression comparing a fresh quote with real finalization after an unobserved dispatch outlives its key-wallet reservation.
- [SUGGESTION] src/wallet_backend/payments.rs:1400-1402: Preserve unexpected builder errors during the Core Max search
The `.ok()` conversion makes every builder failure look like an amount that is too high. This discards unexpected failures such as `BuilderError::NoChangeAddress`, not just funding or input-count rejections. If no candidate succeeds, `core_send_search_outcome()` reports `HeldByPendingTransaction`; the screen then caches that unavailable result without a Retry control, and the original diagnostic is lost. The asset-lock search already distinguishes expected rejection outcomes from unexpected errors. Return a source-preserving `Result` here, narrow only on known funding/input-limit variants, and propagate other failures so the quote enters the retryable failed state. Add coverage that an unexpected builder error is not relabelled as a reservation shortfall.
- [SUGGESTION] src/wallet_backend/payments.rs:1370-1375: Reuse a pooled funding snapshot across Core Max probes
(existing thread: https://github.com/dashpay/dash-evo-tool/pull/1107#discussion_r4467732955)
Every candidate clones the resolved funding accounts again under the wallet-manager write lock. The pinned `ManagedCoreFundsAccount` derives `Clone` over address-pool, transaction, UTXO, and spent-output state; only its reservation set is shared. Even an unnarrowed quote performs the proof build and a separate all-coins drain, while reservation narrowing can repeat the deep copy many more times. The five-second deadline is checked between candidates, so it does not bound an individual clone/build or the subsequent drain. Prefer a reusable quote/funding-snapshot primitive in platform-wallet; any interim scratch-account reuse must preserve owner-guarded reservation release and avoid advancing its change pool. Please link the proposed performance follow-up.
In `src/ui/wallets/send_screen.rs`:
- [SUGGESTION] src/ui/wallets/send_screen.rs:963-971: Avoid rebuilding formatted address lists for each quote-cache lookup
(existing thread: https://github.com/dashpay/dash-evo-tool/pull/1107#discussion_r4467732963)
`spend_limit_target()` is reached by status rendering, Max rendering, and request scheduling, including frames with a valid cached quote. Each Platform-shield lookup calls `get_platform_addresses()`, which holds the wallet read lock while encoding addresses and constructing a string-keyed deduplication map, then sorts and allocates the result; this helper allocates another vector before hashing it. Backend quote caching does not avoid this recurring egui-thread work. Maintain a balance revision with wallet updates, or compute and share one fingerprint per frame while preserving live-balance invalidation. The proposed performance follow-up has no linked tracker in the supplied discussion; please link one if this remains deferred.
In `src/wallet_backend/mod.rs`:
- [SUGGESTION] src/wallet_backend/mod.rs:2925-2928: Invalidate Core Max when wallet reservations change
(existing thread: https://github.com/dashpay/dash-evo-tool/pull/1107#discussion_r4466881202)
The quote revision hashes pooled outpoints, values, spendability, and DET operation activity, but none changes solely because key-wallet sweeps an aged reservation. When an abandoned, unfenced reservation expires with otherwise unchanged coins, `SpendLimitCache::ensure_requested()` retains the reduced quote or `HeldByPendingTransaction` outcome until another invalidation; unavailable outcomes offer no Retry control. Consume an authoritative reservation/admissibility revision or expiry notification from key-wallet/platform-wallet rather than maintaining a DET reservation mirror. That signal must also respect platform-wallet's longer-lived pending-spend fences: reservation expiry alone does not make an ambiguously broadcast input safe to spend. This remains a nonblocking under-offering case, but the proposed upstream-dependent deferral needs a linked tracking issue.
Dismissed by maintainer decision: the remaining blocker (Max quote vs. platform-wallet's broadcast fence) is rejected as an edge case with no double-spend risk — #1107 (comment); the suggestion moves to #1112.
|
@coderabbitai review No review for |
|
@thepastaclaw review No review for |
|
Ready for review — files with no dedicated owner: lklimek. |
|
@thepastaclaw please re-review this pr |
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 head 2d99079 against the base and relevant pinned/current upstream sources; the prior affordability, dust, amount-minimum, and live-balance defects are addressed. Six non-blocking findings remain concerning quote admissibility, reservation-expiry invalidation, unexpected builder errors, and avoidable cloning/allocation. This was static verification only: current Test Suite, Clippy, and Platform pin guard checks pass; PR Hygiene remains pending.
🟡 6 suggestion(s)
5 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: 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:
criticalbygpt-6.1-sol(effort low) — This large, intricate diff changes funds movement and coin selection in src/wallet_backend/payments.rs, including pooled funding sources, transaction finalization, send limits, and asset-lock input enforcement. - 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 xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `src/wallet_backend/snapshot.rs`:
- [SUGGESTION] src/wallet_backend/snapshot.rs:983-987: Avoid eagerly deep-cloning the funding pool on every snapshot event
`AssetLockFundingPool::from_wallet` clones every resolved funding account before `try_asset_lock_final_input_state` attempts its observation try-lock. At the pinned key-wallet revision, these clones copy address pools, transaction bookkeeping, UTXO maps, and spent-output collections; reservation state is shared. On contention, all those copies are discarded. On success, `observe_asset_lock_inputs_locked` clones each managed account again for its scratch builder. This adds a full-pool copy to ordinary EventBridge snapshot recomputation while the wallet-manager read guard is held, even when no Max query is running. Acquire the observation try-lock before preparing scratch state and pass borrowed pooled accounts so observation needs only its existing per-account scratch clone.
In `src/wallet_backend/payments.rs`:
- [SUGGESTION] src/wallet_backend/payments.rs:1380-1386: Quote through platform-wallet's full spending policy, including pending-spend fences
(existing thread: https://github.com/dashpay/dash-evo-tool/pull/1107#discussion_r4468128348)
This dry run establishes key-wallet buildability, but the real platform-wallet finalizer additionally checks `info.generation.in_broadcast_conflict(&unsigned)` and can reject the same inputs with `InputMidBroadcast`. That distinction exists in both the pinned and current upstream implementations, including the real asset-lock build path. After a retained reservation expires, a quote can therefore succeed while finalization refuses it after secret access. The finalizer prevents a conflicting broadcast, so this is not a funds-safety blocker. Also, the reservation clock can advance during historical catch-up; the scenario does not necessarily require waiting for 24 newly mined blocks. Track a read-only quote/admissibility API in dashpay/platform and consume it here, rather than adding another DET mirror of private spending policy. The Known limitations entry currently has no tracking link for this API gap.
- [SUGGESTION] src/wallet_backend/payments.rs:1401-1402: Preserve unexpected builder errors during the Core Max search
(existing thread: https://github.com/dashpay/dash-evo-tool/pull/1107#discussion_r4468128360)
Calling `.ok()` turns every `BuilderError` into an unaffordable candidate, including failures unrelated to funding or input limits. If no probe succeeds, the outcome becomes `HeldByPendingTransaction`, which is cached without the failed-state Retry control, and the original diagnostic is discarded. The scope comment on #1112 explicitly tracks the repair, but this error-classification defect is introduced by this PR's new search and remains present on this head. Return a source-preserving result, narrow only on expected funding/input-limit failures, and propagate unexpected errors into the retryable quote-failure state. This remains non-blocking because the conversion can suppress Max but cannot publish an unproven amount.
- [SUGGESTION] src/wallet_backend/payments.rs:1370-1375: Reuse a pooled funding snapshot across Core Max probes
(existing thread: https://github.com/dashpay/dash-evo-tool/pull/1107#discussion_r4467732955)
Every candidate reconstructs and clones the pooled funding accounts while the wallet-manager write lock is held. Those derived clones copy historical account state as well as UTXOs, so reservation-aware narrowing can repeat a full-pool copy many times. The deadline preserves conservative results, but it is checked between candidates and cannot interrupt a clone or build; the subsequent `pooled_spendable_coins` drain also runs under the same lock after the search. Prepare reusable scratch funding accounts once per quote, with a fixed change address and owner-guarded reservation release, to avoid repeatedly copying unchanged history. The proposed performance follow-up currently has no tracking link.
In `src/wallet_backend/mod.rs`:
- [SUGGESTION] src/wallet_backend/mod.rs:2925-2928: Invalidate Core Max when wallet reservations change
(existing thread: https://github.com/dashpay/dash-evo-tool/pull/1107#discussion_r4466881202)
The quote revision combines the pooled coin fingerprint with DET spend activity, but neither changes when a residual key-wallet reservation reaches its 24-block TTL while the coins remain otherwise unchanged. `SpendLimitCache::ensure_requested` retains loaded and unavailable results for the same revision, so a reduced Max or `HeldByPendingTransaction` can survive after the reservation stops restricting selection. The reservation set remains private in both pinned and current key-wallet, so an upstream reservation revision/expiry signal is the appropriate solution, not another DET reservation mirror. This only under-offers and is non-blocking; link an upstream issue and the DET follow-up, or provide an explicit quote-retry escape hatch.
In `src/ui/wallets/send_screen.rs`:
- [SUGGESTION] src/ui/wallets/send_screen.rs:963-971: Avoid rebuilding formatted address lists for each quote-cache lookup
(existing thread: https://github.com/dashpay/dash-evo-tool/pull/1107#discussion_r4467732963)
Live-balance invalidation is correct, but every shield quote lookup obtains its revision by rebuilding the display address list. `get_platform_addresses` holds the wallet read lock while Bech32m-encoding addresses, building a string-keyed deduplication map, and sorting; this helper then allocates another vector solely for hashing. Status rendering, Max rendering, and request scheduling repeat that work on the egui thread even when balances and the cached quote are unchanged. Maintain a revision with wallet updates or compute a canonical fingerprint once per frame and share it across lookups, preserving the existing freshness behavior. The proposed performance follow-up currently has no tracking link.
|
Policy satisfied — this can merge. |
TL;DR: "Max" for Core sends, asset locks and shielding from Platform now comes from the wallet library's own quotes, so a Max can no longer fail when you send. Username registration checks every fee the network will charge, including the real cost of joining a crowded vote, before anything is paid.
User story
As a wallet user, I want Max to send exactly what the wallet can actually send, and username registration to tell me the real price up front, so that I never lose a fee on a transaction that was bound to fail.
Scenario
Actual behavior
Expected behavior
Detailed discussion
Based on
v1.0-dev(Platform v5.1-dev575d961). Rebuilt from #1015's stale base by replaying only this PR's own commits.username_name_admission_reserve_creditsis derived from the contract's chooseFirst declaration and the platform version (0 before DPNS v3). The backend guard and the confirmation both require it. The backend guard checks the balance read from Platform right before the preorder.max_asset_lock_transaction_inputscounts as unbuildable. Exact-amount asset locks that would need more inputs are refused before any secret is opened (TaskError::AssetLockTooManyInputs) at all five entry points.send_paymentcallsfinalize_transactionover the pooled sources andbroadcast_finalized_transaction; change goes to BIP-44, coin selection is upstream's default. Max ispooled_max_sendableviaWalletTask::GetSpendLimitand theui/state/spend_limit.rscache. A pooled dry run before signing keeps shortfalls and too-many-inputs typed and avoids a passphrase prompt for a send that cannot work. The old UI-side Max helpers are removed. When Max is zero the form says why, from typed outcomes (TaskError::CoreSendMaxUnavailable): nothing spendable outside CoinJoin, coins below their own fee, or coins held by an unfinished transaction. A search that times out offers a retry instead. The quote is keyed on the coins the pooled build can spend, so new blocks and chainlocks do not re-quote it.shielded_shield_preflight(0).max_shieldable_credits; the Max hint names the planner's 2× reserve, while the fee preview and confirmation state the two-action fee the shield is charged;TaskError::ShieldFromPlatformCapacityExceeded. Upstream's shield drops its inputs' proven post-state, so after a confirmed shield DET runs upstream's Platform-address sync pass (bounded 10 s wait, best-effort). The next Max is then quoted from the spent-down balances.Sdk::contest_fund_to_join; the result carriescontest_fund, shown in the review and consent dialog. The backend re-quotes before the preorder and refuses a stale approval asUsernameRegistrationTermsChanged.document_create_contest_fund_capuses the poll'srequired_vote_resolution_fund(moderation elections get the moderation fund).TaskError::UsernameContestFulland aContestFullavailability row, frommax_contenders_per_contestunder protocol 14 create validation (none before). DET counts contenders itself from proved vote-tally pages, because the SDK does not expose the count.Fee estimates: upstream first, corrected in one place
model/fee_estimation.rscalls the upstream function and then one constant infee_estimation::tolerance. The upstream functions are key-walletestimate_tx_size+FeeRate::normal(), dppcalculate_min_required_fee/estimate_min_fee, thePlatformVersionfee tables, and platform-wallet's planner reserves. Each constant is anEstimateTolerance { percent, floor }.apply_feeonly raises a fee.apply_maxlowers a Max by exactly whatapply_feeadds, so a Max plus its fee never exceeds the funds. The arithmetic saturates: the headroom is computed inu128, and a Max below the headroom becomes 0. The module doc makes it the only place DET corrects an upstream estimate. A future tolerance, such as feat(documents): agree to document action fees before broadcasting #1122's multiplier increase, would become one more constant there.latest().max_address_inputs).TODO(upstream), because both are private upstream: the 500-input standard cap andpooled_max_sendable's per-input pricing. The 546-duff change remainder key-wallet may give the miner is a third such mirror.estimate_contract_create_detailed+ContractComponents,estimate_masternode_vote, the*_with_sizevariants, the hand-keptStorageFeeConstants/StateTransitionMinFees/DataContractRegistrationFeestables.Known limitations
v1.0-dev) and is safe; it is left for a follow-up.finalize_transactionstringifiesTooManyInputs; the pooled-source resolver and contender count are crate-private.Testing
cargo clippy --all-features --all-targets -- -D warningsclean. These library suites pass: fee estimation, wallet-backend payments/snapshot, the Send and single-key Send screens, identity, and shielded.cargo test --test kittest send_screenpasses.det-clihas no Max or fee-preview command):e532ebf8bd2e26751f819311e98faa5de9041269c6810390e6caa4e1e75bda7bcd10033310acca48eb95abbcf8fafba7ee391f81884f726163319b43e38fd8843f7b6870c6c3208ad3c9380f291ea508dffc5654fb965324e259e4d55710bc7fNo panics in
det.log/det-stderr.log. Not run locally: full kittest and e2e (CI covers them); no live shields.🤖 Co-authored by Claudius the Magnificent AI Agent
🤖 Generated with Claude Code
https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
https://claude.ai/code/session_01WunYYhY7P2FJqHVgkHiXtT
PR Hygiene ·
2d99079docs/user-stories.md,src/backend_task/dashpay/contact_info.rs,src/backend_task/error.rsand 39 more) — approved by 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