mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-07 13:55:17 +00:00
consensus: stricter on LastCommitRound check (#4970)
LastCommitRound should always be >= 0 for heights > 1. In State.updateToState, last precommit is computed only when round greater than -1 and has votes. But "LastCommit" is always updated regardless of the condition. If there's no last precommit, "LastCommit" is set to (*types.VoteSet)(nil). That's why "LastCommit" can be -1 for heights > 1. To fix it, only update State.RoundState.LastCommit when there is last precommit. Fixes #2737 Co-authored-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
This commit is contained in:
@@ -699,12 +699,12 @@ func TestNewRoundStepMessageValidateBasic(t *testing.T) {
|
||||
testName string
|
||||
messageStep cstypes.RoundStepType
|
||||
}{
|
||||
{false, 0, 0, 0, "Valid Message", 0x01},
|
||||
{true, -1, 0, 0, "Invalid Message", 0x01},
|
||||
{true, 0, 0, -1, "Invalid Message", 0x01},
|
||||
{true, 0, 0, 1, "Invalid Message", 0x00},
|
||||
{true, 0, 0, 1, "Invalid Message", 0x00},
|
||||
{true, 0, -2, 2, "Invalid Message", 0x01},
|
||||
{false, 0, 0, 0, "Valid Message", cstypes.RoundStepNewHeight},
|
||||
{true, -1, 0, 0, "Negative round", cstypes.RoundStepNewHeight},
|
||||
{true, 0, 0, -1, "Negative height", cstypes.RoundStepNewHeight},
|
||||
{true, 0, 0, 0, "Invalid Step", cstypes.RoundStepCommit + 1},
|
||||
{true, 0, 0, 1, "H == 1 but LCR != -1 ", cstypes.RoundStepNewHeight},
|
||||
{true, 0, -1, 2, "H > 1 but LCR < 0", cstypes.RoundStepNewHeight},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
||||
Reference in New Issue
Block a user