From 9a5e236d30c6d53f04f72d9ff442e6523d7b285c Mon Sep 17 00:00:00 2001 From: chengwenxi Date: Wed, 26 Jun 2019 16:29:22 +0800 Subject: [PATCH] Reset triggered timeout precommit --- consensus/common_test.go | 10 ++++++++-- consensus/state.go | 5 +++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/consensus/common_test.go b/consensus/common_test.go index d24290c2a7b..e8bb0dbe9a7 100644 --- a/consensus/common_test.go +++ b/consensus/common_test.go @@ -125,15 +125,21 @@ func startTestRound(cs *ConsensusState, height int64, round int) { // Create proposal block from cs1 but sign it with vs func decideProposal(cs1 *ConsensusState, vs *validatorStub, height int64, round int) (proposal *types.Proposal, block *types.Block) { + cs1.mtx.Lock() block, blockParts := cs1.createProposalBlock() + cs1.mtx.Unlock() if block == nil { // on error panic("error creating proposal block") } // Make proposal - polRound, propBlockID := cs1.ValidRound, types.BlockID{block.Hash(), blockParts.Header()} + cs1.mtx.RLock() + validRound := cs1.ValidRound + chainID := cs1.state.ChainID + cs1.mtx.RUnlock() + polRound, propBlockID := validRound, types.BlockID{block.Hash(), blockParts.Header()} proposal = types.NewProposal(height, round, polRound, propBlockID) - if err := vs.SignProposal(cs1.state.ChainID, proposal); err != nil { + if err := vs.SignProposal(chainID, proposal); err != nil { panic(err) } return diff --git a/consensus/state.go b/consensus/state.go index 55aa15b32ff..04b95ed7008 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -78,9 +78,9 @@ type ConsensusState struct { evpool sm.EvidencePool // internal state - mtx sync.RWMutex + mtx sync.RWMutex cstypes.RoundState - state sm.State // State until height-1. + state sm.State // State until height-1. // state changes may be triggered by: msgs from peers, // msgs from ourself, or by timeouts @@ -538,6 +538,7 @@ func (cs *ConsensusState) updateToState(state sm.State) { cs.CommitRound = -1 cs.LastCommit = lastPrecommits cs.LastValidators = state.LastValidators + cs.TriggeredTimeoutPrecommit = false cs.state = state cs.Deprecated = state.Deprecated