Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finality: add more check to ensure reuslt of assembleVoteAttestation #1791

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) {
brilliant-lx marked this conversation as resolved.
Show resolved Hide resolved
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