Skip to content

Commit 44dea31

Browse files
authored
fix: use updateRoundStep to track consensus state changes (#1464)
We're currently using `newStep` to indicate whether to write a new trace, however this actually doesn't track when the round and step change happens and thus misses certain steps (like NewRound). This PR fixes it
1 parent 344a6d4 commit 44dea31

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

consensus/state.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ func (cs *State) updateRoundStep(round int32, step cstypes.RoundStepType) {
538538
}
539539
if cs.Step != step {
540540
cs.metrics.MarkStep(cs.Step)
541+
schema.WriteRoundState(cs.traceClient, cs.Height, round, uint8(step))
541542
}
542543
}
543544
cs.Round = round
@@ -706,10 +707,6 @@ func (cs *State) newStep() {
706707

707708
cs.nSteps++
708709

709-
step := uint8(cs.RoundState.Step)
710-
711-
schema.WriteRoundState(cs.traceClient, cs.Height, cs.Round, step)
712-
713710
// newStep is called by updateToState in NewState before the eventBus is set!
714711
if cs.eventBus != nil {
715712
if err := cs.eventBus.PublishEventNewRoundStep(rs); err != nil {
@@ -1518,6 +1515,7 @@ func (cs *State) enterPrecommitWait(height int64, round int32) {
15181515
defer func() {
15191516
// Done enterPrecommitWait:
15201517
cs.TriggeredTimeoutPrecommit = true
1518+
cs.updateRoundStep(round, cstypes.RoundStepPrecommitWait)
15211519
cs.newStep()
15221520
}()
15231521

0 commit comments

Comments
 (0)