diff --git a/consensus/consensus_v2.go b/consensus/consensus_v2.go index 5ebb94736..2d930da09 100644 --- a/consensus/consensus_v2.go +++ b/consensus/consensus_v2.go @@ -235,7 +235,7 @@ func (consensus *Consensus) onAnnounce(msg *msg_pb.Message) { logMsgs := consensus.PbftLog.GetMessagesByTypeSeqView(msg_pb.MessageType_ANNOUNCE, recvMsg.BlockNum, recvMsg.ViewID) if len(logMsgs) > 0 { - if logMsgs[0].BlockHash != recvMsg.BlockHash { + if logMsgs[0].BlockHash != recvMsg.BlockHash && logMsgs[0].SenderPubkey.IsEqual(recvMsg.SenderPubkey) { utils.Logger().Debug(). Str("leaderKey", consensus.LeaderPubKey.SerializeToHexStr()). Msg("[OnAnnounce] Leader is malicious") diff --git a/consensus/view_change.go b/consensus/view_change.go index 6f5bd533d..6e323aedc 100644 --- a/consensus/view_change.go +++ b/consensus/view_change.go @@ -223,6 +223,7 @@ func (consensus *Consensus) onViewChange(msg *msg_pb.Message) { } // TODO: if difference is only one, new leader can still propose the same committed block to avoid another view change + // TODO: new leader catchup without ignore view change message if consensus.blockNum > recvMsg.BlockNum { utils.Logger().Debug(). Uint64("MsgBlockNum", recvMsg.BlockNum). @@ -252,6 +253,7 @@ func (consensus *Consensus) onViewChange(msg *msg_pb.Message) { consensus.vcLock.Lock() defer consensus.vcLock.Unlock() + // TODO: remove NIL type message // add self m1 or m2 type message signature and bitmap _, ok1 := consensus.nilSigs[consensus.PubKey.SerializeToHexStr()] _, ok2 := consensus.bhpSigs[consensus.PubKey.SerializeToHexStr()] @@ -554,6 +556,7 @@ func (consensus *Consensus) onNewView(msg *msg_pb.Message) { } // NewView message is verified, change state to normal consensus + // TODO: check magic number 32 if len(recvMsg.Payload) > 32 { // Construct and send the commit message blockNumHash := make([]byte, 8)