Fix view change stuck issue

pull/3419/head
Rongjian Lan 4 years ago
parent 9018d10bc9
commit ff9a85ac48
  1. 4
      consensus/consensus_service.go
  2. 2
      consensus/consensus_v2.go
  3. 3
      consensus/view_change.go

@ -573,9 +573,9 @@ func (consensus *Consensus) selfCommit(payload []byte) error {
continue
}
if _, err := consensus.Decider.SubmitVote(
if _, err := consensus.Decider.AddNewVote(
quorum.Commit,
[]bls.SerializedPublicKey{key.Pub.Bytes},
[]*bls_cosi.PublicKeyWrapper{key.Pub},
key.Pri.SignHash(commitPayload),
common.BytesToHash(consensus.blockHash[:]),
block.NumberU64(),

@ -517,7 +517,7 @@ func (consensus *Consensus) commitBlock(blk *types.Block, committedMsg *FBFTMess
}
atomic.AddUint64(&consensus.blockNum, 1)
consensus.SetCurBlockViewID(committedMsg.ViewID + 1)
consensus.SetViewIDs(committedMsg.ViewID + 1)
consensus.LeaderPubKey = committedMsg.SenderPubkeys[0]
// Update consensus keys at last so the change of leader status doesn't mess up normal flow
if blk.IsLastBlockInEpoch() {

@ -131,9 +131,8 @@ func (consensus *Consensus) getNextViewID() (uint64, time.Duration) {
if curTimestamp <= blockTimestamp {
return consensus.fallbackNextViewID()
}
totalNode := consensus.Decider.ParticipantsCount()
// diff is at least 1, and it won't exceed the totalNode
diff := uint64(((curTimestamp - blockTimestamp) / viewChangeTimeout) % int64(totalNode))
diff := uint64((curTimestamp - blockTimestamp) / viewChangeTimeout)
nextViewID := diff + consensus.GetCurBlockViewID()
consensus.getLogger().Info().

Loading…
Cancel
Save