Skip to content

Commit 54dbb2b

Browse files
authored
finality: add more check to ensure reuslt of assembleVoteAttestation (#1791)
1 parent 522d4cd commit 54dbb2b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

consensus/parlia/parlia.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,11 @@ func (p *Parlia) assembleVoteAttestation(chain consensus.ChainHeaderReader, head
882882
attestation.VoteAddressSet |= 1 << (valInfo.Index - 1) //Index is offset by 1
883883
}
884884
}
885+
validatorsBitSet := bitset.From([]uint64{uint64(attestation.VoteAddressSet)})
886+
if validatorsBitSet.Count() < uint(len(signatures)) {
887+
log.Warn(fmt.Sprintf("assembleVoteAttestation, check VoteAddress Set failed, expected:%d, real:%d", len(signatures), validatorsBitSet.Count()))
888+
return fmt.Errorf("invalid attestation, check VoteAddress Set failed")
889+
}
885890

886891
// Append attestation to header extra field.
887892
buf := new(bytes.Buffer)
@@ -1758,7 +1763,6 @@ func (p *Parlia) GetFinalizedHeader(chain consensus.ChainHeaderReader, header *t
17581763
return nil
17591764
}
17601765

1761-
// snap.Attestation is nil after plato upgrade, only can happen in local testnet
17621766
if snap.Attestation == nil {
17631767
return chain.GetHeaderByNumber(0) // keep consistent with GetJustifiedNumberAndHash
17641768
}

0 commit comments

Comments
 (0)