Compare commits

...

2 Commits

Author SHA1 Message Date
William Banfield
4ed24a5656 fix tests to ensure we are before timeout precommit step 2021-10-15 16:34:58 -04:00
William Banfield
9b29adb7cf remove legacy triggered precommit logic 2021-10-15 16:20:26 -04:00
3 changed files with 17 additions and 20 deletions

View File

@@ -726,7 +726,6 @@ func (cs *State) updateToState(state sm.State) {
cs.Votes = cstypes.NewHeightVoteSet(state.ChainID, height, validators)
cs.CommitRound = -1
cs.LastValidators = state.LastValidators
cs.TriggeredTimeoutPrecommit = false
cs.state = state
@@ -1052,7 +1051,6 @@ func (cs *State) enterNewRound(height int64, round int32) {
}
cs.Votes.SetRound(tmmath.SafeAddInt32(round, 1)) // also track next round (round+1) to allow round-skipping
cs.TriggeredTimeoutPrecommit = false
if err := cs.eventBus.PublishEventNewRound(cs.NewRoundEvent()); err != nil {
cs.Logger.Error("failed publishing new round", "err", err)
@@ -1491,12 +1489,10 @@ func (cs *State) enterPrecommit(height int64, round int32) {
// Enter: any +2/3 precommits for next round.
func (cs *State) enterPrecommitWait(height int64, round int32) {
logger := cs.Logger.With("height", height, "round", round)
if cs.Height != height || round < cs.Round || (cs.Round == round && cs.TriggeredTimeoutPrecommit) {
if cs.Height != height || round < cs.Round || (cs.Round == round && cstypes.RoundStepPrecommitWait <= cs.Step) {
logger.Debug(
"entering precommit wait step with invalid args",
"triggered_timeout", cs.TriggeredTimeoutPrecommit,
"current", fmt.Sprintf("%v/%v", cs.Height, cs.Round),
"current", fmt.Sprintf("%v/%v/%v", cs.Height, cs.Round, cs.Step),
)
return
}
@@ -1512,7 +1508,7 @@ func (cs *State) enterPrecommitWait(height int64, round int32) {
defer func() {
// Done enterPrecommitWait:
cs.TriggeredTimeoutPrecommit = true
cs.updateRoundStep(round, cstypes.RoundStepPrecommitWait)
cs.newStep()
}()

View File

@@ -1639,13 +1639,14 @@ func TestStartNextHeightCorrectlyAfterTimeout(t *testing.T) {
ensureNewTimeout(timeoutProposeCh, height+1, round, cs1.config.Propose(round).Nanoseconds())
rs = cs1.GetRoundState()
assert.False(
assert.Less(
t,
rs.TriggeredTimeoutPrecommit,
"triggeredTimeoutPrecommit should be false at the beginning of each round")
rs.Step,
cstypes.RoundStepPrecommitWait,
"RoundStep should be less than 'PrecommitWait' at the beginning of each round")
}
func TestResetTimeoutPrecommitUponNewHeight(t *testing.T) {
func TestNotEnteredTimeoutPrecommitUponNewHeight(t *testing.T) {
config := configSetup(t)
config.Consensus.SkipTimeoutCommit = false
@@ -1698,10 +1699,11 @@ func TestResetTimeoutPrecommitUponNewHeight(t *testing.T) {
ensureNewProposal(proposalCh, height+1, 0)
rs = cs1.GetRoundState()
assert.False(
assert.Less(
t,
rs.TriggeredTimeoutPrecommit,
"triggeredTimeoutPrecommit should be false at the beginning of each height")
rs.Step,
cstypes.RoundStepPrecommitWait,
"RoundStep should be less than 'PrecommitWait' at the beginning of each round")
}
//------------------------------------------------------------------------------------------

View File

@@ -85,12 +85,11 @@ type RoundState struct {
ValidBlock *types.Block `json:"valid_block"` // Last known block of POL mentioned above.
// Last known block parts of POL mentioned above.
ValidBlockParts *types.PartSet `json:"valid_block_parts"`
Votes *HeightVoteSet `json:"votes"`
CommitRound int32 `json:"commit_round"` //
LastCommit *types.VoteSet `json:"last_commit"` // Last precommits at Height-1
LastValidators *types.ValidatorSet `json:"last_validators"`
TriggeredTimeoutPrecommit bool `json:"triggered_timeout_precommit"`
ValidBlockParts *types.PartSet `json:"valid_block_parts"`
Votes *HeightVoteSet `json:"votes"`
CommitRound int32 `json:"commit_round"` //
LastCommit *types.VoteSet `json:"last_commit"` // Last precommits at Height-1
LastValidators *types.ValidatorSet `json:"last_validators"`
}
// Compressed version of the RoundState for use in RPC