From 716f5855406fd02502859f40cbcdd3a1827d7614 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Mon, 12 Aug 2024 12:39:05 +0200 Subject: [PATCH] fix(consensus): vote extensions verified multiple times --- 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