add log messages to debug consensus issues

Signed-off-by: Leo Chen <leo@harmony.one>
pull/498/head
Leo Chen 6 years ago
parent d2dfbc3d52
commit ad41838dd6
  1. 3
      consensus/consensus.go
  2. 3
      consensus/consensus_leader.go
  3. 2
      consensus/consensus_validator.go
  4. 9
      node/node_handler.go

@ -258,7 +258,6 @@ func (consensus *Consensus) checkConsensusMessage(message *msg_pb.Message, publi
consensusID := consensusMsg.ConsensusId
blockHash := consensusMsg.BlockHash
utils.GetLogInstance().Warn("checkConsensusMessage", "consensusID", consensusID, "blockHash", blockHash)
// Verify message signature
err := verifyMessageSig(publicKey, message)
if err != nil {
@ -655,6 +654,8 @@ func (consensus *Consensus) populateMessageFields(request *msg_pb.ConsensusReque
// 4 byte sender id
request.SenderId = uint32(consensus.nodeID)
utils.GetLogInstance().Debug("[populateMessageFields]", "myConsensusID", consensus.consensusID, "SenderId", request.SenderId)
}
// Signs the consensus message and returns the marshaled message.

@ -148,6 +148,7 @@ func (consensus *Consensus) startConsensus(newBlock *types.Block) {
if utils.UseLibP2P {
// Construct broadcast p2p message
utils.GetLogInstance().Warn("[Consensus]", "sent announce message", len(msgToSend))
consensus.host.SendMessageToGroups([]p2p.GroupID{p2p.GroupIDBeacon}, host.ConstructP2pMessage(byte(17), msgToSend))
} else {
host.BroadcastMessageFromLeader(consensus.host, consensus.GetValidatorPeers(), msgToSend, consensus.OfflinePeers)
@ -217,6 +218,7 @@ func (consensus *Consensus) processPrepareMessage(message *msg_pb.Message) {
consensus.aggregatedPrepareSig = aggSig
if utils.UseLibP2P {
utils.GetLogInstance().Warn("[Consensus]", "sent prepared message", len(msgToSend))
consensus.host.SendMessageToGroups([]p2p.GroupID{p2p.GroupIDBeacon}, host.ConstructP2pMessage(byte(17), msgToSend))
} else {
host.BroadcastMessageFromLeader(consensus.host, consensus.GetValidatorPeers(), msgToSend, consensus.OfflinePeers)
@ -295,6 +297,7 @@ func (consensus *Consensus) processCommitMessage(message *msg_pb.Message) {
consensus.aggregatedCommitSig = aggSig
if utils.UseLibP2P {
utils.GetLogInstance().Warn("[Consensus]", "sent committed message", len(msgToSend))
consensus.host.SendMessageToGroups([]p2p.GroupID{p2p.GroupIDBeacon}, host.ConstructP2pMessage(byte(17), msgToSend))
} else {
host.BroadcastMessageFromLeader(consensus.host, consensus.GetValidatorPeers(), msgToSend, consensus.OfflinePeers)

@ -123,6 +123,7 @@ func (consensus *Consensus) processAnnounceMessage(message *msg_pb.Message) {
// Construct and send prepare message
msgToSend := consensus.constructPrepareMessage()
if utils.UseLibP2P {
utils.GetLogInstance().Warn("[Consensus]", "sent prepare message", len(msgToSend))
consensus.host.SendMessageToGroups([]p2p.GroupID{p2p.GroupIDBeacon}, host.ConstructP2pMessage(byte(17), msgToSend))
} else {
consensus.SendMessage(consensus.leader, msgToSend)
@ -189,6 +190,7 @@ func (consensus *Consensus) processPreparedMessage(message *msg_pb.Message) {
multiSigAndBitmap := append(multiSig, bitmap...)
msgToSend := consensus.constructCommitMessage(multiSigAndBitmap)
if utils.UseLibP2P {
utils.GetLogInstance().Warn("[Consensus]", "sent commit message", len(msgToSend))
consensus.host.SendMessageToGroups([]p2p.GroupID{p2p.GroupIDBeacon}, host.ConstructP2pMessage(byte(17), msgToSend))
} else {
consensus.SendMessage(consensus.leader, msgToSend)

@ -132,10 +132,10 @@ func (node *Node) messageHandler(content []byte, sender string) {
case proto.Consensus:
msgPayload, _ := proto.GetConsensusMessagePayload(content)
if consensusObj.IsLeader {
utils.GetLogInstance().Info("NET: Leader received message:", "messageCategory", msgCategory)
utils.GetLogInstance().Info("NET: Leader received consensus message")
consensusObj.ProcessMessageLeader(msgPayload)
} else {
utils.GetLogInstance().Info("NET: Validator received message:", "messageCategory", msgCategory)
utils.GetLogInstance().Info("NET: Validator received consensus message")
consensusObj.ProcessMessageValidator(msgPayload)
// TODO(minhdoan): add logic to check if the current blockchain is not sync with other consensus
// we should switch to other state rather than DoingConsensus.
@ -144,10 +144,10 @@ func (node *Node) messageHandler(content []byte, sender string) {
msgPayload, _ := proto.GetDRandMessagePayload(content)
if node.DRand != nil {
if node.DRand.IsLeader {
utils.GetLogInstance().Info("NET: DRand Leader received message:", "messageCategory", msgCategory)
utils.GetLogInstance().Info("NET: DRand Leader received message")
node.DRand.ProcessMessageLeader(msgPayload)
} else {
utils.GetLogInstance().Info("NET: DRand Validator received message:", "messageCategory", msgCategory)
utils.GetLogInstance().Info("NET: DRand Validator received message")
node.DRand.ProcessMessageValidator(msgPayload)
}
}
@ -169,6 +169,7 @@ func (node *Node) messageHandler(content []byte, sender string) {
blockMsgType := proto_node.BlockMessageType(msgPayload[0])
switch blockMsgType {
case proto_node.Sync:
utils.GetLogInstance().Info("NET: received message: Node/Sync")
var blocks []*types.Block
err := rlp.DecodeBytes(msgPayload[1:], &blocks) // skip the Sync messge type
if err != nil {

Loading…
Cancel
Save