Repository navigation
fix(platform)!: end a contest without a winner when the award has no room (PV15) - #5859
QuantumExplorer wants to merge 2 commits into
Conversation
…room (PV15) A contender's document waits in its contest's area, where the checks a document create runs do not see it. A contract registered before protocol version 15 can keep a contest its index values do not decide, and a document created outside such a contest while the chain ran protocol version 14 still holds the contest's index values when the contest ends. award_document_to_winner 1, selected by the protocol version 15 table, runs the two checks of a document create on the winner's document before inserting it: no document holds its id, and no document holds its unique index values (read only when the entry is one Drive shares). When one fails it inserts nothing and the contest is recorded without a winner and cleaned up like any other. Otherwise it calls version 0 unchanged. check_for_ended_vote_polls 1 is edited in place to read the award's answer. Protocol version 14 selects award version 0, which always inserts or returns the insert's error, so nothing changes there. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 30 minutes. View limit details
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. |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
🔍 Review in progress — actively reviewing now (commit 724d951) · triage: normal |
|
📖 Book Preview built successfully. Download the preview from the workflow artifacts. Updated at 2026-11-11T13:03:24.958Z |
Conflict in packages/rs-platform-version/src/version/v15.rs: two adjacent table row comments, one changed on each side. Kept both. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
Basic explanation
What this does: When a contest over a document (a DPNS name, for example) ends, the winner's document is moved out of the contest's area and stored with the ordinary documents of its type. This change makes that step look first: is there already a document with the same id, or one holding the same unique index values? If so, nothing is stored and the contest is recorded as ended without a winner. Otherwise the document is stored exactly as before.
Value: A contest always ends with a recorded result at its end date, whatever documents its type holds by then. This covers contests on contracts registered before protocol version 15 that were opened before the create checks of #5744 applied.
Risks: Low. This is a consensus change, active only from protocol version 15, which is unreleased. One module that protocol version 14 also uses is edited in place; the edit cannot change anything at protocol version 14 (see "In-place changes to shipped generations"). In the one case the new path covers, the leading contender does not receive the document and its prefunded balance is spent like a losing contender's. Every awarded contest pays two extra reads at its end. No slow or flaky tests.
Issue being fixed or feature implemented
A contender's document waits in the contest's area, where the checks a document create runs do not see it. Only checks run on other creates while the contest is live keep its place free.
#5744 added those checks for protocol version 15: registration refuses a contest its index values do not decide, and a create outside such a contest, on a contract registered earlier, is refused while the contest is live. A document created while the chain ran protocol version 14 is not covered by either: it still holds the contest's index values when the contest ends at protocol version 15. The award had no answer for that state.
What was done?
award_document_to_winner1 (packages/rs-drive-abci/src/execution/platform_events/voting/award_document_to_winner/v1/mod.rs), selected byDRIVE_ABCI_METHOD_VERSIONS_V11(protocol version 15). It runs the two checks of a document create on the winner's document, then calls version 0 unchanged:Drive::validate_moderated_document_uniqueness, the document-based uniqueness check). This is read only when the entry is one Drive shares between documents (unique_index_entry_is_shared); an entry kept under the document's id meets no other.check_for_ended_vote_polls1 recordsContestedDocumentVotePollWinnerInfo::NoWinnerwhen the award answers no. The contest is then cleaned up like any other: contenders and votes removed, the prefunded balance emptied, the stored status back toNotStarted(orLockedif it was locked before).v15.rs, theDRIVE_ABCI_METHOD_VERSIONS_V11doc and row comment, and the contested keyword page of the book.Before and after
A contract registered at protocol version 14 with a contested index over
[normalizedParentDomainName, normalizedLabel]whosefieldMatchesreadslabel. State when the contest over("dash", "quantum")ends at protocol version 15:A contest whose index values no document holds is awarded as before (
Awarded(A)).In-place changes to shipped generations
check_for_ended_vote_polls/v1/mod.rsis selected by protocol versions 14 and 15. The edit replaceswith
Protocol version 14 selects
award_document_to_winner0, whose dispatcher arm returnsOk(true)or the insert's error, so theelsebranch is unreachable there and the outcome is identical.should_find_the_awarded_entry_taken_at_protocol_version_14runs the module at protocol version 14 and still sees the same result as before this change.check_for_ended_vote_polls/v0(protocol versions 1 to 13) is not edited; it ignores the returned value.How Has This Been Tested?
Four tests added to
contest_decided_by_index_valuesinpackages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/mod.rs:perform_events_on_first_block_of_protocol_changeto the latest version: ends without a winner;"\0"beside"");The three "without a winner" tests fail when version 1 is routed to version 0.
Run locally:
cargo test -p drive-abci --lib contest_decided_by_index_values(15 tests)cargo test -p drive-abci --lib masternode_vote::(107 tests),clean_up_after_contested_resources_vote_polls_end,contested_index_mismatch_chain_haltcargo test -p platform-versioncargo clippy -p drive-abci --lib --tests,cargo fmt --allThe full drive-abci suite and the strategy tests were left to CI.
Breaking Changes
Consensus change from protocol version 15: a contest whose winner's id or unique index values a document already holds ends without a winner. Protocol version 14 and earlier are unchanged.
Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
724d951/skip-botsproceeds without the ones not yet reported/self-reviewedWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.