Repository navigation
fix(consensus): correct loop condition in checkDoubleSigningRisk for height=1 (backport #5668) - #6001
Merged
Merged
Conversation
…5668) Fixes: #5435 When `double_sign_check_height` is set to `1`, the loop condition `i := int64(1); i < 1` is never satisfied, resulting in zero iterations and no double sign checks being performed. This makes the setting functionally equivalent to `0` (disabled), silently giving validators false confidence in their double-sign protection. Changed the loop condition from `i < doubleSignCheckHeight` to `i <= doubleSignCheckHeight` so that a value of `1` correctly checks `height - 1`, matching the documented intent of the configuration parameter. The existing guard `if doubleSignCheckHeight > height` already prevents out-of-bounds lookups on short chains, so no additional bounds protection is needed. #### PR checklist - [x] Tests written/updated - [x] Changelog entry added in `CHANGELOG.md` - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments --------- Co-authored-by: Alex Cozart <[email protected]> (cherry picked from commit 6e8065b) # Conflicts: # CHANGELOG.md # consensus/state_test.go # scripts/metricsgen/metricsgen.go
Contributor
Author
|
Cherry-pick of 6e8065b has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
Contributor
|
PR author is not in the allowed authors list. |
- CHANGELOG.md: keep only the #5668 entry (other entries were main-only and already present or not applicable on v0.38.x) - consensus/state_test.go: drop main-only countingWAL/WAL fsync tests that were pulled in as conflict context; keep TestDoubleSigning - mempool/clist_mempool.go, scripts/metricsgen/metricsgen.go: revert to v0.38.x base; those hunks were unrelated main-only cleanups
swift1337
approved these changes
Jul 27, 2026
Contributor
Author
|
Tick the box to add this pull request to the merge queue (same as
|
4 tasks
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.
Fixes: #5435
When
double_sign_check_heightis set to1, the loop conditioni := int64(1); i < 1is never satisfied, resulting in zero iterations and no double sign checks being performed. This makes the setting functionally equivalent to0(disabled), silently giving validators false confidence in their double-sign protection.Changed the loop condition from
i < doubleSignCheckHeighttoi <= doubleSignCheckHeightso that a value of1correctly checksheight - 1, matching the documented intent of the configuration parameter. The existing guardif doubleSignCheckHeight > heightalready prevents out-of-bounds lookups on short chains, so no additional bounds protection is needed.PR checklist
CHANGELOG.mddocs/orspec/) and code commentsThis is an automatic backport of pull request fix(consensus): correct loop condition in checkDoubleSigningRisk for height=1 #5668 done by Mergify.