Skip to content

refactor(dpp): remove the empty moderation charter validation step - #4970

Merged
QuantumExplorer merged 1 commit into
v4.2-devfrom
claude/cleanup-validate-charter-error-a81149
Sep 24, 2026
Merged

QuantumExplorer merged 1 commit into
v4.2-devfrom
claude/cleanup-validate-charter-error-a81149

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Once #4957 (maxBytes) and #4962 (propertyConstraints) moved the last proposal rules into the moderation charters contract's schema, the charter-specific validation step was left with nothing to check:

  • SubmittedCharter::validate dispatched on dpp.validation.data_contract.validate_moderation_charter to a v0 that always returned an empty, valid result.
  • validate_submitted_charter read the proposal's properties, then called that empty step.
  • Error 11001 (ModerationCharterRewardSplitNotOneHundredError) is never produced: the reward split is held to 100 by the contract's rewardSplitIsWhole rule (10422).

Nothing outside rs-dpp's own tests called validate_submitted_charter or SubmittedCharter::validate. Drive ABCI reads a seated charter with ElectedCharter::from_document_properties and the moderators share straight from the stored proposal.

What was done?

  • Removed SubmittedCharter::validate, its moderation_charter/v0 module and validate_submitted_charter from rs-dpp.
  • Removed the validate_moderation_charter field from DataContractValidationVersions and from DPP_VALIDATION_VERSIONS_V1, V2, V3 (all None) and V5 (Some(0)).
  • Error 11001 stays. BasicError is bincode-encoded positionally and two variants follow it (DocumentPropertyMaxBytesExceededError at 198, DocumentPropertyConstraintViolatedError at 199), so removing it would shift their wire discriminants. Its doc comment now says no check produces it.
  • Updated the docs that named the removed function: the module doc, protocol version 14 items 37 and 39 in v14.rs, and docs/protocol/moderation-charters.md.
  • Removed first_basic_error from the charter tests; nothing had called it since the reward split and description checks moved to the schema.

Before:

let proposal = validate_submitted_charter(document.properties(), platform_version)?
    .into_data()?;

After (the same result, since the validation step checked nothing):

let proposal = SubmittedCharter::from_document_properties(document.properties())
    .into_data()?;

How Has This Been Tested?

  • cargo test -p dpp --features moderation-charters-contract,validation --lib -- moderation_charter: 24 passed. The tests that only exercised the empty step (should_accept_a_valid_proposal, which duplicated the round trip, and should_refuse_to_validate_below_protocol_version_14) are removed; should_accept_a_proposal_without_reasons became should_read_a_proposal_without_reasons.
  • cargo clippy -p dpp -p platform-version --all-features --all-targets -- -D warnings: clean.
  • No other crate names the removed items (git grep across the repository).

Breaking Changes

None for consensus: the removed step validated nothing, and nothing on a block-execution path called it. validate_submitted_charter and SubmittedCharter::validate leave rs-dpp's public API; neither shipped in a release, and no SDK used them.

In-place changes to shipped generations

DPP_VALIDATION_VERSIONS_V1, V2 and V3 lose the validate_moderation_charter: None entry. No code read that field at those versions (the only reader, SubmittedCharter::validate, was PV14 only and is removed), so the edit cannot change consensus there. V5 is protocol version 14, which is unreleased.

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 · 6f1ef28

  • 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.

`SubmittedCharter::validate` dispatched on
`validate_moderation_charter` to a v0 that checked nothing: the reward
split's sum moved to the contract's `propertyConstraints` rule
`rewardSplitIsWhole` and the description's cap to `maxBytes`, both
checked wherever the document is validated. `validate_submitted_charter`
only chained the property read with that empty step, and nothing outside
rs-dpp's own tests called either.

Remove the method, its v0 module, `validate_submitted_charter` and the
`validate_moderation_charter` version entry. Tests read a proposal with
`SubmittedCharter::from_document_properties`. Error 11001 keeps its place
in `BasicError`, whose encoding is positional, and is still never
produced.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 11 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: 3522fde4-2220-4404-a87e-12274083e132

📥 Commits

Reviewing files that changed from the base of the PR and between 68aa586 and 6f1ef28.

📒 Files selected for processing (12)
  • docs/protocol/moderation-charters.md
  • packages/rs-dpp/src/errors/consensus/basic/moderation_charter/moderation_charter_reward_split_not_one_hundred_error.rs
  • packages/rs-dpp/src/moderation_charter/mod.rs
  • packages/rs-dpp/src/moderation_charter/tests.rs
  • packages/rs-dpp/src/moderation_charter/v0/mod.rs
  • packages/rs-dpp/src/system_data_contracts.rs
  • packages/rs-platform-version/src/version/dpp_versions/dpp_validation_versions/mod.rs
  • packages/rs-platform-version/src/version/dpp_versions/dpp_validation_versions/v1.rs
  • packages/rs-platform-version/src/version/dpp_versions/dpp_validation_versions/v2.rs
  • packages/rs-platform-version/src/version/dpp_versions/dpp_validation_versions/v3.rs
  • packages/rs-platform-version/src/version/dpp_versions/dpp_validation_versions/v5.rs
  • packages/rs-platform-version/src/version/v14.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 this to the v4.2.0 milestone Sep 24, 2026
@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Sep 24, 2026
@thepastaclaw

thepastaclaw commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

🕓 Queued for automated review — 5th in line, estimated start in ~1.7 h (commit 6f1ef28)
Estimated review time once started: ~40 min (two-phase automated review; median of recent runs).

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

@QuantumExplorer
QuantumExplorer merged commit 8325592 into v4.2-dev Sep 24, 2026
15 of 16 checks passed
@QuantumExplorer
QuantumExplorer deleted the claude/cleanup-validate-charter-error-a81149 branch September 24, 2026 06:48
shumkov added a commit that referenced this pull request Sep 24, 2026
Eight commits, three conflicts, and the enum one for the third merge running.

Git again auto-merged `StateError` by placing this branch's three token pool variants ahead
of the one v4.2-dev added, moving `ModerationReasonNotListedError` from 150 to 153. That enum
is bincode-encoded positionally, so the shift would have mis-decoded every already-encoded
instance of it. As before, only the frozen-discriminant test conflicted; the enum itself
merged silently. Resolved the same way: the base keeps its position and the token pool
variants move to the tail, 151 to 153.

This is why the merge is done in small steps rather than saved for the end. The hazard grows
with the number of variants the base adds, and it is invisible except through that one test.

`dpp_validation_versions/v5.rs`: v4.2-dev removed `validate_moderation_charter` in #4970, so
that removal is taken and only this branch's `validate_token_config_update` remains.
`platform_pb2.py` is generated; the base's copy is taken.

Verified on the merged tree: the three frozen-discriminant tests pass and
`cargo check --workspace --all-features` is clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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