From 0784bac4df71132f97e2d990b54d75b25165cb32 Mon Sep 17 00:00:00 2001 From: William Banfield Date: Sun, 15 May 2022 22:39:07 -0400 Subject: [PATCH] fix nil pointer error for non-validator --- internal/consensus/state.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/consensus/state.go b/internal/consensus/state.go index 63a45444a..6d6edc1b8 100644 --- a/internal/consensus/state.go +++ b/internal/consensus/state.go @@ -2366,12 +2366,14 @@ func (cs *State) addVote( return } - _ = vote.ValidatorAddress - _ = cs.privValidatorPubKey.Address() + var addr []byte + if cs.privValidatorPubKey != nil { + addr = cs.privValidatorPubKey.Address() + } // Verify VoteExtension if precommit and not nil // https://github.com/tendermint/tendermint/issues/8487 if vote.Type == tmproto.PrecommitType && !vote.BlockID.IsNil() && - !bytes.Equal(vote.ValidatorAddress, cs.privValidatorPubKey.Address()) { + !bytes.Equal(vote.ValidatorAddress, addr) { // The core fields of the vote message were already validated in the // consensus reactor when the vote was received. // Here, we valdiate that the vote extension was included in the vote