diff --git a/consensus/height_vote_set.go b/consensus/height_vote_set.go index 945ee2c9e..42e89074c 100644 --- a/consensus/height_vote_set.go +++ b/consensus/height_vote_set.go @@ -78,6 +78,7 @@ func (hvs *HeightVoteSet) addRound(round int) { if _, ok := hvs.roundVoteSets[round]; ok { panic("addRound() for an existing round") } + log.Debug("addRound(round)", "round", round) prevotes := NewVoteSet(hvs.height, round, types.VoteTypePrevote, hvs.valSet) precommits := NewVoteSet(hvs.height, round, types.VoteTypePrecommit, hvs.valSet) hvs.roundVoteSets[round] = RoundVoteSet{ @@ -134,6 +135,7 @@ func (hvs *HeightVoteSet) POLRound() int { } func (hvs *HeightVoteSet) getVoteSet(round int, type_ byte) *VoteSet { + log.Debug("getVoteSet(round)", "round", round, "type", type_) rvs, ok := hvs.roundVoteSets[round] if !ok { return nil diff --git a/consensus/reactor.go b/consensus/reactor.go index f4d503abc..3b00fe3cf 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -67,7 +67,7 @@ func (conR *ConsensusReactor) Start(sw *p2p.Switch) { conR.conS.Start() } go conR.broadcastNewRoundStepRoutine() - go conR.rebroadcastRoundStepRoutine() + // go conR.rebroadcastRoundStepRoutine() } } @@ -322,6 +322,7 @@ func (conR *ConsensusReactor) broadcastNewRoundStepRoutine() { } } +/* TODO delete // Periodically broadcast NewRoundStepMessage. // This is a hack. TODO remove the need for it? // The issue is with Start() happening after a NewRoundStep message @@ -339,6 +340,7 @@ func (conR *ConsensusReactor) rebroadcastRoundStepRoutine() { } } } +*/ func (conR *ConsensusReactor) sendNewRoundStepMessage(peer *p2p.Peer) { rs := conR.conS.GetRoundState() diff --git a/consensus/state.go b/consensus/state.go index a9811ebc2..807c84378 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -400,6 +400,14 @@ func (cs *ConsensusState) updateToState(state *sm.State, contiguous bool) { } // END SANITY CHECK + // If state isn't further out than cs.state, just ignore. + // This happens when SwitchToConsensus() is called in the reactor. + // We don't want to reset e.g. the Votes. + if cs.state != nil && (state.LastBlockHeight <= cs.state.LastBlockHeight) { + log.Info("Ignoring updateToState()", "newHeight", state.LastBlockHeight+1, "oldHeight", cs.state.LastBlockHeight+1) + return + } + // Reset fields based on state. validators := state.BondedValidators height := state.LastBlockHeight + 1 // next desired block height