Repository navigation
fix(types): validate quorum threshold against canonical LLMQ type (#1314) - #1328
Conversation
ValidatorSet.ValidateBasic enforced a rigid size-based 2/3+1 voting-power floor that wrongly rejected legitimate dev/test quorums whose canonical threshold sits at or below 2/3 -- notably llmq_devnet_platform (8-of-12, exactly 2/3), breaking DEVNET_PLATFORM networks. Replace the rigid switch with a quorum-type-aware decision: 1. Reject impossible thresholds (non-positive, or above total power). 2. If VotingPowerThreshold is explicitly set, trust it (the #1052 single-node/dev escape hatch). 3. Otherwise the threshold derives from the quorum type: - recognized type: it MUST equal the canonical type definition; - unknown/custom type: keep the strict size-based 2/3 production floor, since we have no canonical definition to trust. This loosens validation for recognized dev/test types while preserving the strict floor exactly where BFT safety demands it (unknown types). ValidateBasic is a local gate (not hashed, not in ToProto), so this cannot fork a running chain. Add the isDevOrTestQuorum classifier and table-driven tests covering the DEVNET_PLATFORM fix, explicit override, and strict-floor branches. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Polish pass on the #1314 quorum-type-aware ValidateBasic change following QA: - Remove the dead isDevOrTestQuorum classifier and its test. The dev/test distinction only mattered for an operator warning, but ValidateBasic is a pure domain method with no reachable logger; wiring one in would mean invasive plumbing (logger field / signature change / package global) into types/, a pure types package. The reduced-margin caveat belongs in operator docs instead. No dead code, no unfulfilled TODO markers. - Document the recognized-type canonical-mismatch guard as defense-in-depth: it is unreachable when the threshold derives from the type (param unset), and exists for future callers that set the threshold independently. - Add recognized PRODUCTION type coverage (100_67 above 2/3, 50_60 below 2/3 accepted as canonical) so production types are proven to validate through the recognized-type branch. - Make each test's quorum type explicit and fix misleading comments that relied on the LLMQType_5_60 == LLMQType_TEST alias coincidence. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…r_threshold override Update ValidatorParams documentation in params.proto and spec/core/data_structures.md to accurately describe the type-aware threshold validation introduced by the fix for issue #1314 (DEVNET_PLATFORM 8-of-12 rejection): - recognized LLMQ types use their canonical threshold (fixes #1314) - unknown/custom types fall back to the strict >2/3 size-based floor - explicit operator overrides (from #1052) accept any value in (0, totalPower] Adds operator guidance on the footgun: the override path has no 2/3 floor, so values below 2/3 of total power reduce BFT safety and should only be used in controlled dev/test environments. Note: make proto-gen must be run to sync params.pb.go from the updated .proto. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…1314) Quorums whose voting threshold sits at or below the strict 2/3+1 bound are accepted (DEVNET_PLATFORM 8/12, or an explicit operator VotingPowerThreshold override), but operators got no signal that fault tolerance was reduced. Emit a one-shot Warn at the consensus lifecycle layer (updateToState), where the validator set is installed at start and on quorum/valset change. The trigger is broadened to also fire on a VotingPowerThreshold-only consensus- param change (same QuorumHash), so a lowered override is never silent. The log fires only when the active set actually changes, never per block. ValidateBasic stays pure: the warning lives in the lifecycle layer, not the validation method. Add ValidatorSet.BelowStrictThreshold reusing the exact (totalPower*2)/3+1 floor from validateThreshold, with unit tests. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Warning Review limit reached
More reviews will be available in 36 minutes and 19 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR refactors validator-set quorum threshold validation to consult canonical LLMQ type definitions and honor explicit VotingPowerThreshold overrides, adds a strict-floor helper and exported query methods, monitors threshold changes in consensus state, updates docs/proto/spec for voting_power_threshold semantics, and expands test coverage. ChangesQuorum Threshold Validation and Monitoring
🎯 3 (Moderate) | ⏱️ ~25 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Pull request overview
This PR fixes a regression in ValidatorSet.ValidateBasic() where legitimate Dash LLMQ quorums (notably llmq_devnet_platform 8-of-12) were rejected due to an overly rigid > 2/3 + 1 threshold rule. The update makes threshold validation quorum-type-aware (canonical thresholds for recognized LLMQ types, strict floor for unknown types, and an explicit operator override path), and adds a startup/param-change warning when operating below the strict 2/3+1 BFT bound.
Changes:
- Reworked validator-set threshold validation to use canonical LLMQ quorum definitions when the quorum type is recognized, while preserving a strict safety floor for unknown/custom types.
- Added
BelowStrictThreshold()and a warning in consensus state initialization/update when the active threshold is below the strict2/3+1bound. - Added unit tests plus documentation/proto comment updates and a changelog entry.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
types/validator_set.go |
Introduces type-aware threshold validation and BelowStrictThreshold() helper. |
types/validator_set_test.go |
Adds table-driven coverage for threshold validation branches and BelowStrictThreshold(). |
internal/consensus/state_data.go |
Logs a warning when the validator set’s effective threshold is below the strict 2/3+1 bound (on startup / validator updates). |
spec/core/data_structures.md |
Documents voting_power_threshold behavior and validation rules. |
proto/tendermint/types/params.proto |
Updates the field comment for voting_power_threshold to match the new validation semantics. |
CHANGELOG.md |
Adds an Unreleased bug-fix entry describing the validation change. |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/consensus/state_data.go`:
- Around line 275-279: The warning currently recomputes the strict-floor with
(validators.TotalVotingPower()*2)/3+1 which can diverge from the canonical logic
used by BelowStrictThreshold(); replace that inline formula with the canonical
strict-floor value used by BelowStrictThreshold() by calling the same
helper/selector used there (e.g., the
validators.Strict.../StrictThreshold/StrictVotingPower function that
BelowStrictThreshold() relies on) and pass that result as "strict_floor" so the
logger and BelowStrictThreshold() report the identical threshold.
In `@types/validator_set.go`:
- Around line 501-503: ValidatorSet.Copy() currently omits the
VotingPowerThreshold field so clones lose any explicit threshold override,
changing behavior of methods like BelowStrictThreshold() and
QuorumVotingThresholdPower(); update ValidatorSet.Copy() to copy the
VotingPowerThreshold (and any related threshold fields) from the receiver into
the new ValidatorSet instance so cloned sets preserve the effective voting
threshold and semantics.
- Around line 203-218: The code only enforces the canonical threshold from
llmq.QuorumParams(vals.QuorumType) but not the canonical member count, allowing
non-canonical sizes (e.g., DEVNET_PLATFORM labeled sets with 20 validators) to
pass; after calling llmq.QuorumParams and before accepting the canonical
threshold, compute the expected total voting power from the returned canonical
member count (e.g., wantTotalPower := int64(typeMembers) *
DefaultDashVotingPower where typeMembers is the first return from
llmq.QuorumParams) and validate that totalPower equals wantTotalPower, returning
an error if it does not; keep the existing threshold check (using typeThreshold)
and only accept the recognized type when both totalPower and threshold match the
canonical values to ensure vals.QuorumType and the set size are consistent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8cdcb95b-45a7-4039-a30f-e8bc819aae0f
📒 Files selected for processing (6)
CHANGELOG.mdinternal/consensus/state_data.goproto/tendermint/types/params.protospec/core/data_structures.mdtypes/validator_set.gotypes/validator_set_test.go
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
… dedupe strict floor Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
Code Review
The quorum-type-aware ValidateBasic fix, the Copy() preservation of VotingPowerThreshold, and the new below-strict-floor warning are correct and well-scoped. One real consensus-state gap remains: the same-quorum validator-update path in valsetUpdate now drops a fresh params.VotingPowerThreshold for the next height because Copy() carries the previous explicit threshold and UpdateWithChangeSet does not overlay the new param. Smaller items: one misleading error message and one undocumented new rejection path (oversized recognized-type set).
🔴 1 blocking | 🟡 2 suggestion(s) | 💬 1 nitpick(s)
1 additional finding(s) omitted (not in diff).
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `internal/state/current_round_state.go`:
- [BLOCKING] internal/state/current_round_state.go:323-347: Same-quorum validator update path silently drops params.VotingPowerThreshold for the next height
valsetUpdate applies params.VotingPowerThreshold only in the else branch (no validator updates). When validatorUpdates are present AND the quorum hash is unchanged, UpdateWithChangeSet runs but the new params.VotingPowerThreshold is never overlaid. Because this PR makes Copy() preserve VotingPowerThreshold (validator_set.go:396), nValSet now carries the previous explicit threshold and ValidateBasic() will pass with the stale value while ConsensusParamUpdates already record the new one. Concretely: a height that returns both same-quorum validator updates and Validator.VotingPowerThreshold = 900 (was 800) will persist NextConsensusParams=900 but build the next HeightVoteSet's commit gate at 800. The new-quorum branch passes ¶ms to NewValidatorSetCheckPublicKeys and the no-update branch already applies the override — the same-quorum branch needs the same overlay before ValidateBasic().
In `types/validator_set.go`:
- [SUGGESTION] types/validator_set.go:191-194: Error message says both values must be positive, but the branch fires when either is non-positive
This case triggers on `totalPower <= 0 || threshold <= 0` but the message reads "total voting power %d and threshold %d must both be positive". On the existing "zero total power rejected" test path, the derived threshold is 100, so the error reports e.g. `total voting power 0 and threshold 100 must both be positive`, which is incorrect about the threshold component. Reword to match the OR semantics.
- [SUGGESTION] types/validator_set.go:213-216: New over-subscribed rejection should be called out in CHANGELOG and PR description
The PR description and CHANGELOG state the change "only loosens validation" and "cannot reject a validator set that previously passed." The new `vals.Size() > typeMembers` guard is a legitimate, consensus-safe second rejection path (an oversized DEVNET_PLATFORM set would drop the live commit gate below 2/3), but it is unmentioned. Operators of tooling that assembles non-canonical recognized-type sets should not discover this on upgrade. Document the new rejection alongside the existing canonical-threshold-mismatch note.
c3fbb6b to
d5676f2
Compare
Copy() now preserves VotingPowerThreshold, which activated a latent bug in valsetUpdate: the same-quorum-with-updates branch ran UpdateWithChangeSet but never overlaid the new params.VotingPowerThreshold, so the returned set kept the previous height's threshold while NextConsensusParams recorded the new one. The live commit gate (QuorumVotingThresholdPower -> vote_set.go) then tallied votes against a stale threshold for one height. Mirror the override the no-updates branch already applies, placed before ValidateBasic so the explicit-override validation checks the value the chain will actually use. The new-quorum branch already passes ¶ms, so only this branch was affected. Adds a white-box regression test exercising all three valsetUpdate branches; the same-quorum sub-case returned the stale threshold before this fix. Refs #1328. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Thanks for the catch on the same-quorum Verification: Independently reproduced it with a white-box test against branch 1 of Fix (4e67f8b): added the 🤖 Co-authored by Claudius the Magnificent AI Agent |
…itive" misnomer The OR condition fires when *either* value is non-positive, so "must both be positive" could mislead (the other operand might be fine). Changed to "> 0" which is phrasing-neutral w.r.t. which operand triggered. Refs: thepastaclaw review thread on validator_set.go:194 (PR #1328) Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
Code Review
The PR's same-quorum overlay fix (4e67f8b) closes the prior blocking gap and is well covered by TestValsetUpdateOverlaysVotingPowerThreshold. One residual consistency gap: VotingPowerThreshold is now identity-relevant (preserved by Copy, used in updateToState) but ValidatorSet.Equals still ignores it. No callers exercise that today, so it's a latent foot-gun rather than an active bug.
🟡 1 suggestion(s)
1 additional finding(s) omitted (not in diff).
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `types/validator_set.go`:
- [SUGGESTION] types/validator_set.go:256-281: ValidatorSet.Equals ignores VotingPowerThreshold even though Copy and state_data updateToState now treat it as identity-relevant
This PR elevates VotingPowerThreshold to a first-class part of the ValidatorSet's effective identity: Copy() at types/validator_set.go:396 preserves it (with a regression test), and internal/consensus/state_data.go:271 explicitly compares `s.Validators.VotingPowerThreshold != validators.VotingPowerThreshold` to detect threshold flips on the same quorum. Equals() here compares only ThresholdPublicKey, QuorumHash, QuorumType and per-validator bytes, so two sets that differ only in VotingPowerThreshold compare equal. No current caller in the consensus hot path uses Equals (grep finds no `*ValidatorSet.Equals(` invocations), so this is latent rather than an active bug — but it leaves the public API of the struct this PR just hardened inconsistent with its own internal change-detection logic. Future callers that reach for Equals to detect 'meaningful change to the active commit gate' would silently miss the override flip this PR's state_data.go change was added to catch.
|
✅ Review complete (commit 4e67f8b) |
… consistency Not a behavioral fix — Equals has no callers and threshold propagates correctly elsewhere. This makes the method honest about what constitutes ValidatorSet identity, so any future caller gets the correct answer without a surprise. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Why this PR exists
ValidatorSet.ValidateBasic()rejects a legitimate 8-of-12llmq_devnet_platformquorum. The threshold (8×100 = 800) is exactly 2/3 of total power (1200), but thedefaultbranch requires>(2/3)+1 = 801, so the node restart-loops on replay.error on replay: validator set updates: voting threshold 800 of quorum with power 1200 MUST be at least 2/3*1200+1 = 801.switch, which also removes the lower-bound floor — letting an unknown/custom quorum with a sub-2/3 (or near-zero) threshold passValidateBasicand then finalize blocks at that threshold (the value feeds the live commit gate invote_set.go, where crossing it recovers the BLS threshold signature that is the commit). This PR fixes the bug while keeping that floor where BFT safety needs it.Issue being fixed or feature implemented
Fixes #1314.
The rigid size-based threshold rule contradicts both the canonical LLMQ quorum definitions (Dash Core forms
DEVNET_PLATFORMas 8-of-12) and the field's own proto contract, which states the threshold "is determined based on the LLMQ quorum type defined for the network, with a fall back to 2/3 + 1".What was done?
Replaced the rigid
switch len(vals.Validators)threshold check with type-aware validation:voting_power_thresholdset (>0): accept any0 < t ≤ total. The operator/dev escape hatch from feat: allow defining validator power threshold in consensus params #1052, recorded on-chain for accountability; the operator owns any reduced safety margin.DEVNET_PLATFORM8-of-12.==totalfor 1–2;≥2/3for 3;>(2/3)+1for 4+) — preserves production safety where there is no canonical definition to trust.Added a startup / consensus-param-change warning (
internal/consensus/state_data.go) via the newValidatorSet.BelowStrictThreshold()helper: whenever the active voting threshold sits below the strict 2/3+1 BFT bound — a dev/test quorum such as 8-of-12, or a deliberately-loweredvoting_power_threshold— the node logs aWarn. Visibility without rejection; log-only, no state/determinism impact, no per-block spam (fires only at start and on quorum/threshold change).Docs: documented
voting_power_thresholdinspec/core/data_structures.md(previously undocumented) and corrected the proto comment; added a CHANGELOG entry.ValidateBasicis a local, non-hashed gate (absent fromToProto), so this is not consensus-breaking and needs no ABCI bump. The change only loosens validation (recognized + dev/test quorums) — apart from a defensive canonical-mismatch guard — so it cannot reject a validator set that previously passed.How Has This Been Tested?
make build(BLS + binary) andgo test ./types/... ./internal/consensus/...— green.DEVNET_PLATFORM8/12 accepted; recognized production type100_67accepted and50_60accepted at canonical; unknown-type threshold 800 rejected / 801 accepted; explicit override accepted;BelowStrictThresholdboundary cases (8/12 → true, 100_67 → false, override 800 → true, 900 → false).gofmt -s,golangci-lint(0 new issues), andmake proto-gen(no diff — the proto comment edit is a codegen no-op) all clean.Breaking Changes
None.
ValidateBasicis a local, non-hashed validation gate — no wire/ABCI change, no version bump. The change relaxes validation for recognized and dev/test quorums and retains the strict floor for unknown types.Checklist:
For repository code-owners and collaborators only
🤖 Co-authored by Claudius the Magnificent AI Agent
Summary by CodeRabbit
Bug Fixes
Documentation
Tests