Skip to content

Commit

Permalink
use the right aggregated commit checker
Browse files Browse the repository at this point in the history
  • Loading branch information
sergio-mena committed Jan 11, 2025
1 parent d98fefc commit 9739076
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -2608,7 +2608,7 @@ func (cs *State) AddCommit(commit *types.Commit, peerID p2p.ID) (added bool, err
return added, err
}

if !types.IsAggregatedCommit(cs.Validators, commit) {
if !commit.HasAggregatedSignature() {
// Only accept aggregated commits
cs.Logger.Error("Received non aggregated commit for height %v from peer ID %s", commit.Height, peerID)
return added, err
Expand Down
10 changes: 5 additions & 5 deletions types/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ func shouldBatchVerify(vals *ValidatorSet, commit *Commit) bool {
vals.AllKeysHaveSameType()
}

// IsAggregatedCommit returns true if the commit is an aggregated.
func IsAggregatedCommit(vals *ValidatorSet, commit *Commit) bool {
// isAggregatedCommit returns true if the commit is an aggregated.
func isAggregatedCommit(vals *ValidatorSet, commit *Commit) bool {
_, ok := vals.GetProposer().PubKey.(*bls12381.PubKey)
_, ok2 := vals.GetProposer().PubKey.(bls12381.PubKey)
return (ok || ok2) && vals.AllKeysHaveSameType() && commit.HasAggregatedSignature()
Expand Down Expand Up @@ -51,7 +51,7 @@ func VerifyCommit(chainID string, vals *ValidatorSet, blockID BlockID,
ignore := func(c CommitSig) bool { return c.BlockIDFlag == BlockIDFlagAbsent }

// attempt to verify aggregated commit
if IsAggregatedCommit(vals, commit) {
if isAggregatedCommit(vals, commit) {
// only count the signatures that are for the block
count := func(c CommitSig) bool {
return c.BlockIDFlag == BlockIDFlagAggCommit || c.BlockIDFlag == BlockIDFlagAggCommitAbsent
Expand Down Expand Up @@ -129,7 +129,7 @@ func verifyCommitLightInternal(
count := func(_ CommitSig) bool { return true }

// attempt to verify aggregated commit
if IsAggregatedCommit(vals, commit) {
if isAggregatedCommit(vals, commit) {
// ignore all commit signatures that are not for the block
ignore := func(c CommitSig) bool {
return !(c.BlockIDFlag == BlockIDFlagAggCommit || c.BlockIDFlag == BlockIDFlagAggCommitAbsent)
Expand Down Expand Up @@ -220,7 +220,7 @@ func verifyCommitLightTrustingInternal(
count := func(_ CommitSig) bool { return true }

// attempt to verify aggregated commit
if IsAggregatedCommit(vals, commit) {
if isAggregatedCommit(vals, commit) {
// ignore all commit signatures that are not for the block
ignore := func(c CommitSig) bool {
return !(c.BlockIDFlag == BlockIDFlagAggCommit || c.BlockIDFlag == BlockIDFlagAggCommitAbsent)
Expand Down

0 comments on commit 9739076

Please sign in to comment.