Skip to content

Commit

Permalink
consensus/parlia: hardfork block can be epoch block (bnb-chain#1964)
Browse files Browse the repository at this point in the history
  • Loading branch information
buddh0 authored and weiihann committed Dec 5, 2023
1 parent 72455d2 commit 59e52fd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,13 @@ func (p *Parlia) prepareValidators(header *types.Header) error {
}
} else {
header.Extra = append(header.Extra, byte(len(newValidators)))
if p.chainConfig.IsOnLuban(header.Number) {
voteAddressMap = make(map[common.Address]*types.BLSPublicKey, len(newValidators))
var zeroBlsKey types.BLSPublicKey
for _, validator := range newValidators {
voteAddressMap[validator] = &zeroBlsKey
}
}
for _, validator := range newValidators {
header.Extra = append(header.Extra, validator.Bytes()...)
header.Extra = append(header.Extra, voteAddressMap[validator].Bytes()...)
Expand Down Expand Up @@ -989,6 +996,13 @@ func (p *Parlia) verifyValidators(header *types.Header) error {
return errMismatchingEpochValidators
}
validatorsBytes = make([]byte, validatorsNumber*validatorBytesLength)
if p.chainConfig.IsOnLuban(header.Number) {
voteAddressMap = make(map[common.Address]*types.BLSPublicKey, len(newValidators))
var zeroBlsKey types.BLSPublicKey
for _, validator := range newValidators {
voteAddressMap[validator] = &zeroBlsKey
}
}
for i, validator := range newValidators {
copy(validatorsBytes[i*validatorBytesLength:], validator.Bytes())
copy(validatorsBytes[i*validatorBytesLength+common.AddressLength:], voteAddressMap[validator].Bytes())
Expand Down

0 comments on commit 59e52fd

Please sign in to comment.