Skip to content

Commit

Permalink
fix(consensus): vote extensions verified multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Aug 12, 2024
1 parent 29f8bb5 commit 716f585
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/consensus/state_add_vote.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package consensus

import (
"bytes"
"context"
"errors"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 716f585

Please sign in to comment.