From 67a167eb3a6f2af08cc78e40981b30374ab5e471 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Thu, 15 Oct 2020 06:49:49 +0000 Subject: [PATCH] [viewchange] filter out viewchange message in p2p validation filter out viewchange/newview message when the validator is not in viewchanging mode. Signed-off-by: Leo Chen --- consensus/consensus_v2.go | 7 ------- node/node.go | 4 ++-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/consensus/consensus_v2.go b/consensus/consensus_v2.go index a5b88a993..10f52a16a 100644 --- a/consensus/consensus_v2.go +++ b/consensus/consensus_v2.go @@ -43,13 +43,6 @@ func (consensus *Consensus) HandleMessageUpdate(ctx context.Context, msg *msg_pb return nil } - // when node is not in ViewChanging mode, ignore viewchange / newview messages - if !consensus.IsViewChangingMode() && - (msg.Type == msg_pb.MessageType_VIEWCHANGE || - msg.Type == msg_pb.MessageType_NEWVIEW) { - return nil - } - intendedForValidator, intendedForLeader := !consensus.IsLeader(), consensus.IsLeader() diff --git a/node/node.go b/node/node.go index 1a1abe72c..bbf42e3fb 100644 --- a/node/node.go +++ b/node/node.go @@ -461,9 +461,9 @@ func (node *Node) validateShardBoundMessage( return nil, nil, true, nil } } else { - // ignore newview message if the node is not in viewchanging mode + // ignore viewchange/newview message if the node is not in viewchanging mode switch m.Type { - case msg_pb.MessageType_NEWVIEW: + case msg_pb.MessageType_NEWVIEW, msg_pb.MessageType_VIEWCHANGE: return nil, nil, true, nil } }