Merge pull request #3400 from JackyWYX/fix_epoch_leader_change

[consensus] fix leader change during epoch change
pull/3403/head
Rongjian Lan 4 years ago committed by GitHub
commit 1a915c0582
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      consensus/consensus_v2.go
  2. 4
      node/node_handler.go

@ -521,6 +521,10 @@ func (consensus *Consensus) commitBlock(blk *types.Block, committedMsg *FBFTMess
atomic.AddUint64(&consensus.blockNum, 1)
consensus.SetCurBlockViewID(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() {
consensus.SetMode(consensus.UpdateConsensusInformation())
}
consensus.ResetState()
return nil
}

@ -395,10 +395,6 @@ func (node *Node) PostConsensusProcessing(newBlock *types.Block) error {
// Broadcast client requested missing cross shard receipts if there is any
node.BroadcastMissingCXReceipts()
// Update consensus keys at last so the change of leader status doesn't mess up normal flow
if newBlock.IsLastBlockInEpoch() {
node.Consensus.SetMode(node.Consensus.UpdateConsensusInformation())
}
if h := node.NodeConfig.WebHooks.Hooks; h != nil {
if h.Availability != nil {
for _, addr := range node.GetAddresses(newBlock.Epoch()) {

Loading…
Cancel
Save