|
|
@ -161,23 +161,33 @@ func (consensus *Consensus) finalCommit() { |
|
|
|
// Note: leader already sent 67% commit in preCommit. The 100% commit won't be sent immediately
|
|
|
|
// Note: leader already sent 67% commit in preCommit. The 100% commit won't be sent immediately
|
|
|
|
// to save network traffic. It will only be sent in retry if consensus doesn't move forward.
|
|
|
|
// to save network traffic. It will only be sent in retry if consensus doesn't move forward.
|
|
|
|
// Or if the leader is changed for next block, the 100% committed sig will be sent to the next leader immediately.
|
|
|
|
// Or if the leader is changed for next block, the 100% committed sig will be sent to the next leader immediately.
|
|
|
|
sendImmediately := false |
|
|
|
|
|
|
|
if !consensus.IsLeader() || block.IsLastBlockInEpoch() { |
|
|
|
if !consensus.IsLeader() || block.IsLastBlockInEpoch() { |
|
|
|
sendImmediately = true |
|
|
|
// send immediately
|
|
|
|
} |
|
|
|
if err := consensus.msgSender.SendWithRetry( |
|
|
|
if err := consensus.msgSender.SendWithRetry( |
|
|
|
block.NumberU64(), |
|
|
|
block.NumberU64(), |
|
|
|
msg_pb.MessageType_COMMITTED, []nodeconfig.GroupID{ |
|
|
|
msg_pb.MessageType_COMMITTED, []nodeconfig.GroupID{ |
|
|
|
nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(consensus.ShardID)), |
|
|
|
nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(consensus.ShardID)), |
|
|
|
}, |
|
|
|
}, |
|
|
|
p2p.ConstructMessage(msgToSend)); err != nil { |
|
|
|
p2p.ConstructMessage(msgToSend), |
|
|
|
consensus.getLogger().Warn().Err(err).Msg("[finalCommit] Cannot send committed message") |
|
|
|
sendImmediately); err != nil { |
|
|
|
} else { |
|
|
|
consensus.getLogger().Warn().Err(err).Msg("[finalCommit] Cannot send committed message") |
|
|
|
consensus.getLogger().Info(). |
|
|
|
|
|
|
|
Hex("blockHash", curBlockHash[:]). |
|
|
|
|
|
|
|
Uint64("blockNum", consensus.blockNum). |
|
|
|
|
|
|
|
Msg("[finalCommit] Sent Committed Message") |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
// delayed send
|
|
|
|
|
|
|
|
consensus.msgSender.DelayedSendWithRetry( |
|
|
|
|
|
|
|
block.NumberU64(), |
|
|
|
|
|
|
|
msg_pb.MessageType_COMMITTED, []nodeconfig.GroupID{ |
|
|
|
|
|
|
|
nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(consensus.ShardID)), |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
p2p.ConstructMessage(msgToSend)) |
|
|
|
consensus.getLogger().Info(). |
|
|
|
consensus.getLogger().Info(). |
|
|
|
Hex("blockHash", curBlockHash[:]). |
|
|
|
Hex("blockHash", curBlockHash[:]). |
|
|
|
Uint64("blockNum", consensus.blockNum). |
|
|
|
Uint64("blockNum", consensus.blockNum). |
|
|
|
Msg("[finalCommit] Sent Committed Message") |
|
|
|
Msg("[finalCommit] Queued Committed Message") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Dump new block into level db
|
|
|
|
// Dump new block into level db
|
|
|
@ -550,8 +560,7 @@ func (consensus *Consensus) preCommitAndPropose(blk *types.Block) error { |
|
|
|
msg_pb.MessageType_COMMITTED, []nodeconfig.GroupID{ |
|
|
|
msg_pb.MessageType_COMMITTED, []nodeconfig.GroupID{ |
|
|
|
nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(consensus.ShardID)), |
|
|
|
nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(consensus.ShardID)), |
|
|
|
}, |
|
|
|
}, |
|
|
|
p2p.ConstructMessage(msgToSend), |
|
|
|
p2p.ConstructMessage(msgToSend)); err != nil { |
|
|
|
true); err != nil { |
|
|
|
|
|
|
|
consensus.getLogger().Warn().Err(err).Msg("[preCommitAndPropose] Cannot send committed message") |
|
|
|
consensus.getLogger().Warn().Err(err).Msg("[preCommitAndPropose] Cannot send committed message") |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
consensus.getLogger().Info(). |
|
|
|
consensus.getLogger().Info(). |
|
|
|