fix: validate slot duration and epoch configuration invariants (PM-20013)#764
Draft
fix: validate slot duration and epoch configuration invariants (PM-20013)#764
Conversation
Slot duration configurability across nodes — Least Authority audit finding Issue J addressing consensus boundary mismatch in CreateInherentDataConfig. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








Summary
Implement three-layer defense-in-depth for slot duration configurability: constructor validation, on-chain config storage with startup consistency check, and config hash in block headers. Addresses Least Authority Issue J (High severity).
🎫 PM-20013 📐 Engineering
Motivation
CreateInherentDataConfigaggregates consensus-critical parameters — sidechain slot configuration (on-chain) and mainchain epoch configuration (off-chain config files) — without cross-validation, invariant enforcement, or on-chain commitment. Nodes with differing parameter values compute divergent slot indices and epoch boundaries for the same wall-clock time, causing silent consensus divergence.The existing codebase contains an explicit TODO (
ETCM-4079) acknowledging missing validation for the epoch-duration/slot-duration divisibility constraint.Changes
Implementation (coming next):
#[derive(new)]onCreateInherentDataConfigwith falliblefn new() -> Resultenforcing epoch/slot divisibility and non-zero invariants. Addmc_*field validation toMidnightCfg.pallet-consensus-configstoringmc_epoch_configvia genesis config, exposed via runtime API. Startup consistency check inservice.rscomparing local config against on-chain values.DigestItem::Consensuswith new engine ID depositing config hash per block inon_initialize, followingpallet-versionpattern.consensus_configtoRuntimeGenesisConfigacross all chain spec builders.📌 Submission Checklist
🔱 Fork Strategy
🗹 TODO before merging