@ -103,6 +103,7 @@ func (consensus *Consensus) announce(block *types.Block) {
}
consensus . PbftLog . AddMessage ( pbftMsg )
consensus . getLogger ( ) . Debug ( "[Announce] Added Announce message in pbftLog" , "MsgblockHash" , pbftMsg . BlockHash , "MsgViewID" , pbftMsg . ViewID , "MsgBlockNum" , pbftMsg . BlockNum )
consensus . PbftLog . AddBlock ( block )
// Leader sign the block hash itself
@ -116,7 +117,7 @@ func (consensus *Consensus) announce(block *types.Block) {
if err := consensus . host . SendMessageToGroups ( [ ] p2p . GroupID { p2p . NewGroupIDByShardID ( p2p . ShardID ( consensus . ShardID ) ) } , host . ConstructP2pMessage ( byte ( 17 ) , msgToSend ) ) ; err != nil {
consensus . getLogger ( ) . Warn ( "[Announce] Cannot send announce message" , "groupID" , p2p . NewGroupIDByShardID ( p2p . ShardID ( consensus . ShardID ) ) )
} else {
consensus . getLogger ( ) . Debug ( "[Announce] Sent Announce Message!!" , "BlockHash" , block . Hash ( ) , "BlockNum" , block . NumberU64 ( ) )
consensus . getLogger ( ) . Info ( "[Announce] Sent Announce Message!!" , "BlockHash" , block . Hash ( ) , "BlockNum" , block . NumberU64 ( ) )
}
consensus . getLogger ( ) . Debug ( "[Announce] Switching phase" , "From" , consensus . phase , "To" , Prepare )
@ -175,7 +176,8 @@ func (consensus *Consensus) onAnnounce(msg *msg_pb.Message) {
consensus . getLogger ( ) . Debug ( "[OnAnnounce] Leader is malicious" , "leaderKey" , consensus . LeaderPubKey . SerializeToHexStr ( ) )
consensus . startViewChange ( consensus . viewID + 1 )
}
return
consensus . getLogger ( ) . Debug ( "[OnAnnounce] Announce message received again" , "leaderKey" , consensus . LeaderPubKey . SerializeToHexStr ( ) )
//return
}
consensus . getLogger ( ) . Debug ( "[OnAnnounce] Announce message Added" , "MsgViewID" , recvMsg . ViewID , "MsgBlockNum" , recvMsg . BlockNum )
@ -247,7 +249,7 @@ func (consensus *Consensus) onPrepare(msg *msg_pb.Message) {
if ! consensus . PbftLog . HasMatchingViewAnnounce ( consensus . blockNum , consensus . viewID , recvMsg . BlockHash ) {
consensus . getLogger ( ) . Debug ( "[OnPrepare] No Matching Announce message" , "MsgblockHash" , recvMsg . BlockHash , "MsgBlockNum" , recvMsg . BlockNum )
return
//return
}
validatorPubKey := recvMsg . SenderPubkey . SerializeToHexStr ( )
@ -260,7 +262,7 @@ func (consensus *Consensus) onPrepare(msg *msg_pb.Message) {
defer consensus . mutex . Unlock ( )
if len ( prepareSigs ) >= consensus . Quorum ( ) {
// already have enough signatures
consensus . getLogger ( ) . Info ( "[OnPrepare] Received Additional Prepare Message" , "ValidatorPubKey" , validatorPubKey )
consensus . getLogger ( ) . Debug ( "[OnPrepare] Received Additional Prepare Message" , "ValidatorPubKey" , validatorPubKey )
return
}
// proceed only when the message is not received before
@ -282,7 +284,7 @@ func (consensus *Consensus) onPrepare(msg *msg_pb.Message) {
return
}
consensus . getLogger ( ) . Debug ( "[OnPrepare] Received New Prepare Signature" , "NumReceivedSoFar" , len ( prepareSigs ) , "validatorPubKey" , validatorPubKey , "PublicKeys" , len ( consensus . PublicKeys ) )
consensus . getLogger ( ) . Info ( "[OnPrepare] Received New Prepare Signature" , "NumReceivedSoFar" , len ( prepareSigs ) , "validatorPubKey" , validatorPubKey , "PublicKeys" , len ( consensus . PublicKeys ) )
prepareSigs [ validatorPubKey ] = & sign
// Set the bitmap indicating that this validator signed.
if err := prepareBitmap . SetKey ( recvMsg . SenderPubkey , true ) ; err != nil {
@ -463,7 +465,7 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) {
if err := consensus . host . SendMessageToGroups ( [ ] p2p . GroupID { p2p . NewGroupIDByShardID ( p2p . ShardID ( consensus . ShardID ) ) } , host . ConstructP2pMessage ( byte ( 17 ) , msgToSend ) ) ; err != nil {
consensus . getLogger ( ) . Warn ( "[OnPrepared] Cannot send commit message!!" )
} else {
consensus . getLogger ( ) . Debug ( "[OnPrepared] Sent Commit Message!!" , "BlockHash" , consensus . blockHash , "BlockNum" , consensus . blockNum )
consensus . getLogger ( ) . Info ( "[OnPrepared] Sent Commit Message!!" , "BlockHash" , consensus . blockHash , "BlockNum" , consensus . blockNum )
}
consensus . getLogger ( ) . Debug ( "[OnPrepared] Switching phase" , "From" , consensus . phase , "To" , Commit )
@ -527,7 +529,7 @@ func (consensus *Consensus) onCommit(msg *msg_pb.Message) {
// proceed only when the message is not received before
_ , ok := commitSigs [ validatorPubKey ]
if ok {
consensus . getLogger ( ) . Info ( "[OnCommit] Already received commit message from the validator" , "validatorPubKey" , validatorPubKey )
consensus . getLogger ( ) . Debug ( "[OnCommit] Already received commit message from the validator" , "validatorPubKey" , validatorPubKey )
return
}
@ -548,7 +550,7 @@ func (consensus *Consensus) onCommit(msg *msg_pb.Message) {
return
}
consensus . getLogger ( ) . Debug ( "[OnCommit] Received new commit message" , "numReceivedSoFar" , len ( commitSigs ) , "MsgViewID" , recvMsg . ViewID , "MsgBlockNum" , recvMsg . BlockNum , "validatorPubKey" , validatorPubKey )
consensus . getLogger ( ) . Info ( "[OnCommit] Received new commit message" , "numReceivedSoFar" , len ( commitSigs ) , "MsgViewID" , recvMsg . ViewID , "MsgBlockNum" , recvMsg . BlockNum , "validatorPubKey" , validatorPubKey )
commitSigs [ validatorPubKey ] = & sign
// Set the bitmap indicating that this validator signed.
if err := commitBitmap . SetKey ( recvMsg . SenderPubkey , true ) ; err != nil {
@ -571,7 +573,7 @@ func (consensus *Consensus) onCommit(msg *msg_pb.Message) {
if rewardThresholdIsMet {
go func ( viewID uint64 ) {
consensus . commitFinishChan <- viewID
consensus . getLogger ( ) . Debug ( "[OnCommit] 90% Enough commits received" , "NumCommits" , len ( commitSigs ) )
consensus . getLogger ( ) . Info ( "[OnCommit] 90% Enough commits received" , "NumCommits" , len ( commitSigs ) )
} ( consensus . viewID )
}
}
@ -612,7 +614,7 @@ func (consensus *Consensus) finalizeCommits() {
if err := consensus . host . SendMessageToGroups ( [ ] p2p . GroupID { p2p . NewGroupIDByShardID ( p2p . ShardID ( consensus . ShardID ) ) } , host . ConstructP2pMessage ( byte ( 17 ) , msgToSend ) ) ; err != nil {
consensus . getLogger ( ) . Warn ( "[Finalizing] Cannot send committed message" , "error" , err )
} else {
consensus . getLogger ( ) . Debug ( "[Finalizing] Sent Committed Message" , "BlockHash" , consensus . blockHash , "BlockNum" , consensus . blockNum )
consensus . getLogger ( ) . Info ( "[Finalizing] Sent Committed Message" , "BlockHash" , consensus . blockHash , "BlockNum" , consensus . blockNum )
}
consensus . reportMetrics ( * block )