Skip to content

refactor(dpp): restore shipped registration_cost v1 index parsing - #5055

Merged
QuantumExplorer merged 1 commit into
v4.2-devfrom
claude/registration-cost-v1-fixed-grammar
Sep 27, 2026
Merged

QuantumExplorer merged 1 commit into
v4.2-devfrom
claude/registration-cost-v1-fixed-grammar

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

What this does: the fee for registering a data contract is computed by a versioned function. Version 1 of it is used by protocol versions 2 to 13 (already live). During 4.2 development a check was added inside version 1 that asks "which protocol version's index features are allowed?", to bill new kinds of indexes. Protocol version 14 has since moved to version 2 of the fee function, so inside version 1 that check now always answers "none of the new features", which is exactly what the old code did. This PR puts version 1 back to the code that shipped in v4.1.0, byte for byte.

Value: code that already ran on the network looks the way it shipped, and nobody reading version 1 is misled into thinking it can bill new index kinds. Our rules ask for this: a version check inside a shipped generation is the pattern the book warns against.

Risks: Very low. The fee is identical at every protocol version that uses version 1 (the removed check always produced "no new index features", which is what Index::try_from parses with). Version 2, used by protocol version 14, is untouched.

Issue being fixed or feature implemented

book/src/versioning/versioned-dispatch.md: "Inside a generation, a capability is a constant fact, not a check", and a dead version check inside a shipped generation "misleads the next reader into thinking v1 can take that path". registration_cost v1 had carried IndexGrammarAdmissions::for_schema_generation(document_type_schema) since #4266, when protocol version 14 still selected v1. Since #4827, protocol version 14 selects v2, and every version that selects v1 has document_type_schema 0, 1 or 2, for which the mapping returns all false.

What was done?

packages/rs-dpp/src/data_contract/methods/registration_cost/v1/mod.rs is restored to its v4.1.0 content: the index parse is Index::try_from(index_value_map.as_slice()) again, which calls Index::try_from_value_map with all admissions false.

Before / after (unchanged outcome):

protocol version 13 (document_type_schema 2), a contract with a unique index
before: for_schema_generation(2) -> all false -> Index parsed -> unique index fee billed
after:  Index::try_from          -> all false -> Index parsed -> unique index fee billed

In-place changes to shipped generations

  • registration_cost v1, selected by protocol versions 2-13 (contract version tables v2-v5, document_type_schema 0, 0, 1, 2). The edit replaces for_schema_generation(document_type_schema) with the all-false admissions Index::try_from uses; the mapping returns all false for every generation below 3, so the parsed index, and the cost, are identical at every version that selects v1. The file is now byte-identical to v4.1.0.

How Has This Been Tested?

cargo test -p dpp --lib registration_cost, cargo clippy -p dpp --all-features --all-targets -- -D warnings. git diff v4.1.0 -- packages/rs-dpp/src/data_contract/methods/registration_cost/v1/mod.rs is empty.

Breaking Changes

None.

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 · 126e566

  • Bots — coderabbitai skipped after its own rate limit · thepastaclaw ✓
  • Self-review — post /self-reviewed
  • Within your 5 open PRs
  • Build green
  • Approvals — you own every area touched; none needed

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

registration_cost v1 is selected by protocol versions 2-13. #4266 made it
read the ranked and timeRange index admissions from the table's
document_type_schema so that protocol version 14, which then selected v1,
billed those indexes. #4827 moved protocol version 14 to v2, which carries
the same logic, leaving a version check in v1 that is always false for the
versions that select it (document_type_schema 0-2 admit nothing). Restore
the file to what shipped in v4.1.0: Index::try_from parses with the same
all-false admissions, so the cost is identical at every version that
selects v1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 21 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

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

Review profile: CHILL

Plan: Advanced

Run ID: b36c6483-9b8d-4646-a378-a89e0d64becb

📥 Commits

Reviewing files that changed from the base of the PR and between 4d4f38d and 126e566.

📒 Files selected for processing (1)
  • packages/rs-dpp/src/data_contract/methods/registration_cost/v1/mod.rs

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.

@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 added this to the v4.2.0 milestone Sep 27, 2026
@thepastaclaw

thepastaclaw commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 126e566) · triage: low · Phase 2 only (queue backlog)

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 2 only (queue backlog)

Verified the complete diff at 126e566 and confirmed the Phase-2 reviewers' conclusion: the restored parser supplies identical all-false admissions for every protocol version selecting registration_cost v1, the file matches v4.1.0 byte-for-byte, and PV14's v2 implementation remains unchanged. The tables select v1 for PV9–13, not PV2–13 as the PR description states; this does not affect the behavior-preservation argument. No in-scope defects were found; git diff --check passed, and tests were not rerun during verification.

Review provenance

Source: reviewer 1: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: platform-versioning); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)

  • Triage: low by gpt-6-astra (effort low) — The diff is a small, single-file restoration of registration_cost v1 index parsing whose correctness is straightforward to confirm by checking that all protocol versions selecting v1 use the same all-false admissions as Index::try_from.
  • Phase 1 reviewers: not run (skipped for throughput: 11 PRs queued, above the 10 limit)
  • Fresh verifier: gpt-6-astra — final-verifier; agent astra-verifier
  • Phase 2 reviewers: gpt-6-astra — general (completed, effort medium); agent phase2-reviewer, gpt-6-astra — architecture-layering (completed, effort medium); agent phase2-reviewer, gpt-6-astra — platform-versioning (completed, effort medium); agent phase2-reviewer

@github-actions

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. and removed waiting-bots Waiting for the review bots to report on this head labels Sep 27, 2026
@QuantumExplorer
QuantumExplorer merged commit b33aba1 into v4.2-dev Sep 27, 2026
33 of 34 checks passed
@QuantumExplorer
QuantumExplorer deleted the claude/registration-cost-v1-fixed-grammar branch September 27, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. waiting-self-review Waiting for the author to post /self-reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants