message/validation: enable lowest allowed round check#2807
message/validation: enable lowest allowed round check#2807nkryuchkov wants to merge 8 commits intostagefrom
Conversation
Codecov Report❌ Patch coverage is
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Greptile SummaryThis PR re-enables the lower-bound enforcement of the estimated-round window in consensus message validation ( Confidence Score: 5/5Safe to merge; the underflow fix is correct, test coverage is solid, and the check-ordering change is a net improvement. All findings are P2 or informational. The core logic (underflow guard, clamp to FirstRound, proposer bypass, post-slot-time positioning) is correct and well-tested. The per-duty RoundTimer refactoring is clean with no cross-duty state leakage. No blocking issues found. No files require special attention; message/validation/consensus_validation.go is the most sensitive and the change there is minimal and correct. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[validateQBFTMessageByDutyLogic] --> B[validateSlotTime]
B -->|fail: late slot / slot too early| E[return ErrLateSlot / ErrEarlySlot]
B -->|pass| C{len OperatorIDs == 1?}
C -->|No - decided msg| D[skip round spread check]
C -->|Yes - non-decided| F[roundBelongsToAllowedSpread]
F --> G[Compute estimatedRoundAt]
G --> H{estimatedRound > allowedRoundsInPast=2?}
H -->|No - clamp| I[lowestAllowedRound = FirstRound=1]
H -->|Yes| J[lowestAllowedRound = estimatedRound - 2]
I --> K[highestAllowedRound = estimatedRound + 1]
J --> K
K --> L{role == Proposer?}
L -->|Yes| M[lowestAllowed=1, highestAllowed=2]
L -->|No| N{msg.Round in lowestAllowed..highestAllowed?}
M --> N
N -->|No| O[return ErrEstimatedRoundNotInAllowedSpread]
N -->|Yes| P[pass - continue to duty count check]
Reviews (4): Last reviewed commit: "msg-validation: round-timeout validation..." | Re-trigger Greptile |
iurii-ssv
left a comment
There was a problem hiding this comment.
I think there is a discrepancy in the code-area around these changes we need to look into
|
@greptileai review it again |
|
@greptileai review it again |
# Conflicts: # message/validation/consensus_validation.go
…west-round # Conflicts: # protocol/v2/qbft/roundtimer/timer.go
* msg-validation: round-timeout validation refactoring * fix typo * further adjustments * clean up comments * optimize * misc improvements * fix linter * add a test to validate/bind EstimatedRoundAt against RoundTimeout * clean up * finish the clarifying comment * finish the clarifying comment * rename roundTimeoutOffset->roundTimeoutForRound * change Height->Slot to finish the merge cleanly
|
@greptileai review this again |
Summary
Enable the lower bound of the estimated round window in message validation.
This restores rejecting non-decided messages that are too far behind the locally estimated round, while keeping the lower bound clamped to
specqbft.FirstRoundto avoid unsigned underflow.The round spread check now runs after slot-time and slot-advance validation so existing
late slotandslot already advancederrors keep the same precedence.Tests
go test ./message/validationQA
This PR requires thorough QA, because we had some message validation failures when this check was enabled. I suspect it was because of the underflow bug, though.