Skip to content

Commit

Permalink
finality: add more check to ensure reuslt of assembleVoteAttestation (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanBSC authored Aug 2, 2023
1 parent 522d4cd commit 54dbb2b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,11 @@ func (p *Parlia) assembleVoteAttestation(chain consensus.ChainHeaderReader, head
attestation.VoteAddressSet |= 1 << (valInfo.Index - 1) //Index is offset by 1
}
}
validatorsBitSet := bitset.From([]uint64{uint64(attestation.VoteAddressSet)})
if validatorsBitSet.Count() < uint(len(signatures)) {
log.Warn(fmt.Sprintf("assembleVoteAttestation, check VoteAddress Set failed, expected:%d, real:%d", len(signatures), validatorsBitSet.Count()))
return fmt.Errorf("invalid attestation, check VoteAddress Set failed")
}

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

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

0 comments on commit 54dbb2b

Please sign in to comment.