From 1e03507f92135abea19273d937d3915af1ac96b2 Mon Sep 17 00:00:00 2001 From: Ganesha Upadhyaya Date: Wed, 25 Mar 2020 12:15:45 -0700 Subject: [PATCH] fixing minor things in view change --- consensus/checks.go | 15 +++++++++++---- consensus/view_change.go | 11 ++++++----- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/consensus/checks.go b/consensus/checks.go index 24de07851..aa8400ddf 100644 --- a/consensus/checks.go +++ b/consensus/checks.go @@ -184,10 +184,17 @@ func (consensus *Consensus) viewChangeSanityCheck(msg *msg_pb.Message) bool { Msg("[viewChangeSanityCheck] Checking new message") senderKey, err := consensus.verifyViewChangeSenderKey(msg) if err != nil { - consensus.getLogger().Error().Err(err).Msgf( - "[%s] VerifySenderKey Failed", - msg.GetType().String(), - ) + if err == shard.ErrValidNotInCommittee { + consensus.getLogger().Info().Msgf( + "[%s] sender key not in this slot's subcommittee", + msg.GetType().String(), + ) + } else { + consensus.getLogger().Error().Err(err).Msgf( + "[%s] VerifySenderKey Failed", + msg.GetType().String(), + ) + } return false } if err := verifyMessageSig(senderKey, msg); err != nil { diff --git a/consensus/view_change.go b/consensus/view_change.go index 20c555082..ded31fbc5 100644 --- a/consensus/view_change.go +++ b/consensus/view_change.go @@ -152,6 +152,12 @@ func (consensus *Consensus) onViewChange(msg *msg_pb.Message) { consensus.getLogger().Warn().Msg("[onViewChange] Unable To Parse Viewchange Message") return } + // if not leader, noop + newLeaderKey := recvMsg.LeaderPubkey + newLeaderPriKey, err := consensus.GetLeaderPrivateKey(newLeaderKey) + if err != nil { + return + } if consensus.Decider.IsQuorumAchieved(quorum.ViewChange) { consensus.getLogger().Debug(). @@ -167,11 +173,6 @@ func (consensus *Consensus) onViewChange(msg *msg_pb.Message) { } senderKey := recvMsg.SenderPubkey - newLeaderKey := recvMsg.LeaderPubkey - newLeaderPriKey, err := consensus.GetLeaderPrivateKey(newLeaderKey) - if err != nil { - return - } consensus.vcLock.Lock() defer consensus.vcLock.Unlock()