diff --git a/consensus/reactor.go b/consensus/reactor.go index 1ecfcfe38..ca410fa68 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -107,14 +107,19 @@ func (conR *Reactor) OnStop() { func (conR *Reactor) SwitchToConsensus(state sm.State, skipWAL bool) { conR.Logger.Info("SwitchToConsensus") - // We have no votes, so reconstruct LastCommit from SeenCommit. - if state.LastBlockHeight > 0 { - conR.conS.reconstructLastCommit(state) - } + func() { + // We need to lock, as we are not entering consensus state from State's `handleMsg` or `handleTimeout` + conR.conS.mtx.Lock() + defer conR.conS.mtx.Unlock() + // We have no votes, so reconstruct LastCommit from SeenCommit + if state.LastBlockHeight > 0 { + conR.conS.reconstructLastCommit(state) + } - // NOTE: The line below causes broadcastNewRoundStepRoutine() to broadcast a - // NewRoundStepMessage. - conR.conS.updateToState(state) + // NOTE: The line below causes broadcastNewRoundStepRoutine() to broadcast a + // NewRoundStepMessage. + conR.conS.updateToState(state) + }() conR.mtx.Lock() conR.waitSync = false