Skip to content

Commit

Permalink
fix: use updateRoundStep to track consensus state changes (#1464)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cmwaters authored Aug 28, 2024
1 parent 344a6d4 commit 44dea31
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ func (cs *State) updateRoundStep(round int32, step cstypes.RoundStepType) {
}
if cs.Step != step {
cs.metrics.MarkStep(cs.Step)
schema.WriteRoundState(cs.traceClient, cs.Height, round, uint8(step))
}
}
cs.Round = round
Expand Down Expand Up @@ -706,10 +707,6 @@ func (cs *State) newStep() {

cs.nSteps++

step := uint8(cs.RoundState.Step)

schema.WriteRoundState(cs.traceClient, cs.Height, cs.Round, step)

// newStep is called by updateToState in NewState before the eventBus is set!
if cs.eventBus != nil {
if err := cs.eventBus.PublishEventNewRoundStep(rs); err != nil {
Expand Down Expand Up @@ -1518,6 +1515,7 @@ func (cs *State) enterPrecommitWait(height int64, round int32) {
defer func() {
// Done enterPrecommitWait:
cs.TriggeredTimeoutPrecommit = true
cs.updateRoundStep(round, cstypes.RoundStepPrecommitWait)
cs.newStep()
}()

Expand Down

0 comments on commit 44dea31

Please sign in to comment.