From eac51c169f337bb7b4b2f9ef4fbea0a9da8c5b1e Mon Sep 17 00:00:00 2001 From: lklimek <842586+lklimek@users.noreply.github.com> Date: Wed, 14 Aug 2024 16:19:27 +0700 Subject: [PATCH] fix(consensus): vote extensions verified multiple times (#867) --- internal/consensus/state_add_vote.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/consensus/state_add_vote.go b/internal/consensus/state_add_vote.go index 284964cbb..f7bf18251 100644 --- a/internal/consensus/state_add_vote.go +++ b/internal/consensus/state_add_vote.go @@ -1,6 +1,7 @@ package consensus import ( + "bytes" "context" "errors" @@ -238,6 +239,14 @@ func addVoteVerifyVoteExtensionMw( return next(ctx, stateData, vote) } + // If we already know of this vote, return false to not verify it multiple times + existing := stateData.Votes.GetVoteSet(vote.Round, vote.Type).GetByIndex(vote.ValidatorIndex) + if existing != nil && + bytes.Equal(existing.BlockSignature, vote.BlockSignature) && + bytes.Equal(existing.VoteExtensions.Fingerprint(), vote.VoteExtensions.Fingerprint()) { + return false, nil + } + // The core fields of the vote message were already validated in the // consensus reactor when the vote was received. // Here, we verify the signature of the vote extension included in the vote