Repository navigation
fix(dpns): keep the background contest refresh from resetting unrelated screens - #1071
Conversation
A contest refresh pass asked Platform for the contenders of every contest the app had ever seen, finished ones included: one request per contest, about a thousand on Testnet, 24 at a time. Since #901 that pass also runs on arrival at Masternodes > Votes and from a background timer, so it fired every few minutes. The SDK sends requests to five endpoints at a time and each allows 150 a minute; one pass went past that, the endpoints answered ResourceExhausted and were banned, and every other action shared the loss. - A stored contest that already has its outcome (awarded or locked) is final: a refresh that lists it stamps it as current and no longer queues a contender query for it. A pass now costs the contest list plus the contests that are still open. - Only one refresh pass runs at a time. The timer and a user refresh used to overlap and each walk the same unfilled cache. - Contender queries of a pass start no closer than 125 ms apart, so the first load of a long history stays inside the request budget instead of arriving as one burst. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
Pacing the contender queries made the first load of a long contest history take about two minutes, with the contests that can still be voted on sitting at a random alphabetical position in that queue. - The pass now waits for the contest end times (a query it already made) before it starts the contender queries, and reads the contests whose end time is in the future first. The unread history is back-filled after them. - The first 100 contender queries of a pass start at once; only the ones after them are paced. With 480 paced queries a minute that keeps a pass within 580 of the roughly 750 requests a minute the app has. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
On a first load the voting choices and the Votes badge waited for the whole paced back-fill, about two minutes for a thousand contests: both need each node's proved votes, and the pass read those only after its last contender query. Reading them earlier was not safe as it stood. A listed contest nobody has read yet has no end time and counts as open, so every unread finished contest would have shown as waiting for a vote. - While a pass runs, the names it has listed but not read, and has no end time to call open, are left out of the open contests. Each returns as soon as its contenders arrive, and whatever is left returns when the pass ends, however it ends. The set lives in memory only. - When a pass has such unread history, it proves the nodes' votes right after the open contests are read and refreshes the screen, then back-fills. The proof at the end of the pass is kept. A pass on a filled cache has nothing unread, takes neither step and sends the same requests as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
…tart The names a first load had listed but not read were kept out of the open contests by a set held in memory for the length of the pass. The early vote proof, however, is stored. Quitting during a first load and starting again within the proof's lifetime — or a pass that ended with names still unread — left every unread name counted as an open contest the node had not voted on: a badge in the hundreds and enabled choices on finished contests. - A name that was only listed (never read, no end time, no contenders) is not an open contest, wherever the open contests are read. The rule lives on the contest itself, so it holds in a new process and after any pass. The in-memory set, its guard and its lock are gone. - While a pass is running and unread names remain, To decide and Voted say the contests are still loading instead of saying none are open. Tests that seeded such a bare name as an open contest now give it an end time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
…ntest data The contest refresh pass reported progress with TaskResult::Refresh: per list page, after the end-time read, per contender read and after the early vote proof. AppState answers each one with refresh() on the visible screen, so since the pass also runs by itself on a timer, any screen the user was on was told to start over several times a second: lookups lost their spinner and result, typed search text was cleared, amount fields disappeared while their limit was re-checked. The pass now sends TaskResult::DpnsContestsChanged. AppState merges it with adjacent cache notifications as it merges refreshes, and answers it with refresh() only when the visible screen is the Masternodes screen, the one screen that caches contest data. The badge, the attention chip and the identity home's pending-username indicator read live each frame, and the sender already requests the repaint they need. Unchanged: the pass's requests, order and pacing, the early vote proof, what the voting screen does per notification, and every other TaskResult::Refresh sender. Tests: a pass against a mock SDK sends the scoped notification and no TaskResult::Refresh; a withdrawal form on screen is not refreshed by it while a TaskResult::Refresh still refreshes it; an open Votes view shows a contest cached just before the notification. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to Background name-contest updates now refresh only the Masternodes voting screen instead of resetting other screens. No concrete merge-blocking risk was identified. Pre-merge checks |
|
|
🕓 Review not started yet because the new head is waiting for the 30-minute push debounce.
Commit ce968a8. Normal review starts when eligible; priority review starts as soon as a slot is available. |
The pace only spaced out the spawning of contender queries; each spawned query then waited for one of the 24 slots on its own. While answers were slow the pace kept spawning, so queries piled up behind the slots and all started at once when the answers arrived, well above the request allowance. The dispatcher now takes the slot first and waits for the pace second, so a query starts as soon as it is spawned and no sooner than one pace after the query before it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
…ld-load-early-vote-state Brings in the fix that takes a query slot before waiting for the pace. Both dispatch calls of this branch, for the open contests and for the rest, now pass the shared slots and the contender query to start_in_order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
The first-load test sampled the vote state for a second and relied on the paced back-fill outlasting that. A loaded machine could stretch the sampling past the end of the pass and fail the test. The pass now reports to a channel with room for one report, so it gets only as far as the reports the test takes: the proof is awaited report by report and the back-fill stays held while the vote state is checked. A second test answers every contender read. It checks that the votes are not proved before the read of the open contest has finished, and that history read to its outcome does not show as waiting for a vote while the rest is still unread. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
…contest-refresh-notifies-voting-screens-only Brings in the fix that takes a query slot before waiting for the pace and the first-load tests that hold the back-fill by its reports. No conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 2 only (no Phase 1 for this repository)
The exact-head diff confirms that contest notifications refresh only the visible Masternodes screen, while broader refresh requests retain their existing behavior and are flushed before typed results. The added regression tests cover backend notification delivery, preservation of an unrelated form, and updates to the open Votes view; no actionable in-scope issues were found. Verification was static, without local builds or test execution; the supplied CI snapshot reports successful Test Suite and Clippy checks.
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — The diff makes a small, contained change to contest-notification routing and refresh coalescing with focused regression tests, without changing any critical surface. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort medium); agentphase2-reviewer
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
The complete diff preserves generic refresh behavior and notification ordering while restricting contest-cache refreshes to the visible Masternodes screen. The regression tests cover unrelated-screen isolation and updates to the open Votes view; independent static inspection found no actionable in-scope defects. No builds or tests were run locally; the supplied CI snapshot reports successful Test Suite, Clippy, and Platform pin guard checks.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — The diff makes a small, contained change to contest-refresh notification routing and coalescing with focused regression tests, without changing any critical surface. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort medium); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
…r the proof The helper took reports until the stored proof became visible. Another worker could publish the proof right after an earlier report was taken, so the helper returned with a report still filling the one-slot channel. The pass then stayed blocked on its proof report and never began the back-fill, and the answered-history test failed with "no history was read". A pass sends its reports in a fixed order. Both tests now take exactly the reports up to and including the proof report, which puts the pass in the back-fill whichever task ran first, and then check the vote state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
…contest-refresh-notifies-voting-screens-only Brings in the first-load tests that take a fixed number of pass reports instead of polling for the proof. No conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
Independently reviewed the complete diff at head 217faf9 and verified the supplied reviewer claims against notification producers, result routing, and screen refresh behavior. The scoped notification leaves unrelated screens untouched while preserving visible Masternodes updates, broader refresh requests, and typed-result ordering; no actionable in-scope findings were identified. Regression tests cover screen isolation and visible Votes updates, and the supplied exact-head CI snapshot reports successful Test Suite and Clippy checks; no builds or tests were run locally in this static-review lane.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — The diff makes a small, contained change to contest-refresh notification routing and coalescing, with regression tests, without altering requests, voting logic, or critical surfaces. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort medium); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
Conflict in CHANGELOG.md: both entries kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
…-early-vote-state Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
…-refresh-notifies-voting-screens-only Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
* fix(dpns): let operators vote while a long contest history loads On a first load the voting choices and the Votes badge waited for the whole paced back-fill, about two minutes for a thousand contests: both need each node's proved votes, and the pass read those only after its last contender query. Reading them earlier was not safe as it stood. A listed contest nobody has read yet has no end time and counts as open, so every unread finished contest would have shown as waiting for a vote. - While a pass runs, the names it has listed but not read, and has no end time to call open, are left out of the open contests. Each returns as soon as its contenders arrive, and whatever is left returns when the pass ends, however it ends. The set lives in memory only. - When a pass has such unread history, it proves the nodes' votes right after the open contests are read and refreshes the screen, then back-fills. The proof at the end of the pass is kept. A pass on a filled cache has nothing unread, takes neither step and sends the same requests as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw * fix(dpns): keep unread contest names out of the open list after a restart The names a first load had listed but not read were kept out of the open contests by a set held in memory for the length of the pass. The early vote proof, however, is stored. Quitting during a first load and starting again within the proof's lifetime — or a pass that ended with names still unread — left every unread name counted as an open contest the node had not voted on: a badge in the hundreds and enabled choices on finished contests. - A name that was only listed (never read, no end time, no contenders) is not an open contest, wherever the open contests are read. The rule lives on the contest itself, so it holds in a new process and after any pass. The in-memory set, its guard and its lock are gone. - While a pass is running and unread names remain, To decide and Voted say the contests are still loading instead of saying none are open. Tests that seeded such a bare name as an open contest now give it an end time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw * test(dpns): hold the contest back-fill by its reports instead of by time The first-load test sampled the vote state for a second and relied on the paced back-fill outlasting that. A loaded machine could stretch the sampling past the end of the pass and fail the test. The pass now reports to a channel with room for one report, so it gets only as far as the reports the test takes: the proof is awaited report by report and the back-fill stays held while the vote state is checked. A second test answers every contender read. It checks that the votes are not proved before the read of the open contest has finished, and that history read to its outcome does not show as waiting for a vote while the rest is still unread. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw * test(dpns): take a fixed number of pass reports instead of polling for the proof The helper took reports until the stored proof became visible. Another worker could publish the proof right after an earlier report was taken, so the helper returned with a report still filling the one-slot channel. The pass then stayed blocked on its proof report and never began the back-fill, and the answered-history test failed with "no history was read". A pass sends its reports in a fixed order. Both tests now take exactly the reports up to and including the proof report, which puts the pass in the back-fill whichever task ran first, and then check the vote state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw --------- Co-authored-by: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…x/contest-refresh-notifies-voting-screens-only The squash commit's tree equals this branch's already-merged view of #1067 on top of its parent, so it is recorded as merged without changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
Conflict in CHANGELOG.md: both entries kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
…-notifies-voting-screens-only Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
|
Waiting for bot review — coderabbitai not yet · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
Waiting for bot review — coderabbitai not yet · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
…tifies-voting-screens-only The squash commit's tree equals the #1066 head this branch already contains, so it is recorded as merged without changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
|
Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
TL;DR
While the app refreshed name contests in the background, whatever screen you were on kept being reset: a lookup you had just started lost its spinner and its answer, search text you had typed disappeared, and amount fields flickered away. The refresh now only touches the voting screen; every other screen is left alone.
User story
As someone using the app while it keeps its voting data up to date in the background, I want the screen I am working on to stay exactly as I left it, so that a refresh I did not ask for cannot wipe what I typed or hide the answer I am waiting for.
Scenario
Open the app with at least one masternode loaded and wait until the background refresh of name contests starts (about a minute after launch, then every few minutes). While it runs, work on a screen that has nothing to do with voting: start a lookup on Tools ▸ Platform info, type a query on Contracts, or enter an amount on a form that adds funds to an identity.
Actual behavior
Several times a second, for as long as the refresh runs, the screen is told to start over. The Platform info result area falls back to "No results yet" and the answer never appears. Text typed into the Contracts query can be cleared. The amount field on the add-funds form can be replaced by "Checking the available amount…" for a moment, and keystrokes typed meanwhile can be lost.
Expected behavior
Nothing on those screens changes because of the background refresh. Masternodes ▸ Votes, the node cards, the Masternodes badge and the "needs your vote" indicators keep updating as the refresh progresses, exactly as before.
Detailed discussion
Builds on #1066 and #1067, which are merged.
Root cause
The contest refresh pass (
query_dpns_contested_resources) reported progress withTaskResult::Refresh— once per list page, after the end-time read, per contender read, and after the early vote proof.AppState::updateanswers everyTaskResult::Refreshwithrefresh()on the visible screen, whatever it is. That was harmless while a pass only ran behind a manual Refresh on the voting screen; since the pass also runs by itself on a timer, the notifications reach any screen the user happens to be on, and several screens treatrefresh()as "start over".Design
A dedicated notification,
TaskResult::DpnsContestsChanged, replaces the pass's fourTaskResult::Refreshsends.AppState::updatemerges it with adjacent cache notifications the same way it already merges refreshes, and answers it withrefresh()only when the visible screen is the Masternodes screen.Who needs to hear about contest data:
MasternodesScreenis the only screen that caches it: itsrefresh()reloads the node cards and the embedded voting panel. Votes sub-views and node pages are views inside this screen, not pushed screens.AppContextevery frame. The sender already requests a repaint, so they need nothing more.TaskResult::Refreshkeeps its meaning and its other senders are unchanged: identity refresh, owned-names refresh and token-balance refresh each send one notification when their task finishes, not a stream. The wallet event bridge sends onlyTaskResult::Repaint.Why a scoped notification rather than the alternatives: merging more aggressively still resets a screen once per frame; a typed success result would pass through every success hook and every screen's result handler; having the voting screen poll for changes would alter when and how that screen refreshes. This changes exactly one thing — who is told.
Of the symptoms above, the Platform info, add-funds and Contracts ones were reproduced on Testnet on a build without this change, each while a refresh was running; the Send amount field kept its digits there, so that one is predicted from the code only.
Unchanged: the pass's requests, their order and pacing, the early vote proof, what the voting screen does on each notification, and a pass started by Refresh on the voting screen. A voting screen that is hidden was not refreshed by the pass before and is not now; it re-reads on arrival.
Testing
a_pass_reports_contest_changes_without_refreshing_every_screen(lib) runs a pass against a mock SDK and asserts it sends the scoped notification and noTaskResult::Refresh.contest_notifications_do_not_refresh_a_screen_without_contest_data(kittest) puts a withdrawal form on screen, changes its identity in storage, feeds contest notifications through the app's result channel and asserts the form did not re-read; aTaskResult::Refreshthen makes it re-read, proving the probe detects a refresh.contest_notifications_update_the_open_votes_view(kittest) opens Masternodes ▸ Votes, caches a new open contest, sends one contest notification and asserts the contest appears.masternode_tabkittests and the contested-names and voting-panel lib tests pass unchanged.🤖 Generated with Claude Code
https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
🤖 Co-authored by Claudius the Magnificent AI Agent
PR Hygiene ·
ce968a8/skip-botsproceeds without the ones not yet reportedCHANGELOG.md,src/app.rs,src/backend_task/contested_names/query_dpns_contested_resources.rsand 1 more) — approved by lklimekWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.Summary by CodeRabbit