fix nil pointer error for non-validator

This commit is contained in:
William Banfield
2022-05-15 22:39:07 -04:00
parent c92f3d2f33
commit 0784bac4df

View File

@@ -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