feat(platform)!: elected contracts declare their own election delay, read by the electionOpen reference requirement - #4914
Conversation
…read by the electionOpen reference requirement The elected moderation declaration gains an optional, unbounded `electionDelay`: seconds after the contract's creation before the first charter may be filed against it. Since config update v2 refuses declaring elected moderation after creation, the creation is the declaration's own time and nothing new is recorded. Frozen with the rest of the declaration, absent from the wire when not declared. The `moderation` reference requirement's closed set gains `"electionOpen"`: the contract declares elected moderation and its own delay has passed at the block time of the write, or it declares none. The charter's `targetContractId` declares this and carries no number. Unmet is the existing 40135 with field `moderation`, required `electionOpen`. The book sentence from #4913 that motivated `minimumSecondsSinceUpdate` with an old contract updated to declare elected moderation was wrong, since that update is refused; corrected. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 59 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 (16)
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 |
|
📖 Book Preview built successfully. Download the preview from the workflow artifacts. Updated at 2026-09-22T16:11:04.233Z |
|
|
A charter proposal needs the target elected so teams can form during the notice; the charter that opens the contest needs the election open. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
#4914 made the notice before a contract's first election the contract's own (`electionDelay` on its elected declaration), read by the `moderation: "electionOpen"` reference requirement. The charter's `targetContractId` reference declares that instead of the five days the reference fixed with `minimumAgeSeconds`, so the charter carries no number and a target that declares no delay is open at once. The five-day constant in rs-dpp goes with it; the system contract test pins the new requirement. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Resolves the overlap with #4914 (electionDelay + `moderation: "electionOpen"`): both sets of `contractRequirements` keys are kept in the type, the parser tests, the meta-schema, the wasm-dpp2 surface, the book and the changelog. The drive-abci elected-contract test helper takes the election delay, the recorded creation time and the owner protection flag, and every helper's setup closure receives the reference targets. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Issue being fixed or feature implemented
PR #4913 let a
contractreference fix a delay in seconds between the referenced contract's creation and the referring document, so a moderation team cannot be seated on a contract before anyone has seen it. Sam asked for the delay to be the moderated contract's own: each contract declares how much notice it gives before its first election, and the charter that opens the contest only asks whether that notice has passed, without carrying a number.What was done?
ElectedModerators,packages/rs-dpp/src/data_contract/config/moderation/elected.rs): a new optional, unbounded fieldelectionDelay, seconds after the contract's creation before the first charter may be filed against it. Left out, the election may be called at once. It is frozen with the rest of the declaration (the freeze test covers it), absent from the wire form when not declared, andElectedModerators::election_is_open(contract_created_at, block_time_ms)reads it. Because config update v2 refuses declaring elected moderation after creation, the contract's creation is the declaration's own time, so nothing new is recorded. A contract with a delay and no recorded creation time is of unknown age and never opens.moderationrequirement's closed set gains"electionOpen": the contract declares elected moderation and its own delay has passed at the block time of the write, or it declares none. The charter that opens the contest declares it on itstargetContractId:Both values have a user in the charter contract: a charter proposal only needs the target
elected, so teams can form during the notice the contract gives, while the charter that opens the contest needs its electionelectionOpen.Unmet is the existing
ReferencedContractRequirementNotMetError(40135) with fieldmoderationand requiredelectionOpen. No new error code or discriminant. The check runs against the contract already fetched for the existence check, so it costs no further read.["elected", "electionOpen"], parser message listing both, wasm-dpp2ContractModeratorstype gainselectionDelay?: numberand the reference surfacemoderation?: 'elected' | 'electionOpen'.minimumSecondsSinceUpdatewith "an old contract updated to declare elected moderation" was wrong, since an elected declaration cannot be added by an update; it now says that requirement is for other uses than the charter.minimumAgeSecondsandminimumSecondsSinceUpdatestay as the general numeric forms.Follow-up: in the charter contract (#4898), the proposal type keeps
"moderation": "elected"and the type that opens the contest declares"moderation": "electionOpen".How Has This Been Tested?
election_is_open(no delay, one millisecond short, exact boundary, unknown age, saturation),Display, the config update freeze test with the delay as an eighth change, the reference value'sis_met_byon a fixture contract (no moderation, elected without delay, elected with delay before and after it passes, unknown age), parser and meta-schema acceptance ofelectionOpen, and the existing reference tests. 67 targeted tests green.reference-validation-contract-election-open-contract-ref.json; five creation tests: referenced contract not elected (40135), elected without delay (success, even without a recorded creation time), created one millisecond less than its delay before the block (40135, fieldmoderation, requiredelectionOpen), delayed contract without a creation time (40135), created exactly its delay before the block (success). The existing contract-reference, moderation gate and no-locking contest tests still pass.cargo check -p wasm-dpp2 --target wasm32-unknown-unknown, clippy on dpp and drive-abci, rustfmt.Breaking Changes
Consensus, under the unreleased protocol version 14: the elected declaration gains an optional field, so its encoding changes for contracts that declare a delay, and a
contractreference may now refuse a write by 40135 under a new requirement value.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 ·
b1c9b94/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.