refactor(dpp): remove the empty moderation charter validation step - #4970
Conversation
`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>
|
Warning Review limit reachedNext included review available in 11 minutes. View limit detailsLimit 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. Review configuration: ⚙️ Run configurationConfiguration used: Repository: dashpay/platform/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (12)
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. Comment |
|
🕓 Queued for automated review — 5th in line, estimated start in ~1.7 h (commit 6f1ef28)
|
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>
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::validatedispatched ondpp.validation.data_contract.validate_moderation_charterto a v0 that always returned an empty, valid result.validate_submitted_charterread the proposal's properties, then called that empty step.ModerationCharterRewardSplitNotOneHundredError) is never produced: the reward split is held to 100 by the contract'srewardSplitIsWholerule (10422).Nothing outside rs-dpp's own tests called
validate_submitted_charterorSubmittedCharter::validate. Drive ABCI reads a seated charter withElectedCharter::from_document_propertiesand the moderators share straight from the stored proposal.What was done?
SubmittedCharter::validate, itsmoderation_charter/v0module andvalidate_submitted_charterfromrs-dpp.validate_moderation_charterfield fromDataContractValidationVersionsand fromDPP_VALIDATION_VERSIONS_V1,V2,V3(allNone) andV5(Some(0)).BasicErroris bincode-encoded positionally and two variants follow it (DocumentPropertyMaxBytesExceededErrorat 198,DocumentPropertyConstraintViolatedErrorat 199), so removing it would shift their wire discriminants. Its doc comment now says no check produces it.v14.rs, anddocs/protocol/moderation-charters.md.first_basic_errorfrom the charter tests; nothing had called it since the reward split and description checks moved to the schema.Before:
After (the same result, since the validation step checked nothing):
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, andshould_refuse_to_validate_below_protocol_version_14) are removed;should_accept_a_proposal_without_reasonsbecameshould_read_a_proposal_without_reasons.cargo clippy -p dpp -p platform-version --all-features --all-targets -- -D warnings: clean.git grepacross the repository).Breaking Changes
None for consensus: the removed step validated nothing, and nothing on a block-execution path called it.
validate_submitted_charterandSubmittedCharter::validateleave 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,V2andV3lose thevalidate_moderation_charter: Noneentry. 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.V5is protocol version 14, which is unreleased.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 ·
6f1ef28/skip-botsproceeds without the ones not yet reported/self-reviewedonce the bots are doneWhen every box is checked the
PR Hygienecheck passes and this can merge.