Repository navigation
fix(dpns): fetch every contest that ends at a page boundary - #1164
Conversation
The end-date index limit counts vote polls, not end times, so a page of 100 can stop partway through the polls ending at its last end time. Starting the next page strictly after that time dropped the rest, and those contests got no end time. Proved queries refuse an offset, so the next page now re-reads the boundary time (the name map dedupes) and moves strictly past it once a page holds nothing newer. Every step advances, so the walk ends even when more polls share one end time than a page holds (logged as a warning). It also no longer sends the invalid excluded start at the range end that the platform rejects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WunYYhY7P2FJqHVgkHiXtT
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WunYYhY7P2FJqHVgkHiXtT
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Page filtering and metadata src/backend_task/contested_names/query_ending_times.rs |
The page parser records contest names only for polls matching the DPNS contract and domain document type. It tracks the latest end time and poll count across all polls. |
Pagination boundaries src/backend_task/contested_names/query_ending_times.rs |
Query bounds use a page start and an explicit upper timestamp. The next-page logic rereads later timestamps inclusively and advances past an already-included start exclusively. |
Page walk and validation src/backend_task/contested_names/query_ending_times.rs |
The query accumulates page results and warns if a full page cannot advance. Tests cover filtering, page cuts, same-time polls, empty pages, and range-end handling. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Possibly related issues
- feat(dpns): sell, buy and transfer usernames through the platform-wallet marketplace #1103: The query supplies DPNS username contest results and now handles pagination boundaries that could omit results.
Possibly related PRs
- dashpay/dash-evo-tool#1153: This PR continues the changes to
query_dpns_ending_timesby addressing inclusive boundaries and polls with the same end time.
Suggested reviewers: pauldelucia, lklimek
Merge Risk: 
Minimal · up to 95938
-
No identified issue blocks merging. Run the normal tests and platform checks before release.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title "fix(dpns): fetch every contest that ends at a page boundary" matches the main change. The PR changes DPNS contest end-time paging so that polls sharing an end time at a page cut are not omitted. The raw summary confirms the inclusive re-read of the last end time and the advance-past logic. The title is specific and concise, and it follows the conventional commit style. It names the DPNS scope and the boundary case. The title does not mention the DPNS-only filtering or the upstream limitation, but those are secondary details.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 1 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- 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.
Comment @coderabbitai help to get the list of available commands.
|
⛔ Final review complete — 1 blocking finding(s) (commit 95938c7) |
…early An empty end-time tree takes a page slot but returns no row, and proved queries refuse an offset. A page holding only such trees therefore comes back empty and ends the walk before the polls behind them, and no request can page past them. Getting past them needs an upstream change, so the behaviour stays as it is. A TODO(upstream) in next_page_start records the limit, and a comment on the test that pins this behaviour points to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WunYYhY7P2FJqHVgkHiXtT
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WunYYhY7P2FJqHVgkHiXtT
The end-date index lists the contested polls of every contract, so a contest on another contract could be recorded as a contested username. Keep only polls on the DPNS domain document type. Polls of other contracts still advance the page start, or a page holding only them would end the walk early. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WunYYhY7P2FJqHVgkHiXtT
|
Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 2 only (no Phase 1 for this repository)
The paging and DPNS-domain filtering changes correctly address the new cross-contract contamination path and boundary paging behavior. However, the persistence layer only accepts end times that advance the cached value, so records contaminated by the old parser can retain a later foreign-contract deadline indefinitely and continue showing an incorrect contest deadline.
🔴 1 blocking
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.1-sol(effort low) — This is a contained but nontrivial change to pagination and termination logic for DPNS contest end-time queries, without affecting consensus, funds, cryptography, key handling, peer-facing deserialization, or storage migrations. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `src/backend_task/contested_names/query_ending_times.rs`:
- [BLOCKING] src/backend_task/contested_names/query_ending_times.rs:122-126: Filtering new pages does not repair previously persisted cross-contract end times
The new filter prevents future foreign-contract polls from entering `contests_end_times`, but it does not repair values written by the previous implementation. Before this change, the parser stored polls from every contract under the shared `det:contested_name:<name>` key. `update_contested_name_ending_times` only writes a value when it is greater than the stored end time (or when no value exists), so a previously stored later deadline from another contract remains when the current DPNS deadline is earlier. The cache then continues to show the contest as open past its actual DPNS deadline. Add a migration or refresh path that can rebuild or clear legacy end times using authoritative DPNS data, while preserving a valid newer DPNS value rather than blindly replacing it with stale data.
No migration here, it's overengineering - this data will become outdated/refreshed soon anyway.
|
Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
/skip- |
|
/skip-bots |
|
Policy satisfied — this can merge. |
TL;DR: Some contested usernames showed no end time when many contests ended at the same moment, and in one rare case the whole end-time refresh failed. Every contest in the window now gets its end time, and the refresh no longer fails when a contest ends exactly at the edge of the time window it looks at.
User story
As a masternode operator voting on DPNS contests, I want every open contest to show when it ends, so that I can vote before the deadline instead of guessing.
Scenario
Detailed discussion
Verified against platform
575d961(the pinned rev):VotePollsByEndDateDriveQuery::construct_path_queryreads a range of end times with a subqueryinsert_allandSizedQuery { limit, offset: None }. The GroveDB limit counts subquery result slots (polls), not end times.offseton proved queries (RequestingProofWithOffset), and the SDK always requests proofs. Paging by offset is therefore not possible.execute_no_proof_empty_end_times). A cut page can therefore hold fewer than 100 polls, so checking whether a page is full is not a reliable signal.The end-date index also lists contests of every other contract, and the old parser recorded them as usernames.
dpns_end_times_pagenow keeps only polls on the DPNSdomaindocument type. Polls of other contracts still count towards the page's last end time and poll count, or a page holding only them would end the walk.The fix is a pure
next_page_start(page_start, page_last_end_time, range_end):Tests: unit tests for the decision, plus a walk over an in-memory index that follows the platform's slot-limit rules. They cover a page cut in the middle of an end time, more polls at one end time than the limit, empty pages, stale pages, a poll at the range end, and empty end-time trees taking slots. Six of the eight failed on the old behaviour.
Also fixed: a poll ending exactly at the range end made the next request start strictly after the range end, which the platform rejects, so the whole refresh failed. The walk now stops before sending that request.
Known upstream limit: when more than 100 polls end at the same millisecond, the polls past the 100th cannot be fetched, because proved queries reject an offset. The app logs a warning, and a
TODO(upstream)marks the spot.Known upstream limit: the page limit also counts empty end-time trees, which a proved page never returns, so a page made only of such trees comes back empty and ends the walk early. The app cannot page past them without upstream support; a
TODO(upstream)marks the spot.Hard-coded test seeds in
backend_task/identity/mod.rs(also found in the #1153 review) are not changed here: draft #1163 already replaces them with runtime-generated seeds.Merging with #1153: this PR changes only the end of the paging loop and leaves the page-parsing arm alone. When #1153 lands,
next_page_starttakespage.last_end_time(the latest time of any poll, including yes/no polls) where it now takes the latest DPNS name time.Attribution
🤖 Co-authored by Claudius the Magnificent AI Agent
🤖 Generated with Claude Code
https://claude.ai/code/session_01WunYYhY7P2FJqHVgkHiXtT
PR Hygiene ·
95938c7src/backend_task/contested_names/query_ending_times.rs) — 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