Skip to content

feat(platform)!: a contender's fund doubles for every 50 contenders a contest holds past 250 (PV14) - #5034

Merged
QuantumExplorer merged 2 commits into
v4.2-devfrom
claude/contender-cost-scaling-b06d12
Sep 27, 2026
Merged

QuantumExplorer merged 2 commits into
v4.2-devfrom
claude/contender-cost-scaling-b06d12

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

What this does: A contest (for example two or more people registering the same DPNS name) now charges more to join once many people have joined it. The first 250 contenders pay the normal contest fund (0.1 DASH for DPNS). From the 251st on, the fund doubles for every 50 contenders: 0.2 DASH for contenders 251 to 300, 0.4 for 301 to 350, 102.4 from the 701st, and 3,276.8 DASH for contenders 951 to 1,000 (the cap from #5029).

Value: Filling a contest to its 1,000 cap, so that nobody else can join it, now costs 327,695 DASH instead of 100 DASH; in practice a contest stops growing somewhere around 700 to 800 contenders. A normal contest with a handful of contenders pays exactly what it paid before.

Risks: Medium, consensus: this is a new protocol 14 rule. Wallets and SDKs still state the base fund, so they are refused when they try to join a contest that already holds 250 or more contenders, until they state the doubled fund; the refusal carries the fund needed. Contests that large are unusual. Contenders may also now state more than the fund (the extra goes to the contest's fund). No change before protocol 14.

Issue being fixed or feature implemented

#5029 capped a contest at 1,000 contenders. With a flat 0.1 DASH fund, anyone who wants a contested value can create 1,000 contenders for 100 DASH and lock everyone else out of the contest. The price of joining should rise steeply as a contest fills, so that filling one is not a practical strategy.

What was done?

Price (rs-platform-version, rs-dpp)

  • Two new fee schedule fields in VoteResolutionFundFees: contested_document_contenders_before_fund_doubling (250) and contested_document_contenders_per_fund_doubling (50) in VOTE_RESOLUTION_FUND_FEES_VERSION2 (FEE_VERSION3, protocol 14); both 0 ("never doubles") in VERSION1 and in the conversion from pre-4.2 platform states.
  • required_vote_resolution_fund_to_join(contract_id, document_type_name, contenders, platform_version) (and ContestedDocumentResourceVotePoll::required_vote_resolution_fund_to_join): the contest's fund (required_vote_resolution_fund, so the 0.5 DASH moderation election fund doubles the same way) while the contest holds fewer than 250 contenders, and fund * 2^(1 + (contenders - 250) / 50) from then on, saturating instead of overflowing. Doubling is exact in whole credits.

Validation (rs-drive-abci)

  • Document create state validation 2 already counts the contest's contenders for the 1,000 cap. After the cap check it now refuses, paid, a prefunded voting balance below the price for that count, with the existing DocumentContestNotPaidForError (expected = the price, paid = what was stated).
  • Document create structure validation 1 accepts a prefunded voting balance of at least the contest's fund; it wanted exactly it. The whole stated amount goes to the contest's prefunded balance, as before (drive operations and the balance check are unchanged: they already move whatever the transition states).
  • The contender states what it pays, so an identity is never charged more than it signed for.

Before / after (protocol 14, DPNS):

Contest already holds Before After
0 to 249 contenders 0.1 DASH, exactly 0.1 DASH or more
250 to 299 0.1 DASH 0.2 DASH or more; 0.1 refused with DocumentContestNotPaidForError
300 to 349 0.1 DASH 0.4 DASH or more
700 to 749 0.1 DASH 102.4 DASH or more
950 to 999 0.1 DASH 3,276.8 DASH or more
Cost to fill 1,000 100 DASH 327,695 DASH

Docs: book/src/data-model/contested-documents.md (price table), PV14 changelog note 51 in v14.rs, comments in DRIVE_ABCI_VALIDATION_VERSIONS_V10.

In-place changes to shipped generations

  • VOTE_RESOLUTION_FUND_FEES_VERSION1 gains the two new fields set to 0. Only document create state validation 2 reads them, and that is selected by protocol 14 alone. Platform states store only a fee version number, and the frozen VoteResolutionFundFeesFieldsBeforeVersion4 is untouched, so no stored format changes.
  • Document create structure validation 1 and state validation 2 are edited in place; both are selected only by DRIVE_ABCI_VALIDATION_VERSIONS_V10 (protocol 14, unreleased).

How Has This Been Tested?

  • rs-dpp contested_document_resource_vote_poll::fund_to_join_tests: the price at 0, 249, 250, 299, 300, 699, 700, 950 and 999 contenders, a 327,695 DASH fill, the moderation election fund (16,384 DASH for the last contender), saturation; the _protocol_version_13 twin shows no doubling.
  • rs-drive-abci creation_tests:
    • should_double_the_fund_a_contender_pays_once_a_contest_holds_250_contenders: at 250 contenders, 0.1 DASH is refused (paid, expected 0.2) and the fund is untouched; 0.2 DASH joins and the contest's fund grows by exactly 0.2 DASH. Its _protocol_version_13 twin accepts the flat fund.
    • should_put_everything_a_contender_pays_into_the_contest_fund: 0.15 DASH stated, 0.15 DASH lands in the fund.
    • should_refuse_a_contender_past_the_most_a_contest_accepts (from fix(drive-abci)!: cap a contest at 1,000 contenders and tally every one (PV14) #5029): the 1,000th contender now pays 32,768 times the fund; the 1,001st is still refused by the cap.
  • advanced_structure_v1 tests: "at least" at protocol 14, "exactly" at 13, for DPNS and moderation elections.
  • cargo test -p platform-version --lib, and the drive-abci creation, voting, masternode vote, owner balance proof and action fee groups: 230 passed. cargo clippy -p platform-version -p dpp -p drive-abci --all-targets -- -D warnings clean.

Breaking Changes

Consensus change at protocol 14: joining a contest that holds 250 or more contenders requires a larger prefunded voting balance, and a prefunded voting balance above the contest's fund is now accepted. SDKs build contested creates with the base fund (DocumentCreateTransition::from_document), so they need to state the doubled fund to join such a contest (follow-up).

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 added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

PR Hygiene · 1d09319

  • Bots — coderabbitai not yet · thepastaclaw not yet — /skip-bots proceeds without the ones not yet reported
  • Self-review — post /self-reviewed once the bots are done
  • Within your 5 open PRs
  • Build running
  • Approvals — you own every area touched; none needed

When every box is checked the PR Hygiene check passes and this can merge.

…s a contest holds (PV14)

Joining a contest now costs the contest's fund doubled for every 100
contenders it already holds: 0.1 DASH for the first 100 DPNS contenders,
0.2 for the next 100, up to 51.2 for the 901st to the 1,000th. Filling a
contest to its 1,000 cap costs 10,230 DASH instead of 100.

The contender states the fund it pays in its prefunded voting balance,
as before. Create state validation 2 counts the contest's contenders
(the read #5029 added for the cap) and refuses, paid, a stated fund
below the price (DocumentContestNotPaidForError, carrying the price).
Create structure validation 1 accepts a stated fund of at least the
contest's fund instead of exactly it. Everything stated goes to the
contest's fund. The step, 100, is contested_document_contenders_per_fund_doubling
in FEE_VERSION3; earlier schedules carry 0, which never doubles.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added this to the v4.2.0 milestone Sep 27, 2026
@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Sep 27, 2026
@github-actions

github-actions Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

📖 Book Preview built successfully.

Download the preview from the workflow artifacts.
To view locally: download the artifact, unzip, and open index.html.

Updated at 2026-09-27T05:36:40.270Z

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: dashpay/platform/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 1f994336-bd88-4b78-a68b-848ce112e8b1

📥 Commits

Reviewing files that changed from the base of the PR and between f4426b2 and 0c73231.

📒 Files selected for processing (11)
  • book/src/data-model/contested-documents.md
  • packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_create_transition_action/advanced_structure_v1/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_create_transition_action/state_v2/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/creation.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/mod.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v10.rs
  • packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/mod.rs
  • packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v1.rs
  • packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/v2.rs
  • packages/rs-platform-version/src/version/v14.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Protocol version 14 scales the required contested-document fund with the number of existing contenders. Document-creation validation checks the amount paid, accepts overpayment, and reports underpayment. Fee configuration, tests, and documentation are updated for the new rule and the unchanged pre-version-14 behavior.

Changes

Contested-document funding

Layer / File(s) Summary
Configure and calculate join funds
packages/rs-platform-version/src/version/fee/vote_resolution_fund_fees/*, packages/rs-platform-version/src/version/v14.rs, packages/rs-dpp/src/voting/vote_polls/contested_document_resource_vote_poll/mod.rs
Fee configuration adds a contender threshold for doubling. The join-fund calculation applies the configured interval, saturates multiplication, and returns Credits::MAX on exponent overflow. Protocols 1–13 retain the base fund; version 14 configures doubling every 100 contenders.
Validate contested-document prefunding
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_create_transition_action/advanced_structure_v1/mod.rs, packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/document/document_create_transition_action/state_v2/mod.rs, packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v10.rs
Structure validation accepts prefunding at or above the required amount. State validation checks the required fund for an existing contest and returns DocumentContestNotPaidForError when the paid amount is too low.
Exercise and document contest funding
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/mod.rs, packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/creation.rs, book/src/data-model/contested-documents.md, packages/rs-platform-version/src/version/v14.rs
Test helpers can set and sign a prefunded balance. Tests cover underpayment, overpayment, contender-count boundaries, and protocol 13 behavior. Documentation describes the version 14 fund schedule.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant DocumentCreateTransitionValidation
  participant required_vote_resolution_fund_to_join
  participant VoteResolutionFundFees
  DocumentCreateTransitionValidation->>required_vote_resolution_fund_to_join: provide contest details and contender count
  required_vote_resolution_fund_to_join->>VoteResolutionFundFees: read fund-doubling interval
  VoteResolutionFundFees-->>required_vote_resolution_fund_to_join: return configured interval
  required_vote_resolution_fund_to_join-->>DocumentCreateTransitionValidation: return required fund
  DocumentCreateTransitionValidation->>DocumentCreateTransitionValidation: compare paid amount with required fund
  Note over DocumentCreateTransitionValidation: If underfunded, return DocumentContestNotPaidForError
Loading

Suggested reviewers: pastapastapasta

Merge Risk: ⚪ Minimal · up to 0c732

The checked compatibility paths preserve older contest counting and payment rules. No identified issue blocks merging after normal checks.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 0c732

The higher price makes filling a contest more expensive, but multiple joins submitted together may be charged using the same earlier contender count. That could weaken the protection against filling a contest to exclude others. The extent of this path and its transaction limits remain unverified.

Retained concerns

  • Medium · security · inferred: Multiple creates for one existing contest in a batch may each be priced against the same pre-batch contender count, allowing joins across a doubling threshold at the earlier price.
Security review details

Security Blast Radius

  • inferred — The independently attackable target is an existing contested value: a funded submitter can attempt multiple document creates against its shared contender count. The effective batch-size limit and resulting maximum discount were not established.

Security Findings and Attack Paths

  • inferred — At a doubling boundary, two creates validated before either is stored may both satisfy the earlier price, undermining the increased cost of filling that contest. End-to-end acceptance of such a batch remains unverified.

Trust Boundaries and Controls

  • observed — The submitted prefund and poll cross from a document transition into consensus validation. The validator checks the poll against the document type, retains prior state checks, and compares the supplied amount with a requirement computed from stored contest state.

Resilience and Maintainability Implications

  • inferred — Because the price depends on mutable contender state, validation must account for earlier accepted joins to the same poll in a batch as well as joins already in storage. Individual-create tests do not establish that batch invariant.

Hardening Proposals

  • proposed — Account for accepted, pending joins per poll when validating a batch, and verify threshold-crossing batches against the amounts ultimately debited and credited.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 69.23% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 10 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title identifies the protocol 14 contender-fund doubling change and is concise, but it states incorrect thresholds. The changes use doubling every 100 contenders, starting after the first 100, not…
Full details: Docstring Coverage

Explanation

Docstring coverage is 69.23% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 10 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ 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

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

Comment @coderabbitai help to get the list of available commands.

@thepastaclaw

thepastaclaw commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

🕓 Queued for automated review — 2nd in line, estimated start in ~25 min (commit 1d09319)
Estimated review time once started: ~1.0 h (two-phase automated review; median of recent runs).

  • Request priority review — click to move this review to the front of the queue.

…ouble it every 50

The first 250 contenders of a contest pay its fund; from then on the fund
doubles for every 50 more: 0.2 DASH for the 251st to the 300th DPNS
contender, 102.4 DASH from the 701st, 3,276.8 DASH for the 951st to the
1,000th. Filling a contest to its cap costs 327,695 DASH, so in practice a
contest stops growing long before it.

The fee schedule gains contested_document_contenders_before_fund_doubling
(250 in FEE_VERSION3, 0 before) beside contested_document_contenders_per_fund_doubling
(now 50).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@QuantumExplorer QuantumExplorer changed the title feat(platform)!: a contender's fund doubles for every 100 contenders a contest holds (PV14) feat(platform)!: a contender's fund doubles for every 50 contenders a contest holds past 250 (PV14) Sep 27, 2026
@QuantumExplorer
QuantumExplorer merged commit 5febda1 into v4.2-dev Sep 27, 2026
17 of 18 checks passed
@QuantumExplorer
QuantumExplorer deleted the claude/contender-cost-scaling-b06d12 branch September 27, 2026 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-bots Waiting for the review bots to report on this head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants