Skip to content

feat(voting): vote from the pills, with the vote-limit and block confirmations and Add your voting keys - #1347

Open
romchornyi wants to merge 11 commits into
feat/voting-duplicates-and-detailsfrom
feat/voting-vote-from-pills
Open

romchornyi wants to merge 11 commits into
feat/voting-duplicates-and-detailsfrom
feat/voting-vote-from-pills

Conversation

@romchornyi

@romchornyi romchornyi commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

Stacked on the stage 3 PR (duplicates in place, Request details). A masternode owner now votes from the list itself, every vote passes the vote-limit and block confirmations in one order, and the first vote sets up which masternodes vote. This PR also carries the review fixes to stages 1–3 made since they were published. Feature summary: docs/features/username-voting/README.md.

What was done?

  • Vote from the pills. A tap on the block or approve pill sends the vote: the pill shows it is sending, every contest's pills wait until it ends, a toast confirms it and the pill is filled. A tap on a filled pill, or "Cancel approval" in Request details, cancels with an abstain. The store refuses a second send while one runs.
  • One gate order (VoteAttempt, a pure state machine, and one VoteAttemptCoordinator per attempt; ADR-0035, docs/adr/0035-…): voting has ended → voting not set up → "No votes left" → "One vote left" → for a block, the lock-is-final confirmation. Only the first thing that stops a vote is shown; after "Add your voting keys" the vote goes on without a second tap. A vote every ticked masternode already holds is not sent again; a toast says so.
  • "Add your voting keys" rebuilt with tick-boxes for this wallet's masternodes and imported keys, a "N votes will be cast" caption, the linking warning for more than one, and a Block / Approve button that casts. Until it is confirmed once on this install, no recorded vote counts as the owner's: no filled pill, and the "my votes" filters say "Set up voting to filter by your votes." "…" → "Voting keys" opens the same screen without the button. "Enter voting key" follows the design and names its two refusals.
  • Outcomes. A failed vote shows an error toast with a close button; a mixed outcome opens VoteResultSheet with each masternode and "Try again" for the failed ones only.
  • The list's bar is the DashUIKit NavigationBar with a round back button and a NavigationBarCircleMenu; refresh failed, node list incomplete and vote history unavailable show as one SystemMessageView above the rows.
  • Removed: CastVoteSheet, ContestDetailScreen, VotingNodeSelectionSheet, and 76 voting strings no code uses any more (all locales).
  • ADR-0035 and ADR-0038 (only the voting store writes the remembered node choice) added to the decision log as Proposed; the feature summary grows with stage 4.

How Has This Been Tested?

  • DashWalletTests (scheme dashwallet-dashpay, Debug, iPhone 17 simulator, iOS 26.5) on this head (2026-11-13, after the rebase onto develop cb5ab12ee and the latest review fixes): 2519 tests, 0 failures, 1 skipped; Release build (simulator) succeeded. New tests: VoteAttemptTests (gate order, abstain without lock-is-final, per-masternode limit), VoteAttemptCoordinatorTests (dialog order, retry after the key flow, already-voted, cancel), VotingKeysViewModelTests, and new cases in the store, list and Request details view-model tests (single send, outcome per contest, set-up gate).
  • Live run on testnet: not yet — planned for the end, once stage 5b is in, across the whole stack.
  • scripts/a11y_audit.py --check: no new findings; test-target membership check: ok.

Screenshots

To add with the live run: the sending and filled pill, "One vote left", the block confirmation, "Add your voting keys", the result sheet, and the list bar with a message.

Breaking Changes

None. After the update an owner who voted before confirms "Add your voting keys" once before the next vote; the ticks stored by the earlier version are pre-ticked.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • ADR (ADR-0001): ADR-0035 and ADR-0038 added
  • Nothing in this PR holds customer data, unfixed vulnerability detail, secrets, or step-by-step attack detail against keys, PIN or encryption (ADR-0001, rule 2)

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 127 files, which is 27 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9866c5f7-352e-4775-9da9-91662562f7d4
Commits

Reviewing files that changed from the base of the PR and between 9d219ea and 9dbff43.

Files selected for processing: 127

  • DashWallet.xcodeproj/project.pbxproj
  • DashWallet/Sources/Application/App.swift
  • DashWallet/Sources/Infrastructure/SwiftDashSDK/Voting/MasternodeVoteCaster.swift
  • DashWallet/Sources/Infrastructure/SwiftDashSDK/Voting/MasternodeVoterRegistry.swift
  • DashWallet/Sources/Models/Voting/VotingPrefs.swift
  • DashWallet/Sources/UI/DashPay/Voting/CastVoteSheet.swift
  • DashWallet/Sources/UI/DashPay/Voting/ContestDetailScreen.swift
  • DashWallet/Sources/UI/DashPay/Voting/Details/RequestDetailsScreen.swift
  • DashWallet/Sources/UI/DashPay/Voting/Details/RequestDetailsViewModel.swift
  • DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeyInputScreen.swift
  • DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeyInputViewModel.swift
  • DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysScreen.swift
  • DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift
  • DashWallet/Sources/UI/DashPay/Voting/List/VotingListViewModel.swift
  • DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift
  • DashWallet/Sources/UI/DashPay/Voting/UsernameVotingScreen.swift
  • DashWallet/Sources/UI/DashPay/Voting/VoteAttempt/VoteAttempt.swift
  • DashWallet/Sources/UI/DashPay/Voting/VoteAttempt/VoteAttemptCoordinator.swift
  • DashWallet/Sources/UI/DashPay/Voting/VoteAttempt/VoteAttemptDialogs.swift
  • DashWallet/Sources/UI/DashPay/Voting/VoteAttempt/VoteResultSheet.swift
  • DashWallet/Sources/UI/DashPay/Voting/VoteFlow.swift
  • DashWallet/Sources/UI/DashPay/Voting/VotingContestCard.swift
  • DashWallet/Sources/UI/DashPay/Voting/VotingKeyInputScreen.swift
  • DashWallet/Sources/UI/DashPay/Voting/VotingKeysScreen.swift
  • DashWallet/Sources/UI/DashPay/Voting/VotingNodeSelectionSheet.swift
  • DashWallet/Sources/UI/DashPay/Voting/VotingViewModel.swift
  • DashWallet/Sources/UI/Menu/Main/MainMenuViewController.swift
  • DashWallet/ar.lproj/Localizable.strings
  • DashWallet/ar.lproj/Localizable.stringsdict
  • DashWallet/bg.lproj/Localizable.strings
  • DashWallet/bg.lproj/Localizable.stringsdict
  • DashWallet/ca.lproj/Localizable.strings
  • DashWallet/ca.lproj/Localizable.stringsdict
  • DashWallet/cs.lproj/Localizable.strings
  • DashWallet/cs.lproj/Localizable.stringsdict
  • DashWallet/da.lproj/Localizable.strings
  • DashWallet/da.lproj/Localizable.stringsdict
  • DashWallet/de.lproj/Localizable.strings
  • DashWallet/de.lproj/Localizable.stringsdict
  • DashWallet/el.lproj/Localizable.strings
  • DashWallet/el.lproj/Localizable.stringsdict
  • DashWallet/en.lproj/Localizable.strings
  • DashWallet/en.lproj/Localizable.stringsdict
  • DashWallet/eo.lproj/Localizable.strings
  • DashWallet/eo.lproj/Localizable.stringsdict
  • DashWallet/es.lproj/Localizable.strings
  • DashWallet/es.lproj/Localizable.stringsdict
  • DashWallet/et.lproj/Localizable.strings
  • DashWallet/et.lproj/Localizable.stringsdict
  • DashWallet/fa.lproj/Localizable.strings
  • DashWallet/fa.lproj/Localizable.stringsdict
  • DashWallet/fi.lproj/Localizable.strings
  • DashWallet/fi.lproj/Localizable.stringsdict
  • DashWallet/fil.lproj/Localizable.strings
  • DashWallet/fil.lproj/Localizable.stringsdict
  • DashWallet/fr.lproj/Localizable.strings
  • DashWallet/fr.lproj/Localizable.stringsdict
  • DashWallet/hr.lproj/Localizable.strings
  • DashWallet/hr.lproj/Localizable.stringsdict
  • DashWallet/hu.lproj/Localizable.strings
  • DashWallet/hu.lproj/Localizable.stringsdict
  • DashWallet/id.lproj/Localizable.strings
  • DashWallet/id.lproj/Localizable.stringsdict
  • DashWallet/it.lproj/Localizable.strings
  • DashWallet/it.lproj/Localizable.stringsdict
  • DashWallet/ja.lproj/Localizable.strings
  • DashWallet/ja.lproj/Localizable.stringsdict
  • DashWallet/ko.lproj/Localizable.strings
  • DashWallet/ko.lproj/Localizable.stringsdict
  • DashWallet/mk.lproj/Localizable.strings
  • DashWallet/mk.lproj/Localizable.stringsdict
  • DashWallet/ms.lproj/Localizable.strings
  • DashWallet/ms.lproj/Localizable.stringsdict
  • DashWallet/nb.lproj/Localizable.strings
  • DashWallet/nb.lproj/Localizable.stringsdict
  • DashWallet/nl.lproj/Localizable.strings
  • DashWallet/nl.lproj/Localizable.stringsdict
  • DashWallet/pl.lproj/Localizable.strings
  • DashWallet/pl.lproj/Localizable.stringsdict
  • DashWallet/pt.lproj/Localizable.strings
  • DashWallet/pt.lproj/Localizable.stringsdict
  • DashWallet/ro.lproj/Localizable.strings
  • DashWallet/ro.lproj/Localizable.stringsdict
  • DashWallet/ru.lproj/Localizable.strings
  • DashWallet/ru.lproj/Localizable.stringsdict
  • DashWallet/sk.lproj/Localizable.strings
  • DashWallet/sk.lproj/Localizable.stringsdict
  • DashWallet/sl.lproj/Localizable.strings
  • DashWallet/sl.lproj/Localizable.stringsdict
  • DashWallet/sl_SI.lproj/Localizable.strings
  • DashWallet/sl_SI.lproj/Localizable.stringsdict
  • DashWallet/sq.lproj/Localizable.strings
  • DashWallet/sq.lproj/Localizable.stringsdict
  • DashWallet/sr.lproj/Localizable.strings
  • DashWallet/sr.lproj/Localizable.stringsdict
  • DashWallet/sv.lproj/Localizable.strings
  • DashWallet/sv.lproj/Localizable.stringsdict
  • DashWallet/th.lproj/Localizable.strings
  • DashWallet/th.lproj/Localizable.stringsdict
  • DashWallet/tr.lproj/Localizable.strings
  • DashWallet/tr.lproj/Localizable.stringsdict
  • DashWallet/uk.lproj/Localizable.strings
  • DashWallet/uk.lproj/Localizable.stringsdict
  • DashWallet/vi.lproj/Localizable.strings
  • DashWallet/vi.lproj/Localizable.stringsdict
  • DashWallet/zh-Hans.lproj/Localizable.strings
  • DashWallet/zh-Hans.lproj/Localizable.stringsdict
  • DashWallet/zh-Hant-TW.lproj/Localizable.strings
  • DashWallet/zh-Hant-TW.lproj/Localizable.stringsdict
  • DashWallet/zh.lproj/Localizable.strings
  • DashWallet/zh.lproj/Localizable.stringsdict
  • DashWallet/zh_TW.lproj/Localizable.strings
  • DashWallet/zh_TW.lproj/Localizable.stringsdict
  • DashWalletTests/MasternodeVoteCasterTests.swift
  • DashWalletTests/RequestDetailsViewModelTests.swift
  • DashWalletTests/VoteAttemptCoordinatorTests.swift
  • DashWalletTests/VoteAttemptTests.swift
  • DashWalletTests/VotingKeyImportTests.swift
  • DashWalletTests/VotingKeysViewModelTests.swift
  • DashWalletTests/VotingListSectionTests.swift
  • DashWalletTests/VotingListViewModelTests.swift
  • DashWalletTests/VotingStoreTests.swift
  • DashWalletTests/XCTestCase+YieldUntil.swift
  • docs/adr/0035-run-every-vote-through-a-pure-vote-attempt-state-machine.md
  • docs/adr/0038-let-only-the-voting-store-write-the-remembered-node-choice.md
  • docs/adr/README.md
  • docs/features/username-voting/README.md

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@romchornyi
romchornyi added this pull request to stack #1329 November 10, 2026 16:00
@thepastaclaw

thepastaclaw commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

⏸️ Automatic re-review is paused: the review of commit 640ed1c stepped back and asked for a decision before more rounds, and its request for changes stands — @thepastaclaw review asks for a review of this commit (commit 9dbff43)

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 1 + Phase 2

The shared vote-gate flow is coherent, and exact-head CI passes simulator tests, target-membership checks, and accessibility auditing. Static verification confirmed four blocking issues involving persisted node selections, incomplete cancellation reporting, retry serialization, and large result reports, plus two nonblocking findings. No local builds or tests were run; live testnet validation remains pending.

🔴 4 blocking | 🟡 1 suggestion(s) | 💬 1 nitpick(s)

6 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Preserve stored ticks when node resolution temporarily becomes empty
DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift:86-92

When an open manage-mode screen observes its node list change from populated to temporarily empty, rowsChanged() intersects its nonempty ticks with an empty set and immediately persists the result through saveTicks(). MasternodeVoterRegistry explicitly returns an empty resolution when the SDK is unavailable or its masternode phase has not synced, and VotingStore.refreshVotableNodes() deliberately avoids settling persisted selections in that state. This new ViewModel bypasses that protection, erasing the user's standing multi-node choice and sending the next vote back through key setup after nodes return. Preserve the selection while node resolution is unavailable and add a manage-mode populated → temporarily empty → populated regression test.

source: muse-spark-1.3-contributor (phase1-reviewer: general)

🔴 Blocking: Include exhausted masternodes in incomplete vote reporting
DashWallet/Sources/UI/DashPay/Voting/VoteAttempt/VoteAttempt.swift:107-112

The state machine removes exhausted candidates before returning .send, and no later layer receives those excluded nodes or their reasons. With two ticked masternodes approving a request, one exhausted and one still able to vote, Cancel approval sends abstain only from the latter. VotingStore then sees a completely successful one-node report and displays "Vote cancelled", although the exhausted node still approves the request. The removed cast sheet disclosed exhausted exclusions; the replacement neither warns about them nor includes them in its partial-result report. Continue skipping their broadcasts, but carry excluded candidates into an explicit incomplete outcome or warning, and cover mixed-limit cancellation in an aggregation regression test.

source: gpt-6.1-sol (phase2-reviewer: general, security-auditor)

🔴 Blocking: Reserve the global operation slot before retrying history
DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:568-576

retryFailed() checks only whether its own contest is sending and leaves all store-owned in-flight state unset while awaiting history. The result sheet permits Close and swipe dismissal during that await. If another contest's send starts before the retry continues, resend() calls private cast() directly, bypassing send()'s global isSendingAny guard; cast() excludes only duplicate labels. Nothing therefore enforces the advertised single-send invariant across this retry boundary, and concurrent casts can race the same voter's identity nonce. The retry also unconditionally republishes its captured report at lines 591–597 even if a newer attempt has cleared or replaced the shared outcome. Reserve a global operation before the first await, retain it through result publication, and associate publication with the owning attempt. Add a suspended-history test that starts a second-contest send before releasing the retry.

source: gpt-6.1-sol (phase2-reviewer: general, security-auditor)

🔴 Blocking: Provide scrolling for per-masternode result reports
DashWallet/Sources/UI/DashPay/Voting/VoteAttempt/VoteResultSheet.swift:42-47

Every outcome is rendered in a VStack alongside the introduction and action buttons, with no scrolling container. The DashUIKit BottomSheet implementation pinned at 4494a8b317af9faf84f40369b9279488b3bc38ce places its content directly in the sheet and does not add scrolling. Node selection has no small count limit, and each status preserves its full vertical size, so sufficiently many outcomes or long errors at large text sizes exceed the available height and leave report content or actions inaccessible. Put the report in a ScrollView, preferably retaining Close and Try again in a fixed footer, and verify a many-node report with long errors and accessibility text sizes.

source: gpt-6.1-sol (phase2-reviewer: general, security-auditor)

🟡 Suggestion: Expose and coordinate gate-loading busy state across entry points
DashWallet/Sources/UI/DashPay/Voting/VoteFlow.swift:161-168

The route guard covers only this modifier's coordinator, while list pills remain enabled until the store actually starts casting. During a queued history read, another tap on the same list is cleared from the request binding and silently discarded by this guard. Navigating to Request details during that interval creates a second coordinator that can start another attempt; if it reaches send while the first cast is active, VotingStore.send() silently returns instead of reporting that the requested vote did not start. Share or reserve attempt ownership across entry points, reflect gate-loading state in the controls, and give a busy result rather than silently consuming another vote request. Presented dialogs already intercept interaction; the uncovered interval is before their presentation.

source: muse-spark-1.3-contributor (phase1-reviewer: general)

💬 Nitpick: Point both state-machine comments to ADR-0035
DashWallet/Sources/UI/DashPay/Voting/VoteAttempt/VoteAttempt.swift:24

This comment and VoteAttemptCoordinator.swift:55 reference docs/features/voting-redesign/adr/0003-run-every-vote-through-a-pure-vote-attempt-state-machine.md, which does not exist. The ADR introduced by this PR is docs/adr/0035-run-every-vote-through-a-pure-vote-attempt-state-machine.md. Update both references so readers can reach the decision governing this flow.

source: muse-spark-1.3-contributor (phase1-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: security-auditor); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, intricate change that directly changes voting key setup, vote authorization, vote-limit enforcement, block-confirmation gating, and vote submission behavior in DashWallet/Sources/UI/DashPay/Voting/VoteAttempt/VoteAttemptCoordinator.swift and related voting flow files.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-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 are optional: fix them forward in a later PR rather than pushing another round just for them.
- Address every current finding in one push: self-review the full diff first, and don't push piecemeal.
- 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 `DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift:86-92: Preserve stored ticks when node resolution temporarily becomes empty
  When an open manage-mode screen observes its node list change from populated to temporarily empty, rowsChanged() intersects its nonempty ticks with an empty set and immediately persists the result through saveTicks(). MasternodeVoterRegistry explicitly returns an empty resolution when the SDK is unavailable or its masternode phase has not synced, and VotingStore.refreshVotableNodes() deliberately avoids settling persisted selections in that state. This new ViewModel bypasses that protection, erasing the user's standing multi-node choice and sending the next vote back through key setup after nodes return. Preserve the selection while node resolution is unavailable and add a manage-mode populated → temporarily empty → populated regression test.

In `DashWallet/Sources/UI/DashPay/Voting/VoteAttempt/VoteAttempt.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/VoteAttempt/VoteAttempt.swift:107-112: Include exhausted masternodes in incomplete vote reporting
  The state machine removes exhausted candidates before returning .send, and no later layer receives those excluded nodes or their reasons. With two ticked masternodes approving a request, one exhausted and one still able to vote, Cancel approval sends abstain only from the latter. VotingStore then sees a completely successful one-node report and displays "Vote cancelled", although the exhausted node still approves the request. The removed cast sheet disclosed exhausted exclusions; the replacement neither warns about them nor includes them in its partial-result report. Continue skipping their broadcasts, but carry excluded candidates into an explicit incomplete outcome or warning, and cover mixed-limit cancellation in an aggregation regression test.
- [NITPICK] DashWallet/Sources/UI/DashPay/Voting/VoteAttempt/VoteAttempt.swift:24: Point both state-machine comments to ADR-0035
  This comment and VoteAttemptCoordinator.swift:55 reference docs/features/voting-redesign/adr/0003-run-every-vote-through-a-pure-vote-attempt-state-machine.md, which does not exist. The ADR introduced by this PR is docs/adr/0035-run-every-vote-through-a-pure-vote-attempt-state-machine.md. Update both references so readers can reach the decision governing this flow.

In `DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:568-576: Reserve the global operation slot before retrying history
  retryFailed() checks only whether its own contest is sending and leaves all store-owned in-flight state unset while awaiting history. The result sheet permits Close and swipe dismissal during that await. If another contest's send starts before the retry continues, resend() calls private cast() directly, bypassing send()'s global isSendingAny guard; cast() excludes only duplicate labels. Nothing therefore enforces the advertised single-send invariant across this retry boundary, and concurrent casts can race the same voter's identity nonce. The retry also unconditionally republishes its captured report at lines 591–597 even if a newer attempt has cleared or replaced the shared outcome. Reserve a global operation before the first await, retain it through result publication, and associate publication with the owning attempt. Add a suspended-history test that starts a second-contest send before releasing the retry.

In `DashWallet/Sources/UI/DashPay/Voting/VoteAttempt/VoteResultSheet.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/VoteAttempt/VoteResultSheet.swift:42-47: Provide scrolling for per-masternode result reports
  Every outcome is rendered in a VStack alongside the introduction and action buttons, with no scrolling container. The DashUIKit BottomSheet implementation pinned at 4494a8b317af9faf84f40369b9279488b3bc38ce places its content directly in the sheet and does not add scrolling. Node selection has no small count limit, and each status preserves its full vertical size, so sufficiently many outcomes or long errors at large text sizes exceed the available height and leave report content or actions inaccessible. Put the report in a ScrollView, preferably retaining Close and Try again in a fixed footer, and verify a many-node report with long errors and accessibility text sizes.

In `DashWallet/Sources/UI/DashPay/Voting/VoteFlow.swift`:
- [SUGGESTION] DashWallet/Sources/UI/DashPay/Voting/VoteFlow.swift:161-168: Expose and coordinate gate-loading busy state across entry points
  The route guard covers only this modifier's coordinator, while list pills remain enabled until the store actually starts casting. During a queued history read, another tap on the same list is cleared from the request binding and silently discarded by this guard. Navigating to Request details during that interval creates a second coordinator that can start another attempt; if it reaches send while the first cast is active, VotingStore.send() silently returns instead of reporting that the requested vote did not start. Share or reserve attempt ownership across entry points, reflect gate-loading state in the controls, and give a busy result rather than silently consuming another vote request. Presented dialogs already intercept interaction; the uncovered interval is before their presentation.

@romchornyi
romchornyi marked this pull request as ready for review November 11, 2026 13:57
@romchornyi
romchornyi force-pushed the feat/voting-vote-from-pills branch from d6caa0e to 2c33d3d Compare November 11, 2026 20:00
@romchornyi

Copy link
Copy Markdown
Contributor Author

Replies to the findings in the review body, all fixed in 2c33d3d (the stack is rebuilt on develop):

  • Ticks persisted empty while the node list is temporarily empty: the stored ticks are kept while the list is empty; a populated → empty → populated test covers it.
  • Exhausted masternodes dropped silently: masternodes skipped for having no vote left are in the report as «No votes left», so a partly blocked vote reads as partial, not full success; covered by a mixed-limit test.
  • retryFailed() reading history outside the send slot, and the per-coordinator busy state: one vote holds the store from its history read to its outcome (VotingStore.isVoteBusy), pills and Approve read it in every entry point, and Try again publishes only while its attempt still owns the outcome; a suspended-history test covers it.
  • Result report not scrollable: the outcomes scroll, with Close / Try again in a fixed footer.
  • Comments citing a private ADR path: they point at docs/adr/0035-…; no other such path is left in Voting/.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The voting flow still permits a cast to outlive its screen: leaving Username Voting while a send is suspended allows reopening the screen with a fresh store and starting a concurrent vote, so the single-send invariant is not app-wide. The route also guards only the coordinator and can admit a new attempt while the store is busy; CI checks were still queued or running in the supplied snapshot, with no failed code checks reported.

🔴 1 blocking

1 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Preserve single-send ownership when leaving and reopening voting
DashWallet/Sources/UI/DashPay/Voting/UsernameVotingScreen.swift:123-125

The Back action remains available while an inline vote task is awaiting the caster. Popping the screen does not cancel that unstructured task, and reopening Username Voting creates a new VotingViewModel and VotingStore whose isVoteBusy starts false. The new screen can therefore admit another vote using the same masternodes while the first send is still in flight; the per-store guard cannot coordinate these two screens, and the first completion updates only the discarded store. Preserve execution admission in an app-owned boundary that survives screen recreation, or prevent navigation until the operation finishes, and cover leaving and reopening while a cast is suspended.

Raised on code unchanged since the last review, and confirmed by an independent pass: With voting already configured, start an inline vote, press Back while the caster awaits its network result, and reopen Username Voting before it completes: the replacement store can admit another send using the same masternode. If the replacement screen loads history before the first vote succeeds, that success refreshes only the old store, leaving the visible pills and my-vote filters incorrectly showing the vote as uncast until an explicit refresh.

source: gpt-6.1-sol (phase2-reviewer: general)

Follow-up candidates (optional) (1)

New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.

🟡 Suggestion: Guard vote entry on the store busy slot, not only the coordinator
DashWallet/Sources/UI/DashPay/Voting/VoteFlow.swift:162-163

route(_:) rejects a request only when this coordinator is running. The coordinator clears its running state before awaiting host.send, while the store can still have the send in progress; a second request can therefore start another coordinator attempt, clear the current attempt label and outcome, and proceed until VotingStore.send rejects it. The pills and Approve control already consult isVoteBusy, but the route is the final admission point and should enforce the same invariant rather than relying on UI disabled state.

guard !attempt.isRunning, !viewModel.store.isVoteBusy else { return }

source: muse-spark-1.3-contributor (phase1-reviewer: general)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a large, cross-cutting voting UI and state-management change, but it does not itself modify funds movement, cryptography, key handling, consensus, network deserialization, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Code unchanged since the last final review (d6caa0e1): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed; 1 new suggestion(s) listed as follow-up candidates, not posted inline
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-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 `DashWallet/Sources/UI/DashPay/Voting/UsernameVotingScreen.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/UsernameVotingScreen.swift:123-125: Preserve single-send ownership when leaving and reopening voting
  The Back action remains available while an inline vote task is awaiting the caster. Popping the screen does not cancel that unstructured task, and reopening Username Voting creates a new `VotingViewModel` and `VotingStore` whose `isVoteBusy` starts false. The new screen can therefore admit another vote using the same masternodes while the first send is still in flight; the per-store guard cannot coordinate these two screens, and the first completion updates only the discarded store. Preserve execution admission in an app-owned boundary that survives screen recreation, or prevent navigation until the operation finishes, and cover leaving and reopening while a cast is suspended.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: With voting already configured, start an inline vote, press Back while the caster awaits its network result, and reopen Username Voting before it completes: the replacement store can admit another send using the same masternode. If the replacement screen loads history before the first vote succeeds, that success refreshes only the old store, leaving the visible pills and my-vote filters incorrectly showing the vote as uncast until an explicit refresh._

@romchornyi
romchornyi force-pushed the feat/voting-vote-from-pills branch from 2c33d3d to 21817a7 Compare November 11, 2026 21:59
@romchornyi

Copy link
Copy Markdown
Contributor Author

Fixed in 21817a7:

  • Single-send ownership when leaving and reopening: while a vote holds the store's slot, the bar's back button is disabled and the menu's host turns off the swipe-back, so the screen cannot be left and reopened mid-vote. In feat(voting): request dates, the links filter and Quick voting #1366, Back stays available during a Quick voting run because leaving stops the run (ADR-0037); it is held only for a single vote.
  • Follow-up suggestion: route(_:) also returns while store.isVoteBusy.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Static review of the exact head found two blocking issues: the production voting host is compiled only in DEBUG, and leaving Request details during a vote can discard the only owner of a mixed-result sheet. Two additional busy-state and stale-selection issues remain in the voting-key flow. The simulator test check is still queued; accessibility and test-target checks passed, but no local build or tests were run in this review lane.

🔴 2 blocking | 🟡 1 suggestion(s)

3 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Move the production voting host outside the DEBUG preview block
DashWallet/Sources/UI/DashPay/Voting/UsernameVotingScreen.swift:561-564

UsernameVotingHostingController is declared inside the #if DEBUG block that starts at line 482 and ends at line 680. MainMenuViewController.showVoting() instantiates this type whenever DASHPAY is enabled, while the Release and TestFlight configurations define DASHPAY without DEBUG. Those configurations therefore exclude the declaration but still compile the caller, producing an unresolved UsernameVotingHostingController error. Move the production hosting controller outside the preview-only conditional and leave only preview fixtures/helpers inside #if DEBUG.

source: gpt-6.1-sol (phase2-reviewer: general)

🔴 Blocking: Request details can be left mid-vote, stranding the mixed-result sheet
DashWallet/Sources/UI/DashPay/Voting/Details/RequestDetailsScreen.swift:104-105

The list holds its custom back button and the outer UIKit swipe-back while store.isVoteBusy is true, but Request details' back button is always active and its internal NavigationStack can still be popped interactively. A vote started from details is owned by the details-attached VoteFlowModifier; its showsResult state is local to that modifier, while the list modifier does not observe store.outcome. If the details screen is popped during a partial send, the details modifier is removed before it can present VoteResultSheet, leaving the .mixed outcome without the required Close/Try again UI. Hold navigation for the entire vote, including the internal pop gesture, or move result presentation to an owner that survives leaving details.

Raised on code unchanged since the last review, and confirmed by an independent pass: Start a vote from Request details, let it reach the send phase, then tap the always-enabled back button while the cast is in flight. If the caster returns a mixed result after the detail destination is popped, the details-owned VoteFlowModifier is gone before it can present VoteResultSheet, while the list's modifier never sets its own result state; the failed masternode results and Try again action are therefore inaccessible.

source: muse-spark-1.3-contributor (phase1-reviewer: general)

🟡 Suggestion: Voting-keys entry points stay enabled while a vote holds the slot
DashWallet/Sources/UI/DashPay/Voting/UsernameVotingScreen.swift:202-210

The ellipsis menu's Voting keys action and the Voting with row remain enabled while store.isVoteBusy is true. Opening manage mode during the vote's history-read window allows VotingKeysViewModel.toggle to persist a different tick selection immediately. VoteAttemptCoordinator.runGates snapshots host.tickedNodeIDs only after the awaited history read, so the in-flight attempt can use a selection changed through this unrelated flow. Disable both entry points while the shared vote slot is busy, matching the existing back-button hold.

source: muse-spark-1.3-contributor (phase1-reviewer: general)

Follow-up candidates (optional) (1)

New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.

🟡 Suggestion: Vote button stays enabled on stale ticks when rows are empty
DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift:115-116

rowsChanged() correctly preserves ticks while the resolved node list is empty, but canConfirm still checks only !ticked.isEmpty. If the node list becomes empty after initialization, stale ticks keep Block or Approve enabled even though no visible row can be selected. Confirming then persists a selection that cannot be resolved by the current node list and sends the attempt back through the keys gate instead of preventing the invalid action. Require at least one visible row before enabling confirmation.

var canConfirm: Bool { !ticked.isEmpty && !rows.isEmpty }

source: muse-spark-1.3-contributor (phase1-reviewer: general)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The intricate voting state machine, setup flow, retries, and UI changes warrant substantial review, but the diff does not materially change cryptography, key storage or validation, funds movement, consensus rules, or another qualifying critical surface.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Code unchanged since the last final review (2c33d3d8): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed; 1 new suggestion(s) listed as follow-up candidates, not posted inline
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-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 `DashWallet/Sources/UI/DashPay/Voting/UsernameVotingScreen.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/UsernameVotingScreen.swift:561-564: Move the production voting host outside the DEBUG preview block
  `UsernameVotingHostingController` is declared inside the `#if DEBUG` block that starts at line 482 and ends at line 680. `MainMenuViewController.showVoting()` instantiates this type whenever `DASHPAY` is enabled, while the Release and TestFlight configurations define `DASHPAY` without `DEBUG`. Those configurations therefore exclude the declaration but still compile the caller, producing an unresolved `UsernameVotingHostingController` error. Move the production hosting controller outside the preview-only conditional and leave only preview fixtures/helpers inside `#if DEBUG`.
- [SUGGESTION] DashWallet/Sources/UI/DashPay/Voting/UsernameVotingScreen.swift:202-210: Voting-keys entry points stay enabled while a vote holds the slot
  The ellipsis menu's Voting keys action and the Voting with row remain enabled while `store.isVoteBusy` is true. Opening manage mode during the vote's history-read window allows `VotingKeysViewModel.toggle` to persist a different tick selection immediately. `VoteAttemptCoordinator.runGates` snapshots `host.tickedNodeIDs` only after the awaited history read, so the in-flight attempt can use a selection changed through this unrelated flow. Disable both entry points while the shared vote slot is busy, matching the existing back-button hold.

In `DashWallet/Sources/UI/DashPay/Voting/Details/RequestDetailsScreen.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Details/RequestDetailsScreen.swift:104-105: Request details can be left mid-vote, stranding the mixed-result sheet
  The list holds its custom back button and the outer UIKit swipe-back while `store.isVoteBusy` is true, but Request details' back button is always active and its internal `NavigationStack` can still be popped interactively. A vote started from details is owned by the details-attached `VoteFlowModifier`; its `showsResult` state is local to that modifier, while the list modifier does not observe `store.outcome`. If the details screen is popped during a partial send, the details modifier is removed before it can present `VoteResultSheet`, leaving the `.mixed` outcome without the required Close/Try again UI. Hold navigation for the entire vote, including the internal pop gesture, or move result presentation to an owner that survives leaving details.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: Start a vote from Request details, let it reach the send phase, then tap the always-enabled back button while the cast is in flight. If the caster returns a mixed result after the detail destination is popped, the details-owned VoteFlowModifier is gone before it can present VoteResultSheet, while the list's modifier never sets its own result state; the failed masternode results and Try again action are therefore inaccessible._

@romchornyi
romchornyi force-pushed the feat/voting-vote-from-pills branch from 21817a7 to 426e483 Compare November 11, 2026 23:57
@romchornyi

Copy link
Copy Markdown
Contributor Author

Fixed in 426e483:

  • UsernameVotingHostingController is now outside the #if DEBUG preview block; every stage of the stack was built in Release.
  • Request details holds Back and the swipe-back while a vote is busy, so a vote started there keeps its result sheet.
  • The Voting keys menu item and the Voting with row are disabled while the vote slot is held (suggestion).

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The exact-head static review confirms two in-scope blocking voting correctness issues: incomplete masternode resolution can permanently discard selected nodes, and retrying a cancelled vote loses the original cancellation intent. One documentation mismatch remains around intentionally empty post-setup selections; the simulator test check is still in progress, while the other reported policy and membership checks passed.

A pattern across this PR's review rounds

This is review round 4, and the PR has drawn 8 blocking findings so far. 5 of them share 2 underlying causes. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.

1. Observed nodes are treated as the saved choice (1 new in this round, 1 earlier finding(s))

VotingStore.refreshVotableNodes() and VotingKeysViewModel.rowsChanged() independently intersect remembered ticks with the currently visible nodes and persist the result, although visibility does not establish that missing nodes were removed. The earlier fix protects an empty observation, but the same loss now occurs with a nonempty incomplete observation: VotingStore has the completeness flag but does not use it for settlement, and VotingKeysSource does not expose it at all. Without one reconciliation rule that distinguishes incomplete observations from confirmed removals, each observation shape needs another preservation patch.

In this round: Do not persist selection from an incomplete masternode resolution

2. No owner spans the whole vote attempt (4 earlier finding(s))

VoteAttemptCoordinator owns the gates, VotingStore owns history-read and send flags, and each VoteFlowModifier owns result presentation; the store itself is recreated when voting is reopened. The retry overlap, reopening during a send, and losing the details result sheet all follow from ownership covering only part of the operation or one screen's lifetime. Extending the busy flags and then preventing navigation addresses these boundaries separately, so the list fix leaves another boundary to handle in Request details.

Suggested decision (redesign the component): Consolidate saved voting-selection reconciliation in VotingStore before adding another rowsChanged() guard. Give that boundary an explicit unavailable/partial/complete resolution contract, separate remembered user intent from currently usable nodes, and make it the sole authority for automatic selection persistence. The key screen should submit explicit tick changes rather than independently deciding that an absent row means a saved node must be forgotten. This keeps the current PR's standing-selection promise without reopening the already-fixed navigation defects or requiring the SDK to discover every node first.

If a later review again finds new blockers from these causes, it will ask for that decision and pause automatic re-review until it is made.

🔴 1 blocking

1 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Do not persist selection from an incomplete masternode resolution
DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:392-412

resolution.mayBeIncomplete explicitly means that the returned node list is not exhaustive, but this code still intersects and persists selectedNodeIDs whenever the partial list is non-empty. If the stored selection contains A and B while a shallow resolution returns only A, selectedNodeIDs is changed to only A and UserDefaults is overwritten; a later complete resolution cannot restore B, so the next vote silently uses fewer masternodes than the user's saved choice. The same behavior exists in VotingKeysViewModel.rowsChanged() at lines 88-95: a partial non-empty rows list is used to drop ticks and, in manage mode, save them. Defer settlement and persistence whenever the resolution may be incomplete, and propagate that completeness state to the keys view model.

Raised on code unchanged since the last review, and confirmed by an independent pass: After voting setup saves imported node A and wallet-derived node B, a refresh with an unavailable provider voting pool can return only A with mayBeIncomplete=true. refreshVotableNodes permanently saves only A; even after B resolves again, the new direct-pill voting flow sends only A's vote without reconfirming the reduced selection.

source: gpt-6.1-sol (phase2-reviewer: general)

Follow-up candidates (optional) (1)

New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.

🟡 Suggestion: Preserve cancellation intent when retrying a mixed result
DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:611-628

A cancellation begins as VoteAttempt.Intent.cancel(heldChoice), so the initial attempt only sends abstain from ticked masternodes that currently hold the choice being cancelled. The resulting VoteCastReport retains only .abstain, and this retry reconstructs the attempt as .vote(report.choice). Its candidate calculation therefore treats every failed node that does not currently hold abstain as sendable. If a failed node's vote changes externally between the partial result and Try again, the retry can overwrite that unrelated choice with abstain. Retain the original cancellation intent and held choice with the attempt/report or store state, and use it when rebuilding the retry gates.

source: gpt-6.1-sol (phase2-reviewer: general)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The intricate voting state machine, store serialization, retry logic and SwiftUI changes do not change consensus, funds movement, signing implementations or substantive key handling; VotingKeyInputViewModel primarily changes validation messaging.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Code unchanged since the last final review (21817a7f): 2 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed, 1 not confirmed (now follow-up candidates); 1 new nitpick(s) dropped
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
Several findings on this PR share an underlying cause (the review's "pattern" section): Observed nodes are treated as the saved choice; No owner spans the whole vote attempt. When you fix the findings below, fix the cause, not only the reported case. The review suggests (redesign the component): Consolidate saved voting-selection reconciliation in VotingStore before adding another rowsChanged() guard. Give that boundary an explicit unavailable/partial/complete resolution contract, separate remembered user intent from currently usable nodes, and make it the sole authority for automatic selection persistence. The key screen should submit explicit tick changes rather than independently deciding that an absent row means a saved node must be forgotten. This keeps the current PR's standing-selection promise without reopening the already-fixed navigation defects or requiring the SDK to discover every node first. If that decision is not yours to make, say so to the PR's author or maintainer.

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 `DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:392-412: Do not persist selection from an incomplete masternode resolution
  `resolution.mayBeIncomplete` explicitly means that the returned node list is not exhaustive, but this code still intersects and persists `selectedNodeIDs` whenever the partial list is non-empty. If the stored selection contains A and B while a shallow resolution returns only A, `selectedNodeIDs` is changed to only A and UserDefaults is overwritten; a later complete resolution cannot restore B, so the next vote silently uses fewer masternodes than the user's saved choice. The same behavior exists in `VotingKeysViewModel.rowsChanged()` at lines 88-95: a partial non-empty `rows` list is used to drop ticks and, in manage mode, save them. Defer settlement and persistence whenever the resolution may be incomplete, and propagate that completeness state to the keys view model.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: After voting setup saves imported node A and wallet-derived node B, a refresh with an unavailable provider voting pool can return only A with mayBeIncomplete=true. refreshVotableNodes permanently saves only A; even after B resolves again, the new direct-pill voting flow sends only A's vote without reconfirming the reduced selection._

@romchornyi
romchornyi force-pushed the feat/voting-vote-from-pills branch from 426e483 to acf7a07 Compare November 12, 2026 10:20
@romchornyi

Copy link
Copy Markdown
Contributor Author

Fixed in acf7a07, following the suggested decision: VotingStore is now the only writer of the remembered node choice (selectedNodeIDs is private(set)) and exposes the resolution as unavailable, partial or complete. Only a complete resolution forgets a remembered node that is no longer votable; a partial one leaves the choice as the user made it, and a vote uses the remembered nodes that resolved. The keys screen sends single tick changes (setTick) instead of saving the ticks it shows, and removing a voting key forgets that node explicitly (forgetNode). Tests cover A,B → partial A → A,B in the store and on the keys screen.

@romchornyi
romchornyi force-pushed the feat/voting-vote-from-pills branch from acf7a07 to e147270 Compare November 12, 2026 10:59
@romchornyi

Copy link
Copy Markdown
Contributor Author

Recorded the decision as ADR-0038 in e147270 (docs/adr/0038-let-only-the-voting-store-write-the-remembered-node-choice.md, Proposed until a reviewer approves): the store is the only writer of the remembered node choice, and only a complete node resolution forgets a remembered node.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

At e147270, two key-selection defects remain: removing the selected imported key can silently select a replacement, and partial resolution can discard unconfirmed vote-mode ticks. All 11 prior findings are fixed. This verification was static; current PR checks contain no build or unit-test result for this head, and live validation remains outstanding.

🔴 2 blocking

2 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Do not automatically select another node when removing the selected key
DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift:102-104

In manage mode, this fallback persists a replacement even when the standing selection is explicitly empty. Start with voting set up, derived node A unticked, and imported node B ticked, then remove B. removeImportedVotingKey forgets B and refreshes the rows; rowsChanged() receives an empty source.tickedNodeIDs and one remaining row, then calls setTick(A, true). The next pill tap can therefore vote with A without reopening Add your voting keys, although the user never selected A. VotingStore.tickedNodeIDs deliberately distinguishes an explicitly empty selection from nil; preserve that distinction here and do not turn an observation-driven row refresh into an explicit replacement tick. Add a regression covering removal of the sole selected imported node while an unticked derived node remains.

source: gpt-6.1-sol (phase2-reviewer: general)

🔴 Blocking: Preserve unconfirmed vote-mode ticks across partial node resolution
DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift:101-107

The vote-mode branch permanently intersects the draft selection with each nonempty observation, including partial observations. With no remembered selection and rows A and B, A is initially ticked; tick B, then let a key-import refresh resolve only A with mayBeIncomplete set. This handler removes B from ticked. Confirming now passes only A to confirmVotingSetup, whose unseen-node preservation cannot recover B because that draft tick was never persisted. B remains unticked when resolution recovers, without the user unticking it. The existing A,B → partial A → A,B screen regression covers manage mode, not this draft path. Preserve the desired draft independently of resolved rows, derive visible counts and senders from its intersection with those rows, and retain unresolved draft choices when confirming a partial resolution.

source: gpt-6.1-sol (phase2-reviewer: general)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The change is intricate and cross-cutting, but VotingStore and VoteAttempt primarily change vote orchestration, confirmations, and selection state rather than cryptography, signing, private-key storage, or other qualifying critical surfaces.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-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 `DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift:102-104: Do not automatically select another node when removing the selected key
  In manage mode, this fallback persists a replacement even when the standing selection is explicitly empty. Start with voting set up, derived node A unticked, and imported node B ticked, then remove B. `removeImportedVotingKey` forgets B and refreshes the rows; `rowsChanged()` receives an empty `source.tickedNodeIDs` and one remaining row, then calls `setTick(A, true)`. The next pill tap can therefore vote with A without reopening Add your voting keys, although the user never selected A. `VotingStore.tickedNodeIDs` deliberately distinguishes an explicitly empty selection from `nil`; preserve that distinction here and do not turn an observation-driven row refresh into an explicit replacement tick. Add a regression covering removal of the sole selected imported node while an unticked derived node remains.
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift:101-107: Preserve unconfirmed vote-mode ticks across partial node resolution
  The vote-mode branch permanently intersects the draft selection with each nonempty observation, including partial observations. With no remembered selection and rows A and B, A is initially ticked; tick B, then let a key-import refresh resolve only A with `mayBeIncomplete` set. This handler removes B from `ticked`. Confirming now passes only A to `confirmVotingSetup`, whose unseen-node preservation cannot recover B because that draft tick was never persisted. B remains unticked when resolution recovers, without the user unticking it. The existing A,B → partial A → A,B screen regression covers manage mode, not this draft path. Preserve the desired draft independently of resolved rows, derive visible counts and senders from its intersection with those rows, and retain unresolved draft choices when confirming a partial resolution.

@romchornyi
romchornyi force-pushed the feat/voting-vote-from-pills branch from e147270 to f2e8c63 Compare November 12, 2026 15:27
@romchornyi

Copy link
Copy Markdown
Contributor Author

Both blocking findings of the review at e147270 are fixed in f2e8c63, with regression tests:

  • Removing the selected key no longer ticks another node: an explicit empty choice stays empty, and the only row is ticked only when nothing was ever chosen.
  • In vote mode, a tick on a node a partial node list hides is kept and confirmed with the rest; a complete list drops it.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Preliminary review — Phase 1 blocker gate

The current head fixes the previously reported voting-flow issues, but three blocking state-consistency bugs remain in the voting-keys screen. The vote caption can under-report the nodes that confirmation will persist, a completed resolution can auto-select a node despite an earlier choice, and hidden ticks can survive a resolution change that does not alter the row hashes. The only code check is still in progress; no failed code check is reported.

Validated blockers were found by the Phase-1 review and confirmed by a fresh verifier. Phase 2 is deferred until a fresh same-head revalidation clears the blocker gate.

🔴 3 blocking

3 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Vote-mode caption omits hidden ticks while confirm casts them
DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift:129-135

In vote mode, confirm() persists ticked.union(hiddenTicks), but castCaption counts only ticked. When a partial node resolution hides a previously selected node, the UI can say “1 vote will be cast” while confirmation persists two node IDs. The user therefore approves a count that does not match the vote setup that will be used.

    var castCaption: String? {
        guard case .vote = mode else { return nil }
        let total = ticked.union(hiddenTicks).count
        guard total > 0 else { return nil }
        return total == 1
            ? NSLocalizedString("1 vote will be cast", comment: "Voting")
            : String(format: NSLocalizedString("%d votes will be cast", comment: "Voting"), total)
    }

source: muse-spark-1.3-contributor (phase1-reviewer: general)

🔴 Blocking: Vote-mode auto-ticks the only row even when a choice existed
DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift:113-120

nothingChosen is derived from hiddenTicks.isEmpty, rather than from the complete draft selection. After a previously selected node disappears and the resolution becomes complete, hiddenTicks is cleared even though draft was non-empty. With one different live row, the fallback at lines 118–120 then ticks that row and confirmation casts a node the user never selected.

            let draft = ticked.union(hiddenTicks)
            hiddenTicks = source.nodeResolution == .complete ? [] : draft.subtracting(live)
            next = draft.intersection(live)
            nothingChosen = draft.isEmpty

source: muse-spark-1.3-contributor (phase1-reviewer: general)

🔴 Blocking: Stale hidden ticks persist when resolution turns complete without row change
DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift:104-116

The screen invokes rowsChanged() only when votableNodes.map(\.proTxHash) changes. If the node resolution changes from partial to complete while the visible hashes remain identical, hiddenTicks is not cleared. confirm() then unions that stale hidden ID into the persisted setup, allowing a node that is no longer votable to be reintroduced later. Completion must either trigger the same reconciliation or filter hidden ticks at confirmation time.

    func confirm() {
        guard canConfirm else { return }
        let kept = source.nodeResolution == .complete ? ticked : ticked.union(hiddenTicks)
        source.confirmVotingSetup(ticked: kept)
    }

source: muse-spark-1.3-contributor (phase1-reviewer: general)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.1-sol (agent: sol-gate-verifier, role: verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The change is intricate and cross-cutting, but VotingStore and VoteAttempt primarily change vote orchestration and UI gates, while key import and signing implementations remain substantially unchanged.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.1-sol — verifier; agent sol-gate-verifier
  • Phase 2 reviewers: not run (deferred by blocker gate)
🤖 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 `DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift:129-135: Vote-mode caption omits hidden ticks while confirm casts them
  In vote mode, `confirm()` persists `ticked.union(hiddenTicks)`, but `castCaption` counts only `ticked`. When a partial node resolution hides a previously selected node, the UI can say “1 vote will be cast” while confirmation persists two node IDs. The user therefore approves a count that does not match the vote setup that will be used.
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift:113-120: Vote-mode auto-ticks the only row even when a choice existed
  `nothingChosen` is derived from `hiddenTicks.isEmpty`, rather than from the complete draft selection. After a previously selected node disappears and the resolution becomes complete, `hiddenTicks` is cleared even though `draft` was non-empty. With one different live row, the fallback at lines 118–120 then ticks that row and confirmation casts a node the user never selected.
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift:104-116: Stale hidden ticks persist when resolution turns complete without row change
  The screen invokes `rowsChanged()` only when `votableNodes.map(\.proTxHash)` changes. If the node resolution changes from partial to complete while the visible hashes remain identical, `hiddenTicks` is not cleared. `confirm()` then unions that stale hidden ID into the persisted setup, allowing a node that is no longer votable to be reintroduced later. Completion must either trigger the same reconciliation or filter hidden ticks at confirmation time.

@romchornyi-pitcrew romchornyi-pitcrew left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of f2e8c63 — vote from the pills, the vote gates, Add your voting keys

Verdict: no blockers or majors of my own. Ready once the open PastaClaw round is answered (one finding declined with the reason below, two small fixes) and the test notes are refreshed.

What I checked

  • The 19k deleted lines: 16,990 of them are the 76 voting strings and 10 plural entries no code uses any more, removed from all 43 locales (en and uk catalogs carry identical key sets afterwards); the rest are the removed CastVoteSheet, ContestDetailScreen, VotingNodeSelectionSheet and the old keys screens. I grepped every removed key against Swift, Objective-C, storyboards and xibs at this head: none is still used (the four that show up are a stringsdict key still present, test-only plural checks against it, and one doc comment). They belong here, as the screens that used them are removed here.
  • Every NSLocalizedString in the voting code resolves in en.lproj, except one that predates this PR (see Notes).
  • VoteAttempt gate order matches the description and ADR-0035: ended → not set up → history unknown → nothing to send → no votes left → One vote left → lock-is-final; the cancel intent sends abstain and skips the block confirmation. The coordinator's token guard drops a gate run that resumes after a dismiss, and send runs after end(), with the store's isVoteBusy guarding a second send.
  • Try again re-runs the gates on a fresh history read, keeps landed nodes in the report, and only replaces the outcome if no newer attempt did.
  • Logging: every new line goes through DWLogger; nodes are logged as kind, weight and short pro_tx_hash, errors only as their type. No key, WIF, or Platform error text reaches a log. The os.Logger in MasternodeVoteCaster is gone.
  • A wallet wipe now also forgets the node choice and "voting set up" (App.swift).
  • No dangling references to the removed view-model API (effectiveSelectedNodeIDs, castCandidates, lastCastReport, …).
  • QA: three flows tagged pr-1347 (pill before setup, manage voting keys, key validation), none draft. The send itself needs a masternode, so it stays with the planned testnet run.

The open PastaClaw blockers at this head

  1. "Vote-mode caption omits hidden ticks while confirm casts them" (VotingKeysViewModel.swift L129-L135) — not valid as stated. hiddenTicks is by construction the draft minus the shown rows, i.e. nodes not in votableNodes. confirm() persists them, but the vote that follows takes VotingStore.tickedNodeIDs, which is the selection ∩ votableNodeIDs (VotingStore.swift L262-L267). A hidden node casts nothing, so the caption counts what is cast. Worth declining on the thread with that reason.
  2. "Vote-mode auto-ticks the only row even when a choice existed" (L113-L120) — real, but minor. With a complete resolution hiddenTicks is cleared before nothingChosen reads it, so a user whose ticked node is proved gone gets the one remaining row pre-ticked. The tick is visible and nothing is sent until they tap Block / Approve, and a single node links nothing — but it contradicts the method's own contract ("tick the only row when nothing was chosen") and manage mode, where an explicit choice that emptied stays empty. nothingChosen = draft.isEmpty fixes it.
  3. "Stale hidden ticks persist when resolution turns complete without row change" (L104-L116, VotingKeysScreen.swift L166) — real, but minor. The id is persisted, never cast (same reason as 1), and the next complete refresh settles it away (VotingStore.swift L444-L450). Since ADR-0038 makes the store the only writer, the narrowest fix is there rather than in the view model: in confirmVotingSetup (L234-L239) keep ticked.intersection(votableNodeIDs) when the resolution is complete, as unseen already does for the remembered side.

Recommendations

  • Log why a key was refused. "Enter voting key" now shows one message for every bad shape (VotingKeyInputViewModel.swift L96-L101), as AC-13 asks, so a support report can no longer tell a testnet key from an address. One DWLogger.log("Voting: key refused: \(problem)") with the VotingKeyProblem case (never the text) keeps that; it is also the only use left for the case distinctions.
  • "You can cancel your vote until voting ends" in the block confirmation is not true for a masternode on its fifth vote: cancelling is an abstain, which is a vote. Either qualify it or rely on "One vote left" coming first (it does, so the copy is only wrong in the last-vote case).
  • The caption counts ticked nodes, not the votes the gates will send. Nodes that already hold the choice or have no vote left are dropped after the button, so "2 votes will be cast" can send one. Fine if the design says so; otherwise word it as nodes.
  • PR description: the test run is dated 2026-11-10, before the later fix rounds (the gate comment's blockers and ADR-0038 landed after it), and ADR-0038 is in the diff but not in the checklist line. A fresh run on this head and the ADR line would make it match.

Notes (outside this diff)

  • "Review the posting below to verify the ownership of this username" (RequestDetailsScreen.swift L120-L122) has no entry in any Localizable.strings; it came in with the stage 3 PR.
  • This PR also carries review fixes for stages 1–3, so those PRs are only complete together with this one; merge the stack in order.

🤖 Reviewed with Claude Code

romchornyi added a commit that referenced this pull request Nov 13, 2026
A confirmation past the voting end sends nothing; a hidden remembered choice keeps the only row unticked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SDD-Published-From: 783eeecf1820d5c7652359f3eabcfaf148a55fc3
@romchornyi

Copy link
Copy Markdown
Contributor Author

Review at ea1a555:

  • Missing import Combine in VotingKeysViewModel and VoteAttemptCoordinator: not changing this. The target compiles. DashWalletTests on simulator passed at ea1a555, and the Release build succeeds. Foundation makes ObservableObject and @Published available on Apple platforms, and 59 other files in DashWallet/Sources rely on the same thing.
  • A confirmation held past the voting end (fixed in 1db357e): confirming «One vote left» or the block dialog now rechecks the time and whether Platform closed the contest. An ended contest is reported as ended, and nothing is sent. Tests cover the deadline and the Platform close.
  • The only row ticked while the remembered choice is hidden (fixed in 1db357e): a node the remembered choice holds but an incomplete list does not show now counts as a choice. In vote mode, the only row is no longer ticked for the user, so the vote button cannot add it next to the hidden node. Test added.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The exact-head voting flow is largely coherent and the cumulative selection, lifecycle, reporting, and confirmation fixes are present. Two issues remain: the coordinator reads vote history before evaluating the documented ended/setup gates, which can block first-time setup and delay ended-contest feedback, and vote-mode initialization can auto-tick a visible row beside a hidden remembered choice.

🔴 1 blocking | 🟡 1 suggestion(s)

2 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Evaluate ended and setup gates before awaiting vote history
DashWallet/Sources/UI/DashPay/Voting/VoteAttempt/VoteAttemptCoordinator.swift:154-164

runGates unconditionally awaits host.voteHistory(for:) before constructing VoteAttempt, even though VoteAttempt.step defines the gate order as contest ended, voting setup, then history availability. On the first vote from a wallet that has not completed setup, an unreadable or suspended history read reports history unavailable instead of presenting Add your voting keys. An already-ended contest likewise waits for the history read before reporting that voting has ended. The coordinator should evaluate the cheap ended and setup gates first, then read history only when those gates pass; after the keys flow, it should re-read history as it already does on restart.

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general)

🟡 Suggestion: Vote-mode init still auto-ticks the only row while a choice existed only in a hidden node
DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift:74-78

Initialization falls back to the first visible node whenever source.tickedNodeIDs is nil, without checking source.remembersHiddenNodes. VotingStore.tickedNodeIDs is nil before setup when the remembered selection contains only a node absent from the currently visible, incomplete resolution. In that state, opening vote mode auto-ticks the first visible row, while rowsChanged() correctly treats the hidden remembered node as an existing choice and does not select another row. The visible tick can cause the user to confirm a privacy-linking choice they did not make, even though no vote is sent until confirmation.

let fallback: Set<Data>
if case .vote = mode, source.remembersHiddenNodes {
    fallback = []
} else {
    fallback = Set(source.votableNodes.first.map { [$0.proTxHash] } ?? [])
}
ticked = source.tickedNodeIDs ?? fallback

source: muse-spark-1.3-contributor (phase1-reviewer: general)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This large, intricate diff changes masternode voting behavior and key-handling flows in MasternodeVoteCaster.swift, MasternodeVoterRegistry.swift, and the voting key screens, including vote signing/submission and selection of voting keys.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-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 `DashWallet/Sources/UI/DashPay/Voting/VoteAttempt/VoteAttemptCoordinator.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/VoteAttempt/VoteAttemptCoordinator.swift:154-164: Evaluate ended and setup gates before awaiting vote history
  `runGates` unconditionally awaits `host.voteHistory(for:)` before constructing `VoteAttempt`, even though `VoteAttempt.step` defines the gate order as contest ended, voting setup, then history availability. On the first vote from a wallet that has not completed setup, an unreadable or suspended history read reports history unavailable instead of presenting Add your voting keys. An already-ended contest likewise waits for the history read before reporting that voting has ended. The coordinator should evaluate the cheap ended and setup gates first, then read history only when those gates pass; after the keys flow, it should re-read history as it already does on restart.

In `DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift`:
- [SUGGESTION] DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift:74-78: Vote-mode init still auto-ticks the only row while a choice existed only in a hidden node
  Initialization falls back to the first visible node whenever `source.tickedNodeIDs` is `nil`, without checking `source.remembersHiddenNodes`. `VotingStore.tickedNodeIDs` is nil before setup when the remembered selection contains only a node absent from the currently visible, incomplete resolution. In that state, opening vote mode auto-ticks the first visible row, while `rowsChanged()` correctly treats the hidden remembered node as an existing choice and does not select another row. The visible tick can cause the user to confirm a privacy-linking choice they did not make, even though no vote is sent until confirmation.

… a hidden node is remembered

Before setup the store has no choice to show when the remembered node is
one an incomplete node list hides; vote mode no longer falls back to the
first row then.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SDD-Published-From: 2a63077fe6377526ea5c82e14bc6dc9cf65ebe09
@romchornyi

Copy link
Copy Markdown
Contributor Author

Re: the latest review (1 blocking, 1 suggestion; no inline threads, the diff was too large):

  • Suggestion — vote-mode init ticks a row beside a hidden remembered choice: fixed in 0f5e568. Vote mode now starts with no row ticked while remembersHiddenNodes holds, as rowsChanged() already did; with a test.
  • Blocking — ended and setup gates wait for the history read: deferred, tracked in Voting: report an ended contest before reading the vote history #1403. The ended half is a delay only, and the outcome is still right. The setup half does not happen: VoteAttempt.step checks voting setup before the history (guard isVotingSetUp, !tickedNodes.isEmpty else { return .needsKeys } comes before historyUnavailable), so a wallet that is not set up gets "Add your voting keys" even when the history cannot be read.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The reviewed head has a blocking compile defect: VotingToast.Style lacks Equatable while VotingToast synthesizes Equatable and RequestDetailsViewModel compares styles directly. The pre-setup key-removal path also still conflates an explicitly emptied selection with an unchosen selection and can auto-select the remaining node; the simulator test check remains queued, while completed target-membership, accessibility, workflow, title, and CodeRabbit checks passed.

🔴 3 blocking

3 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Make VotingToast.Style Equatable
DashWallet/Sources/UI/DashPay/Voting/List/VotingListViewModel.swift:497-500

VotingToast declares Equatable, so synthesized equality requires every stored property, including style, to conform to Equatable. RequestDetailsViewModel also evaluates toast.style == .error; the voting target cannot compile until the nested enum conforms.

Raised on code unchanged since the last review, and confirmed by an independent pass: The voting target fails to compile: synthesized Equatable conformance for VotingToast cannot be generated because its stored style property has type Style, which does not conform to Equatable; RequestDetailsViewModel's toast.style == .error and the style equality tests also require that conformance.

enum Style: Equatable {
        case success
        case error
    }

source: gpt-6.1-sol (phase2-reviewer: general)

🔴 Blocking: Do not automatically select another node when removing the selected key
DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift:132-145

Removing an imported key calls store.forgetNode, which removes that node from selectedNodeIDs. Before voting setup, VotingStore.tickedNodeIDs returns nil when the remaining live selection is empty, so rowsChanged() treats the result as 'nothing was ever chosen' and auto-ticks the sole remaining row. Removing the only selected node from a pre-setup A/B list can therefore silently select B, contrary to the explicit removal action.

source: gpt-6.1-sol (phase2-reviewer: ffi-engineer)

🔴 Blocking: Do not automatically select another node when removing the selected key
DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:271-275

The tickedNodeIDs accessor returns nil for an empty live selection while voting is not set up. That sentinel is consumed by VotingKeysViewModel.rowsChanged() as an unchosen state, which triggers the single-row fallback after forgetNode empties the selection. The store must preserve the distinction between 'no choice has ever been made' and 'the user explicitly removed the last choice'.

source: gpt-6.1-sol (phase2-reviewer: ffi-engineer)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The large, intricate change modifies voting key setup and masternode vote casting in MasternodeVoteCaster.swift and MasternodeVoterRegistry.swift, including key-handling and signed peer-facing vote behavior.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Code unchanged since the last final review (1db357e9): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-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 `DashWallet/Sources/UI/DashPay/Voting/List/VotingListViewModel.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/List/VotingListViewModel.swift:497-500: Make VotingToast.Style Equatable
  `VotingToast` declares `Equatable`, so synthesized equality requires every stored property, including `style`, to conform to `Equatable`. `RequestDetailsViewModel` also evaluates `toast.style == .error`; the voting target cannot compile until the nested enum conforms.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: The voting target fails to compile: synthesized Equatable conformance for VotingToast cannot be generated because its stored style property has type Style, which does not conform to Equatable; RequestDetailsViewModel's toast.style == .error and the style equality tests also require that conformance._

In `DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeysViewModel.swift:132-145: Do not automatically select another node when removing the selected key
  Removing an imported key calls `store.forgetNode`, which removes that node from `selectedNodeIDs`. Before voting setup, `VotingStore.tickedNodeIDs` returns `nil` when the remaining live selection is empty, so `rowsChanged()` treats the result as 'nothing was ever chosen' and auto-ticks the sole remaining row. Removing the only selected node from a pre-setup A/B list can therefore silently select B, contrary to the explicit removal action.

In `DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:271-275: Do not automatically select another node when removing the selected key
  The `tickedNodeIDs` accessor returns `nil` for an empty live selection while voting is not set up. That sentinel is consumed by `VotingKeysViewModel.rowsChanged()` as an unchosen state, which triggers the single-row fallback after `forgetNode` empties the selection. The store must preserve the distinction between 'no choice has ever been made' and 'the user explicitly removed the last choice'.
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.

  • Move the blocking vote FFI call off the main actor — MasternodeVoteCaster is main-actor isolated and its default sender awaits castContestedResourceVote; the SDK implementation performs a blocking runtime operation until broadcast completes. A slow network or retry can therefore stall the UI during voting. This predates the reviewed range and is not required to resolve this PR.
    • Follow-up: Create a follow-up issue or PR that moves the blocking SDK vote invocation onto the SDK worker executor while preserving voting-key buffer lifetime.

@romchornyi

Copy link
Copy Markdown
Contributor Author

Review round r13 (thepastaclaw at 0f5e568): no code change here.

  • Make VotingToast.Style Equatable: not changing this. An enum without associated values gets Equatable and Hashable synthesized automatically, so VotingToast's synthesized conformance and toast.style == .error compile as they are. The target builds and the unit-test CI job is green at this head.
  • Do not automatically select another node when removing the selected key (VotingKeysViewModel.swift:132-145, VotingStore.swift:271-275): not changing this. It is the behaviour already declined in earlier rounds as intended: before voting is set up, the only remaining node is ticked visibly, and no vote is sent until the owner confirms on Add your voting keys.

The diff of this PR is too large for inline threads, so these replies cannot sit on a thread; they cover the same findings if they come up again.

…settles the remembered choice

Before the sync is done the registry can return imported nodes while this
wallet's own are not found yet. That resolution is now partial, so the
store does not drop remembered nodes against it and Add your voting keys
keeps hidden ticks. Includes the filter-by-my-vote sync gate from below.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SDD-Published-From: dfd23434e28115c8f679734815c08d682561ff2f
@romchornyi

Copy link
Copy Markdown
Contributor Author

From the review of #1366 (a blocking finding on code that lives here): a node list read before the wallet's sync is done could settle the remembered node choice against imported nodes only and drop this wallet's own nodes not found yet. Such a resolution is now .partial, so nothing settles it. Fixed in f1fc1c4 (with the sync gate from #1328 below), with a test.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Two blocking sync-lifecycle gaps remain in the voting screen: node resolution is sampled only during explicit refreshes, and sync-completeness changes do not reliably publish derived state. The simulator test check is still in progress; all completed code-policy checks pass, and CodeRabbit reported no findings.

A pattern across this PR's review rounds

This is review round 12, and the PR has drawn 21 blocking findings so far. 2 of them share one underlying cause. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.

1. Node resolution is a snapshot, not a live state (2 new in this round finding(s))

VotingStore.refreshVotableNodes() samples MasternodeVoterRegistry once, stores nodeListSynced separately, and emits stateDidChange only for node-ID or incompleteness changes. No owner handles the transition when SyncingActivityMonitor reaches .syncDone, so a screen opened during sync never re-resolves and a false-to-true sync change with identical node IDs is invisible to VotingListViewModel; the list message also consults a narrower flag than nodeResolution.

In this round: Re-resolve and publish voting nodes when wallet sync completes; List message omits sync-partial node resolution

Suggested decision (redesign the component): Redesign the VotingStore/MasternodeVoterRegistry boundary before adding another callback or guard. Make VotingStore own a live NodeResolution fed by the sync lifecycle, re-resolve at .syncDone, and publish resolution changes even when node IDs stay unchanged; make VotingListViewModel.message, filters, and key flows consume that state instead of separate flags. Keep ADR-0038's selection-persistence rule, but do not land this feature until one resolution stream drives both selection safety and user-visible readiness.

If a later review again finds new blockers from this cause, it will ask for that decision and pause automatic re-review until it is made.

🔴 2 blocking

2 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Re-resolve and publish voting nodes when wallet sync completes
DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:453-457

refreshVotableNodes() samples nodes.isNodeListSynced, but VotingStore does not observe SyncingActivityMonitor and no screen callback calls this method when sync reaches .syncDone. UsernameVotingScreen only calls refreshIfNeeded(), which returns after the first contest load, so a screen opened during sync can retain a partial node list and stale vote filters indefinitely. In addition, nodeListSynced has no change publisher and the votableNodes setter emits only when node IDs change; a false-to-true sync transition with identical IDs therefore does not trigger VotingListViewModel.recomputeVisible(). Observe the sync completion lifecycle, re-resolve the nodes, and publish whenever sync completeness changes.

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general)

🔴 Blocking: List message omits sync-partial node resolution
DashWallet/Sources/UI/DashPay/Voting/List/VotingListViewModel.swift:105-110

VotingStore.nodeResolution is .partial whenever non-empty nodes are observed before wallet sync completes, even when nodeListMayBeIncomplete is false. message checks only nodeListMayBeIncomplete, so a pre-sync imported-only or otherwise partial list shows no persistent warning above the rows. The user can see and act on a list that is known not to be exhaustive, while the existing sync-related subtitle in myVotesUnavailableReason confirms that this state is intended to be surfaced.

if store.nodeListMayBeIncomplete || store.nodeResolution == .partial { return .nodeListIncomplete }

source: muse-spark-1.3-contributor (phase1-reviewer: general)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, intricate change that modifies masternode voting and vote casting, including key setup, signing-related SDK integration, vote-limit enforcement, and network-facing vote submission in MasternodeVoteCaster.swift and the voting store/coordinator.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
Several findings on this PR share an underlying cause (the review's "pattern" section): Node resolution is a snapshot, not a live state. When you fix the findings below, fix the cause, not only the reported case. The review suggests (redesign the component): Redesign the VotingStore/MasternodeVoterRegistry boundary before adding another callback or guard. Make VotingStore own a live NodeResolution fed by the sync lifecycle, re-resolve at .syncDone, and publish resolution changes even when node IDs stay unchanged; make VotingListViewModel.message, filters, and key flows consume that state instead of separate flags. Keep ADR-0038's selection-persistence rule, but do not land this feature until one resolution stream drives both selection safety and user-visible readiness. If that decision is not yours to make, say so to the PR's author or maintainer.

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 `DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:453-457: Re-resolve and publish voting nodes when wallet sync completes
  `refreshVotableNodes()` samples `nodes.isNodeListSynced`, but `VotingStore` does not observe `SyncingActivityMonitor` and no screen callback calls this method when sync reaches `.syncDone`. `UsernameVotingScreen` only calls `refreshIfNeeded()`, which returns after the first contest load, so a screen opened during sync can retain a partial node list and stale vote filters indefinitely. In addition, `nodeListSynced` has no change publisher and the `votableNodes` setter emits only when node IDs change; a false-to-true sync transition with identical IDs therefore does not trigger `VotingListViewModel.recomputeVisible()`. Observe the sync completion lifecycle, re-resolve the nodes, and publish whenever sync completeness changes.

In `DashWallet/Sources/UI/DashPay/Voting/List/VotingListViewModel.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/List/VotingListViewModel.swift:105-110: List message omits sync-partial node resolution
  `VotingStore.nodeResolution` is `.partial` whenever non-empty nodes are observed before wallet sync completes, even when `nodeListMayBeIncomplete` is false. `message` checks only `nodeListMayBeIncomplete`, so a pre-sync imported-only or otherwise partial list shows no persistent warning above the rows. The user can see and act on a list that is known not to be exhaustive, while the existing sync-related subtitle in `myVotesUnavailableReason` confirms that this state is intended to be surfaced.

@romchornyi

Copy link
Copy Markdown
Contributor Author

Review at f1fc1c444: both findings ("Re-resolve and publish voting nodes when wallet sync completes" and "List message omits sync-partial node resolution") are deferred to #1424, which covers the node-resolution-as-live-state cause from the pattern section. Nothing is voted or saved against a partial list meanwhile: the remembered choice settles only on a complete resolution, Quick voting refuses to run, and the "my votes" filters say the list is still syncing; pull to refresh re-reads the nodes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SDD-Published-From: 81f4a1bcd554a4b1f537d252282b7ee11e084050

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The head still has two blocking issues. Retry does not retain the store-wide vote slot after its history read, allowing another vote to start while retry work is still running; the new voting-key import screen also exposes a private voting credential through a non-secure field. The supplied simulator tests, accessibility audit, workflow lint, and target-membership checks passed; the review check remains in progress.

A pattern across this PR's review rounds

This is review round 13, and the PR has drawn 22 blocking findings so far. 2 of them share one underlying cause. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.

1. Node resolution is still a snapshot, not live state (2 earlier finding(s))

VotingStore still samples MasternodeVoterRegistry only during refreshVotableNodes(), then exposes separate nodeListSynced and nodeListMayBeIncomplete flags rather than one resolution stream driven by SyncingActivityMonitor. The earlier selection-persistence redesign is now in place, but the screen can remain on a stale partial snapshot and its consumers still read different flags, so each new guard or message fix works around the same missing lifecycle ownership.

Already tracked: #1424

Suggested decision (redesign the component): Before landing this feature, redesign the VotingStore/MasternodeVoterRegistry boundary so VotingStore owns a live NodeResolution fed by the sync lifecycle and re-resolves when sync reaches .syncDone. Publish resolution changes even when the node IDs do not change, and make the list message, filters, and key flow consume that single state instead of separate readiness flags. Keep ADR-0038's rule that only VotingStore writes the remembered selection; either land issue #1424's live-resolution work first or remove the feature behavior that depends on it until that issue is complete.

If a later review again finds new blockers from this cause, it will ask for that decision and pause automatic re-review until it is made.

🔴 2 blocking

2 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Reserve the global operation slot before retrying history
DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:682-691

retryFailed() checks !isVoteBusy, but the reservation from loadVotedNodesForVote exists only for the history read and is released before the retry evaluates its gates and resends failed nodes. The subsequent private cast path does not enforce the store-wide busy state, so another vote can begin while the retry is still resolving or resending. That can produce concurrent broadcasts and shared-state races, including changes to outcome, lastSentContest, and the retry's report. Hold a dedicated global operation slot from the initial retry check through the final merged outcome, releasing it only after all retry work completes.

source: gpt-6.1-sol (phase2-reviewer: general)

🔴 Blocking: Render the imported voting private key in a secure field
DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeyInputScreen.swift:115-124

The new screen passes the masternode voting private key to DashUIKit.AddressFieldView, which uses a regular text field rather than secure text entry. The complete WIF remains visible while focused and after focus is lost, and can be exposed through shoulder surfing, screenshots, screen recording, or accessibility. Anyone obtaining it can authorize voting actions for the associated masternode without further owner consent. Use a secure-entry variant or SecureField while retaining the existing paste and QR actions.

Raised on code unchanged since the last review, and confirmed by an independent pass: A user can reach the voting-key import screen, paste or scan a valid WIF, and see the complete private key in the ordinary AddressFieldView text field while editing and after focus is lost. Anyone who observes or captures that screen can obtain the key and authorize votes for the associated masternode without further owner consent.

source: gpt-6.1-sol (phase2-reviewer: security-auditor)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, intricate change that directly modifies voting key setup, masternode vote signing/casting, vote-limit enforcement, confirmation gating, and the SwiftDashSDK voting boundary in MasternodeVoteCaster.swift and MasternodeVoterRegistry.swift, affecting signatures and peer-facing governance actions.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Code unchanged since the last final review (f1fc1c44): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
Several findings on this PR share an underlying cause (the review's "pattern" section): Node resolution is still a snapshot, not live state. When you fix the findings below, fix the cause, not only the reported case. The review suggests (redesign the component): Before landing this feature, redesign the VotingStore/MasternodeVoterRegistry boundary so VotingStore owns a live NodeResolution fed by the sync lifecycle and re-resolves when sync reaches .syncDone. Publish resolution changes even when the node IDs do not change, and make the list message, filters, and key flow consume that single state instead of separate readiness flags. Keep ADR-0038's rule that only VotingStore writes the remembered selection; either land issue #1424's live-resolution work first or remove the feature behavior that depends on it until that issue is complete. If that decision is not yours to make, say so to the PR's author or maintainer.

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 `DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:682-691: Reserve the global operation slot before retrying history
  `retryFailed()` checks `!isVoteBusy`, but the reservation from `loadVotedNodesForVote` exists only for the history read and is released before the retry evaluates its gates and resends failed nodes. The subsequent private `cast` path does not enforce the store-wide busy state, so another vote can begin while the retry is still resolving or resending. That can produce concurrent broadcasts and shared-state races, including changes to `outcome`, `lastSentContest`, and the retry's report. Hold a dedicated global operation slot from the initial retry check through the final merged outcome, releasing it only after all retry work completes.

In `DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeyInputScreen.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Keys/VotingKeyInputScreen.swift:115-124: Render the imported voting private key in a secure field
  The new screen passes the masternode voting private key to `DashUIKit.AddressFieldView`, which uses a regular text field rather than secure text entry. The complete WIF remains visible while focused and after focus is lost, and can be exposed through shoulder surfing, screenshots, screen recording, or accessibility. Anyone obtaining it can authorize voting actions for the associated masternode without further owner consent. Use a secure-entry variant or `SecureField` while retaining the existing paste and QR actions.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: A user can reach the voting-key import screen, paste or scan a valid WIF, and see the complete private key in the ordinary AddressFieldView text field while editing and after focus is lost. Anyone who observes or captures that screen can obtain the key and authorize votes for the associated masternode without further owner consent._

The slot was held only for the retry's history read and taken again by the
send, so nothing tied the two together. It is now held from the read to the
merged outcome.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SDD-Published-From: 566653f7c68019f0aed4a66052700155b310fb39
@romchornyi

Copy link
Copy Markdown
Contributor Author

Answers to the two blockers at 5a79024 (not inline, the diff is too large):

  • Reserve the global operation slot before retrying history — fixed in de3c9b1. retryFailed() now holds the vote slot from its history read to the merged outcome, so no other vote can start between them; covered by testTryAgainHoldsTheVoteSlotUntilItsOutcome.
  • Render the imported voting private key in a secure field — deferred to Voting key entry: show the masternode voting private key in a secure field #1429. develop's voting key screen already shows the key in the same AddressFieldView; this PR moved the screen without changing the field, so the change goes in on its own.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The exact-head code checks in the supplied CI snapshot are green. Two in-scope blocking defects remain: voting setup and node selection are stored globally despite wallet- and network-scoped voting state, and Try again retries transport-ambiguous broadcasts as ordinary failures.

Step back: this PR keeps drawing new blockers

This is review round 14, and the PR has drawn 24 blocking findings so far. The review of 5a790246 named these causes and the decision that would settle it; this round found 2 more finding(s) from the same place. Fixing them one at a time is not converging, so this review asks for that decision before another round.

1. Node resolution is still a snapshot, not live state (2 earlier finding(s))

VotingStore samples MasternodeVoterRegistry during explicit refreshes and stores separate nodeListSynced and nodeListMayBeIncomplete flags instead of owning a resolution stream driven by SyncingActivityMonitor. Because publication is tied mainly to node-ID changes, sync completion can leave the list, filters, and key flow using a stale partial snapshot; the PR discussion explicitly defers this to the still-open node-resolution work.

Already tracked: #1424

2. The remembered voting choice has no identity or resolution context (1 new in this round, 1 earlier finding(s))

VotingPrefs stores isVotingSetUp and votingNodeSelection under global UserDefaults keys, while VotingStore treats the values as the current wallet's decision and reconciles them against whatever node snapshot is currently available. Earlier partial-resolution handling and the new wallet/network switch case expose the same missing model: a selection needs an owner and trusted-resolution context, not just a bare set of proTxHashes.

In this round: Scope the voting setup and node selection to the active wallet and network

3. Retry is not a first-class, at-most-once vote operation (1 new in this round, 1 earlier finding(s))

retryFailed reconstructs a new attempt from the local failed report, and MasternodeVoteCaster converts every thrown submission error into an ordinary failed VoteOutcome. There is no durable operation identity or explicit accepted, rejected, and transport-ambiguous state, so one patch had to reserve the store slot across the retry window while another failure mode still allows a timeout or lost response to be submitted again.

In this round: Do not retry votes whose broadcast outcome is ambiguous

Requested decision (redesign the component): Redesign the VotingStore voting boundary before landing instead of adding another guard: it must own one wallet/network-scoped live NodeResolution and one first-class vote-attempt record with explicit accepted, rejected, and transport-ambiguous outcomes. The list, filters, key flow, and retry UI should consume those states, with sync completion and submission reconciliation feeding the store. If the SDK cannot support reconciliation, remove or gate Try again and the behavior that depends on live node resolution from this PR and track it separately.

Automatic re-review is paused until then: later pushes keep this review's verdict and are not reviewed on their own. Comment @thepastaclaw review once the decision is made: that resumes automatic re-review, and reviews the current commit if it has not been reviewed.

🔴 2 blocking

2 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Scope the voting setup and node selection to the active wallet and network
DashWallet/Sources/Models/Voting/VotingPrefs.swift:76-78

isVotingSetUp and votingNodeSelection use fixed UserDefaults keys, while VotingStore reads them for whichever wallet and network is currently active. After setup in wallet A, opening voting with wallet B leaves the setup flag and A's selected node IDs in place; if B has different votable nodes, the intersection can be empty while VotingListViewModel.canFilterByMyVotes still reports true, causing the approved and not-voted filters to classify B's contests using an empty or stale selection. The same contamination occurs when switching between mainnet and testnet, whose vote history is separately scoped. Persist these values by active wallet ID and network scope, or explicitly invalidate and reload them on wallet and network transitions, and add coverage for both transitions.

Raised on code unchanged since the last review, and confirmed by an independent pass: After wallet A completes setup with its masternode IDs selected, switching to wallet B leaves the global setup flag and A's IDs in UserDefaults. If B has at least one different votable node and a synced, complete node list, VotingStore.isVotingSetUp and VotingListViewModel.canFilterByMyVotes are true, but tickedNodeIDs is the empty intersection; the approved filter then hides every contest and the not-voted filter treats every contest as unvoted, regardless of B's actual history.

source: gpt-6.1-sol (phase2-reviewer: general)

🔴 Blocking: Do not retry votes whose broadcast outcome is ambiguous
DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:770-775

retryFailed() treats every failed node as eligible for a fresh send after rereading history, and resend calls cast for those nodes. MasternodeVoteCaster.castAuthenticated records any send error as an ordinary failed outcome, while network and timeout errors are presented as a normal connection failure. The SDK vote operation submits a transition and waits for a response, so a lost response or timeout can occur after Platform accepted the vote; tapping Try again can then submit another signed transition, consume another vote slot, and leave local history short of the votes Platform accepted. Preserve an explicit ambiguous-transport outcome and reconcile it where possible, or prevent automatic retry and require an explicit warning before resubmission.

source: security-auditor

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, intricate change that alters masternode voting authorization, vote-limit enforcement, block-confirmation gating, voting-key setup, and vote casting through MasternodeVoteCaster.swift, which touches key handling and signed peer-facing voting behavior.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Code unchanged since the last final review (5a790246): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
Before fixing anything, read the review's "Step back" section. This PR keeps drawing new blocking findings from the same underlying causes, and patching the findings below one at a time is not converging. The review asks for this decision first (redesign the component): Redesign the VotingStore voting boundary before landing instead of adding another guard: it must own one wallet/network-scoped live NodeResolution and one first-class vote-attempt record with explicit accepted, rejected, and transport-ambiguous outcomes. The list, filters, key flow, and retry UI should consume those states, with sync completion and submission reconciliation feeding the store. If the SDK cannot support reconciliation, remove or gate Try again and the behavior that depends on live node resolution from this PR and track it separately. Raise that decision with the PR's author or maintainer instead of only patching; if it is theirs to make, stop and ask them.

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 `DashWallet/Sources/Models/Voting/VotingPrefs.swift`:
- [BLOCKING] DashWallet/Sources/Models/Voting/VotingPrefs.swift:76-78: Scope the voting setup and node selection to the active wallet and network
  `isVotingSetUp` and `votingNodeSelection` use fixed UserDefaults keys, while `VotingStore` reads them for whichever wallet and network is currently active. After setup in wallet A, opening voting with wallet B leaves the setup flag and A's selected node IDs in place; if B has different votable nodes, the intersection can be empty while `VotingListViewModel.canFilterByMyVotes` still reports true, causing the approved and not-voted filters to classify B's contests using an empty or stale selection. The same contamination occurs when switching between mainnet and testnet, whose vote history is separately scoped. Persist these values by active wallet ID and network scope, or explicitly invalidate and reload them on wallet and network transitions, and add coverage for both transitions.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: After wallet A completes setup with its masternode IDs selected, switching to wallet B leaves the global setup flag and A's IDs in UserDefaults. If B has at least one different votable node and a synced, complete node list, `VotingStore.isVotingSetUp` and `VotingListViewModel.canFilterByMyVotes` are true, but `tickedNodeIDs` is the empty intersection; the approved filter then hides every contest and the not-voted filter treats every contest as unvoted, regardless of B's actual history._

In `DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:770-775: Do not retry votes whose broadcast outcome is ambiguous
  `retryFailed()` treats every failed node as eligible for a fresh send after rereading history, and `resend` calls `cast` for those nodes. `MasternodeVoteCaster.castAuthenticated` records any send error as an ordinary failed outcome, while network and timeout errors are presented as a normal connection failure. The SDK vote operation submits a transition and waits for a response, so a lost response or timeout can occur after Platform accepted the vote; tapping Try again can then submit another signed transition, consume another vote slot, and leave local history short of the votes Platform accepted. Preserve an explicit ambiguous-transport outcome and reconcile it where possible, or prevent automatic retry and require an explicit warning before resubmission.

SDD-Published-From: d91b151415bbb9c3f4e281115a91cf3b18354cad
@romchornyi

Copy link
Copy Markdown
Contributor Author

Scope the voting setup and node selection to the active wallet and network: fixed in 7a1387f. The masternode choice and "voting set up" are now stored per Platform network (mainnet keeps the existing key), and a wallet wipe forgets them on every network; covered by testVotingSetupIsKeptPerNetwork. The wallet half was already handled: the app holds one wallet, a wallet change goes through the wipe, and the wipe calls forgetVotingSetup().

Do not retry votes whose broadcast outcome is ambiguous: fixed above this PR in the stack, #1366 (8b52cf3). The SDK reports an ambiguous submission as SDKError.stateTransitionResultUnconfirmed; #1366 records it as an unconfirmed outcome ("Result not confirmed") that isRetryable excludes, so Try again never resends it. The stack lands in develop as one merge, so this stage's behaviour does not reach develop on its own.

Requested decision (redesign the VotingStore boundary): the maintainer's decision is to land the stack with the current guards and do the redesign as follow-up work: the vote-attempt model with explicit accepted, rejected and ambiguous outcomes in #1417, live node resolution in #1424.

@thepastaclaw review

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The exact reviewed head still contains two blocking correctness issues: ambiguous SDK broadcast outcomes are converted into generic retryable failures, and voting preferences are scoped by network but not by active wallet. The simulator test and review checks are still in progress; no completed code check is currently failing.

🔴 2 blocking

2 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Do not retry votes whose broadcast outcome is ambiguous
DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:694-709

retryFailed() builds failed from every report.failed entry and passes those nodes through retryOutcomes, which can reach resend after the fresh history read. At this head, VoteErrorMessage.plain(for:) does not special-case SDKError.stateTransitionResultUnconfirmed; it falls through to the generic message, and VoteOutcome stores no distinction between a rejected vote and an unknown broadcast result. Consequently, Try again can resend a vote whose first submission may already have reached Platform, risking a duplicate vote. The referenced #1366 change is not an ancestor of this exact head, so this behavior remains present here.

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general)

🔴 Blocking: Scope the voting setup and node selection to the active wallet and network
DashWallet/Sources/Models/Voting/VotingPrefs.swift:48-51

scoped(_:) adds only the Platform network to the preference key. The wallet-switch path in WalletsViewModel.gatedSwitchWallet calls SwiftDashSDKWalletRuntime.switchWallet(to:) and posts the wallet-change notification, but it does not call App.cleanUp() or VotingPrefs.forgetVotingSetup(). App.cleanUp() is invoked by wallet-wipe flows, not ordinary wallet switching. Therefore switching from wallet A to wallet B on the same network leaves A's isVotingSetUp flag and selected proTx hashes in the shared preferences, allowing B to inherit voting setup and node selection without confirming its own keys.

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a large, cross-cutting voting UI and application-logic change, but it does not itself modify funds movement, cryptography, consensus rules, key handling, peer-facing deserialization, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-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 `DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:694-709: Do not retry votes whose broadcast outcome is ambiguous
  `retryFailed()` builds `failed` from every `report.failed` entry and passes those nodes through `retryOutcomes`, which can reach `resend` after the fresh history read. At this head, `VoteErrorMessage.plain(for:)` does not special-case `SDKError.stateTransitionResultUnconfirmed`; it falls through to the generic message, and `VoteOutcome` stores no distinction between a rejected vote and an unknown broadcast result. Consequently, Try again can resend a vote whose first submission may already have reached Platform, risking a duplicate vote. The referenced #1366 change is not an ancestor of this exact head, so this behavior remains present here.

In `DashWallet/Sources/Models/Voting/VotingPrefs.swift`:
- [BLOCKING] DashWallet/Sources/Models/Voting/VotingPrefs.swift:48-51: Scope the voting setup and node selection to the active wallet and network
  `scoped(_:)` adds only the Platform network to the preference key. The wallet-switch path in `WalletsViewModel.gatedSwitchWallet` calls `SwiftDashSDKWalletRuntime.switchWallet(to:)` and posts the wallet-change notification, but it does not call `App.cleanUp()` or `VotingPrefs.forgetVotingSetup()`. `App.cleanUp()` is invoked by wallet-wipe flows, not ordinary wallet switching. Therefore switching from wallet A to wallet B on the same network leaves A's `isVotingSetUp` flag and selected proTx hashes in the shared preferences, allowing B to inherit voting setup and node selection without confirming its own keys.
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.

  • Move the production voting host outside the DEBUG preview block — Already addressed: UsernameVotingHostingController is outside the DEBUG-only preview block and is available to Release builds.
    • Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.

SDD-Published-From: b549622bd9fc870020f2b27298e20e4d0bd1ea60
@romchornyi

Copy link
Copy Markdown
Contributor Author

Scope the voting setup and node selection to the active wallet and network: fixed in 640ed1c. My earlier note was wrong: switching wallets does not go through the wipe. The masternode choice and "voting set up" are now keyed by the network and the active wallet ID, and a wipe still forgets them all; covered by testVotingSetupIsKeptPerWalletAndNetwork.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The wallet/network-scoped preference and retry-slot changes are present at the reviewed head, and the simulator, target-membership, accessibility, and workflow checks reported by CI succeeded. Two in-scope blockers remain: ambiguous SDK broadcast failures are still retried, and remembered node selections are discarded when moving from the prior unscoped or network-scoped keys to the new wallet-scoped keys.

Step back: this PR keeps drawing new blockers

This is review round 16, and the PR has drawn 25 blocking findings so far. The review of de3c9b1b named these causes and the decision that would settle it; this round found 1 more finding(s) from the same place. Fixing them one at a time is not converging, so this review asks for that decision before another round.

1. Node resolution remains a snapshot rather than live state (9 earlier finding(s))

VotingStore.refreshVotableNodes() samples MasternodeVoterRegistry and records nodeListSynced and nodeListMayBeIncomplete, but it does not own a resolution stream driven by SyncingActivityMonitor. VotingKeysViewModel and the list must therefore keep adding special cases for unavailable, partial, and newly complete snapshots, so each fix moves the stale-state problem to another transition or entry point.

Already tracked: #1424

2. Vote retry still lacks an at-most-once operation record (2 earlier finding(s))

The recent patches reserve an in-memory voteReads slot, but a vote has no durable operation identity or explicit accepted, rejected, and transport-ambiguous outcome. MasternodeVoteCaster still turns every thrown submission error into an ordinary failed VoteOutcome, and retryFailed() can resend it after rereading history even when Platform may have accepted the original transition.

3. Preference scope changed without a migration model (1 new in this round, 1 earlier finding(s))

VotingPrefs changed from global keys to network keys and then to wallet-and-network keys, but the design has no versioned migration or legacy-read rule. The wallet scoping patch prevents new cross-wallet contamination, while the missing migration makes existing selections appear absent and can cause the keys flow to choose a different visible node, so the same preference is first shared incorrectly and then lost on upgrade.

In this round: Migrate remembered voting-node selections into the wallet-scoped key

Requested decision (redesign the component): Redesign the VotingStore voting boundary before landing: it must own one wallet/network-scoped live NodeResolution and one first-class vote-attempt record with explicit accepted, rejected, and transport-ambiguous outcomes. Make the preference namespace migration part of that boundary, or remove the new scope change until existing selections can be migrated safely. The list, filters, keys flow, and retry UI should consume those states instead of reconstructing them from snapshots and transient reports.

Automatic re-review is paused until then: later pushes keep this review's verdict and are not reviewed on their own. Comment @thepastaclaw review once the decision is made: that resumes automatic re-review, and reviews the current commit if it has not been reviewed.

🔴 2 blocking

2 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Do not retry votes whose broadcast outcome is ambiguous
DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:694-709

retryFailed() places every entry in report.failed into failed and advances those nodes through the retry gates and resend path. In MasternodeVoteCaster.castAuthenticated(), all thrown send errors—including SDKError.stateTransitionResultUnconfirmed, which means the broadcast may have landed—are converted by VoteErrorMessage.plain(for:) into an ordinary failed VoteOutcome; there is no explicit ambiguous outcome or retry exclusion at this head. The #1366 change cited in the discussion is not present in this exact head, so Try again can rebroadcast a vote whose first submission may already have been accepted and consume another vote-limit slot. Preserve an explicit unconfirmed/ambiguous outcome through the caster and exclude those nodes from retryFailed().

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general)

🔴 Blocking: Migrate remembered voting-node selections into the wallet-scoped key
DashWallet/Sources/Models/Voting/VotingPrefs.swift:83-91

The new accessor reads only votingNodeSelectionKey.<network>.<walletId>. The immediately preceding implementation stored mainnet selections under the unscoped votingNodeSelectionKey and other networks under votingNodeSelectionKey.<network>, while the earlier implementation also used the unscoped key; this code has no migration or fallback read for either form. Existing owners who selected multiple masternodes therefore see an empty selection after updating, and the keys screen can fall back to a different visible node, silently changing the privacy choice that the PR description says will remain pre-ticked. Migrate legacy data only into the currently active wallet and network scope, without allowing one wallet to inherit another wallet's selection.

source: gpt-6.1-sol (phase2-reviewer: general)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a large, intricate cross-cutting voting UI and state-management change, but the diff does not directly modify consensus rules, funds movement, cryptography, signatures, key handling, peer-facing deserialization, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
Before fixing anything, read the review's "Step back" section. This PR keeps drawing new blocking findings from the same underlying causes, and patching the findings below one at a time is not converging. The review asks for this decision first (redesign the component): Redesign the VotingStore voting boundary before landing: it must own one wallet/network-scoped live NodeResolution and one first-class vote-attempt record with explicit accepted, rejected, and transport-ambiguous outcomes. Make the preference namespace migration part of that boundary, or remove the new scope change until existing selections can be migrated safely. The list, filters, keys flow, and retry UI should consume those states instead of reconstructing them from snapshots and transient reports. Raise that decision with the PR's author or maintainer instead of only patching; if it is theirs to make, stop and ask them.

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 `DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Voting/Store/VotingStore.swift:694-709: Do not retry votes whose broadcast outcome is ambiguous
  `retryFailed()` places every entry in `report.failed` into `failed` and advances those nodes through the retry gates and resend path. In `MasternodeVoteCaster.castAuthenticated()`, all thrown send errors—including `SDKError.stateTransitionResultUnconfirmed`, which means the broadcast may have landed—are converted by `VoteErrorMessage.plain(for:)` into an ordinary failed `VoteOutcome`; there is no explicit ambiguous outcome or retry exclusion at this head. The #1366 change cited in the discussion is not present in this exact head, so Try again can rebroadcast a vote whose first submission may already have been accepted and consume another vote-limit slot. Preserve an explicit unconfirmed/ambiguous outcome through the caster and exclude those nodes from `retryFailed()`.

In `DashWallet/Sources/Models/Voting/VotingPrefs.swift`:
- [BLOCKING] DashWallet/Sources/Models/Voting/VotingPrefs.swift:83-91: Migrate remembered voting-node selections into the wallet-scoped key
  The new accessor reads only `votingNodeSelectionKey.<network>.<walletId>`. The immediately preceding implementation stored mainnet selections under the unscoped `votingNodeSelectionKey` and other networks under `votingNodeSelectionKey.<network>`, while the earlier implementation also used the unscoped key; this code has no migration or fallback read for either form. Existing owners who selected multiple masternodes therefore see an empty selection after updating, and the keys screen can fall back to a different visible node, silently changing the privacy choice that the PR description says will remain pre-ticked. Migrate legacy data only into the currently active wallet and network scope, without allowing one wallet to inherit another wallet's selection.

…allet split

SDD-Published-From: c020b21957559f3a3ac80fc962a9d1aeddb734bd
@romchornyi

Copy link
Copy Markdown
Contributor Author

Migrate remembered voting-node selections into the wallet-scoped key: fixed in 9d86c18. A mainnet wallet that has not saved a choice of its own reads the selection earlier versions stored under the plain key; the store ticks only that wallet's own votable nodes, and the wallet's next save replaces it. The intermediate per-network keys never shipped. Covered by testTheChoiceSavedBeforeTheSplitStaysMainnets.

SDD-Published-From: a4207ca350cf32f4bf6641f42b6c57e8d0d85b7c

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants