Merge pull request #2605 from gupadhyaya/view-change-fix

Fix view change message level and early return for non-leader
pull/2608/head
Ganesha Upadhyaya 5 years ago committed by GitHub
commit d65afe3db6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      consensus/checks.go
  2. 11
      consensus/view_change.go

@ -184,10 +184,17 @@ func (consensus *Consensus) viewChangeSanityCheck(msg *msg_pb.Message) bool {
Msg("[viewChangeSanityCheck] Checking new message") Msg("[viewChangeSanityCheck] Checking new message")
senderKey, err := consensus.verifyViewChangeSenderKey(msg) senderKey, err := consensus.verifyViewChangeSenderKey(msg)
if err != nil { if err != nil {
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( consensus.getLogger().Error().Err(err).Msgf(
"[%s] VerifySenderKey Failed", "[%s] VerifySenderKey Failed",
msg.GetType().String(), msg.GetType().String(),
) )
}
return false return false
} }
if err := verifyMessageSig(senderKey, msg); err != nil { if err := verifyMessageSig(senderKey, msg); err != nil {

@ -152,6 +152,12 @@ func (consensus *Consensus) onViewChange(msg *msg_pb.Message) {
consensus.getLogger().Warn().Msg("[onViewChange] Unable To Parse Viewchange Message") consensus.getLogger().Warn().Msg("[onViewChange] Unable To Parse Viewchange Message")
return return
} }
// if not leader, noop
newLeaderKey := recvMsg.LeaderPubkey
newLeaderPriKey, err := consensus.GetLeaderPrivateKey(newLeaderKey)
if err != nil {
return
}
if consensus.Decider.IsQuorumAchieved(quorum.ViewChange) { if consensus.Decider.IsQuorumAchieved(quorum.ViewChange) {
consensus.getLogger().Debug(). consensus.getLogger().Debug().
@ -167,11 +173,6 @@ func (consensus *Consensus) onViewChange(msg *msg_pb.Message) {
} }
senderKey := recvMsg.SenderPubkey senderKey := recvMsg.SenderPubkey
newLeaderKey := recvMsg.LeaderPubkey
newLeaderPriKey, err := consensus.GetLeaderPrivateKey(newLeaderKey)
if err != nil {
return
}
consensus.vcLock.Lock() consensus.vcLock.Lock()
defer consensus.vcLock.Unlock() defer consensus.vcLock.Unlock()

Loading…
Cancel
Save