Repository navigation
fix(drive): prove decision proposal creates as plain documents, found by a new strategy test - #5696
Conversation
…ored The prover and the client verifier both looked for a create's document in the contest area whenever the create stated a fund. A decision proposal (protocol version 15) states the decision proposal fund, but it opens a yes/no poll and is stored as any document is, so the proof of a proposal create looked in the wrong place and a client waiting for the result could not find the proposal it had just created. `SingleDocumentDriveQueryContestedStatus::of_document_transition` now decides where a transition's document is stored, for both: contested for a create stating a fund, except a decision proposal. Only creates of the decision proposals contract change, and that contract exists from protocol version 15 only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ge flags A document of a type keeping history stores each revision with the document's storage flags, the owner's when the owner paid. The structure description allowed a revision no flags only, so the conformance check of a chain holding such documents failed. Decision proposals keep their history and are the first strategy fixture to write them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng chain A strategy test at protocol version 15: four identities open eight proposals in one block, three ending on the end date of a DPNS contest opened the block before, the others one to four weeks out. Masternodes answer every proposal and vote on the contest for four weeks of daily blocks, the strategy verifying the proof of every create and vote. It checks that each proposal opens its poll with exactly the decision proposal fund, filed under its end date beside the contest; that due polls close in end date order, at most `maximum_vote_polls_to_process` a block, the contest's included (so the proposal due half a day after the contest waits a block); that each result follows from the poll's rule and tallies, with polls passing, failing on the answers and failing short of turnout; that the rest of each fund is spent and the end date index emptied; and that the proposals stay. Strategies gain `OperationType::YesNoVote`, appended last so saved strategies still decode. It answers a yes/no poll with weighted answers, skipping an answer the masternode already gave, one past its allowance, a second answer in the same block (the proof is checked against the state the block leaves) and any vote once the poll is due. The masternode vote signing the contested votes used is shared with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🌳 GroveDB structure This pull request changes the described GroveDB structure. Open it in the structure viewer: new nodes glow, removed ones stay as ghosts, and the tour walks through each change. Changed (1 node)
Compared |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Weighted vote operations packages/strategy-tests/src/operations.rs |
Adds a weighted yes/no/abstain operation and serialization support. The existing weighted-choice method now uses a shared helper. |
Document contested-status classification packages/rs-drive/src/query/single_document_drive_query.rs, packages/rs-drive/src/prove/prove_state_transition/v0/mod.rs, packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs, packages/rs-drive/src/drive/document/structure.rs, packages/rs-drive/grovedb-structure.json |
Adds a shared classifier that excludes decision proposals from contested creates. Proof generation and verification use it. Revision flag metadata describes epoch-owned and absent flags. |
Strategy vote generation packages/rs-drive-abci/tests/strategy_tests/strategy.rs |
Generates eligible yes/no votes before poll end dates. Resource and yes/no votes use a shared helper to construct masternode vote transitions. |
Proposal poll setup and indexing packages/rs-drive-abci/tests/strategy_tests/test_cases/voting_tests.rs |
Adds a chain test that creates DPNS contenders and decision proposals, then checks poll dates, funding, and end-date index entries. |
Proposal voting and resolution checks packages/rs-drive-abci/tests/strategy_tests/test_cases/voting_tests.rs |
Runs daily contest and proposal voting. Checks outcomes, closing order and capacity, and final index and document state. |
Estimated code review effort: 3 (Moderate) | ~25 minutes
Possibly related issues
- Decision proposals: anyone opens a masternode yes/no vote for 0.5 Dash (5.1, protocol 15) #5679: The changes to decision-proposal contested-status classification and revision flag metadata match the issue’s proof-lookup and storage-flag objectives.
Suggested reviewers: lklimek, pastapastapasta, shumkov
Merge Risk: 
Minimal · up to a66e8
-
Decision proposal creates are now classified as plain documents when their proof is located, and the shared classifier keeps proof generation and verification consistent. The other changes are a documentation-level structure update and new strategy tests. I see no concrete merge-blocking risk.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title names the two main fixes: proof handling for decision proposal creates and a new strategy test that surfaced them. The changeset matches this. Its files change the proof and verification logic so decision proposal creates are treated as plain documents, add a strategy test that runs decision proposals alongside a DPNS contest, and fix the grovedb structure description for document revisions. The title is specific and omits the structure fix, which is expected for a title.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 62.50% 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 8 functions across 7 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
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.
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
🕓 Review not started yet because the new head is waiting for the 30-minute push debounce.
Commit a66e85c. Normal review starts when eligible; priority review starts as soon as a slot is available. |
Basic explanation
What this does: It runs decision proposals (protocol version 15, #5684) in a simulated chain next to a DPNS name contest, for four weeks of blocks. The run found two problems, both fixed here.
What the test found:
Before and after, for a client creating a proposal and waiting for the result:
Value:
maximum_vote_polls_to_process), contests included. So four polls due at the same time close over two blocks, and a poll due just after waits behind them.Risks:
OperationType::YesNoVoteis appended last, so saved strategies (for example Dash Evo Tool's) still decode. A client matchingOperationTypeexhaustively needs one more arm.Issue being fixed or feature implemented
The strategy test on the test list of #5679 that #5684 left out: many proposals and votes on end dates shared with DPNS contests. Writing it found the two bugs above.
What was done?
Proof of a proposal create (
rs-drive)SingleDocumentDriveQueryContestedStatus::of_document_transitiondecides where a transition's document is stored: contested for a create stating a fund, except a decision proposal (dpp::decision_proposal::is_decision_proposal).prove_state_transitionv0 andverify_state_transition_was_executed_with_proofv0 both call it, in place of two identical inline checks.Structure description (
rs-drive)contracts.contract.documents.document_type.primary_key.document.revisionallowsEpochOwnedflags as well as none, like the document node above it.grovedb-structure.jsonis regenerated (5 lines).Yes/no votes in strategies (
strategy-tests, drive-abci strategy runner)OperationType::YesNoVote(YesNoVoteOp { vote_poll_id, end_date, vote_choices_with_weights }). Each hit picks a random masternode and a weighted answer, and skips a vote that would be refused or could not be checked:The contested-vote branch and this one share the masternode vote signing (
signed_masternode_vote). The weighted pick is shared too (choose_weighted), and draws from the random generator exactly as before, so existing strategy outcomes do not move.The test
run_chain_with_decision_proposals_closing_beside_a_dpns_contest, at protocol version 15:It checks:
DecisionProposalVotePoll::from_proposal, the function consensus uses) and holds exactly 0.5 Dash;maximum_vote_polls_to_processper block, the contest included. A poll closes in the first daily block at or after its end date that has room, and every block it waits through closes the maximum, none of them due later than it. Here the four polls due on the contest's end date take two blocks, and "Two weeks and a half day" waits one block behind them;passedfollows from the rule (yes strictly above the percent of yes plus no, and yes plus no reaching the minimum), matchingYesNoVotePoll::passes;How Has This Been Tested?
cargo test -p drive-abci --test strategy_tests test_cases::voting_tests),strategy-testsunit tests pass.rs-drive: the new unit test ofof_document_transition(a contested create, a plain create, a proposal), the verify/prove/single document tests (520 passed), and the structure tests with the regenerated JSON (11 passed).drive-abcilibrary tests for decision proposals and contested resources (49 passed).cargo clippy -p drive -p strategy-tests -p drive-abci --testsis clean;cargo fmt --all.In-place changes to shipped generations
prove_state_transitionv0verify_state_transition_was_executed_with_proofv0Breaking Changes
None to the protocol.
strategy_tests::operations::OperationTypegains a variant (appended last, so serialized strategies still decode).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 ·
a66e85c/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.Summary by CodeRabbit