From 35aa879c7e383f4bbd0bcd5834ef798e3432d412 Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Tue, 12 Apr 2022 13:53:32 -0400 Subject: [PATCH] Only set vote extension signatures when signing is successful Signed-off-by: Thane Thomson --- privval/file.go | 3 ++- types/priv_validator.go | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/privval/file.go b/privval/file.go index cefbef376..a0835cfeb 100644 --- a/privval/file.go +++ b/privval/file.go @@ -405,10 +405,11 @@ func (pv *FilePV) signVote(chainID string, vote *tmproto.Vote) error { vote.Signature = sig // Sign the vote extension, regardless of whether it's present or not - vote.ExtensionSignature, err = pv.Key.PrivKey.Sign(extSignBytes) + extSig, err := pv.Key.PrivKey.Sign(extSignBytes) if err != nil { return err } + vote.ExtensionSignature = extSig return nil } diff --git a/types/priv_validator.go b/types/priv_validator.go index cbf3896fd..29620f829 100644 --- a/types/priv_validator.go +++ b/types/priv_validator.go @@ -96,8 +96,12 @@ func (pv MockPV) SignVote(ctx context.Context, chainID string, vote *tmproto.Vot return err } vote.Signature = sig - vote.ExtensionSignature, err = pv.PrivKey.Sign(extSignBytes) - return err + extSig, err := pv.PrivKey.Sign(extSignBytes) + if err != nil { + return err + } + vote.ExtensionSignature = extSig + return nil } // Implements PrivValidator.