diff --git a/consensus/consensus_v2.go b/consensus/consensus_v2.go index eecb1a87c..9a030034a 100644 --- a/consensus/consensus_v2.go +++ b/consensus/consensus_v2.go @@ -107,6 +107,7 @@ func (consensus *Consensus) announce(block *types.Block) { // save announce message to PbftLog msgPayload, _ := proto.GetConsensusMessagePayload(msgToSend) + // TODO(chao): don't unmarshall the message here and direclty pass the original object. msg := &msg_pb.Message{} _ = protobuf.Unmarshal(msgPayload, msg) pbftMsg, err := ParsePbftMessage(msg) @@ -115,6 +116,7 @@ func (consensus *Consensus) announce(block *types.Block) { return } + // TODO(chao): review pbft log data structure consensus.PbftLog.AddMessage(pbftMsg) utils.Logger().Debug(). Str("MsgBlockHash", pbftMsg.BlockHash.Hex()). @@ -183,6 +185,7 @@ func (consensus *Consensus) onAnnounce(msg *msg_pb.Message) { } // verify validity of block header object + // TODO: think about just sending the block hash instead of the header. encodedHeader := recvMsg.Payload header := new(block.Header) err = rlp.DecodeBytes(encodedHeader, header) @@ -384,6 +387,7 @@ func (consensus *Consensus) onPrepare(msg *msg_pb.Message) { consensus.aggregatedPrepareSig = aggSig //leader adds prepared message to log + // TODO(chao): don't unmarshall the payload again msgPayload, _ := proto.GetConsensusMessagePayload(msgToSend) msg := &msg_pb.Message{} _ = protobuf.Unmarshal(msgPayload, msg) @@ -678,6 +682,7 @@ func (consensus *Consensus) onCommit(msg *msg_pb.Message) { return } + // has to be called before verifying signature quorumWasMet := len(commitSigs) >= consensus.Quorum() // Verify the signature on commitPayload is correct diff --git a/node/node_handler.go b/node/node_handler.go index b9b8367ee..0c028b447 100644 --- a/node/node_handler.go +++ b/node/node_handler.go @@ -366,6 +366,7 @@ func (node *Node) PostConsensusProcessing(newBlock *types.Block, commitSigAndBit // Update last consensus time for metrics // TODO: randomly selected a few validators to broadcast messages instead of only leader broadcast + // TODO: refactor the asynchronous calls to separate go routine. node.lastConsensusTime = time.Now().Unix() if node.Consensus.PubKey.IsEqual(node.Consensus.LeaderPubKey) { if node.NodeConfig.ShardID == 0 {