mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
consensus/bor: validate valset from header at sprint end (#7438)
This PR adds changes from https://github.com/maticnetwork/bor/pull/768 and https://github.com/maticnetwork/bor/pull/787. Note that bor fetches the data from the child chain contract via `getBorValidators` method while erigon does it via fetching the required span from heimdall (or cache if present). Hence, as done in bor, we don't really need to create new methods to get data via block number or hash.
This commit is contained in:
parent
f38ec1e772
commit
b4fc18ad14
@ -477,6 +477,33 @@ func (c *Bor) verifyCascadingFields(chain consensus.ChainHeaderReader, header *t
|
||||
return err
|
||||
}
|
||||
|
||||
// Verify the validator list match the local contract
|
||||
if isSprintStart(number+1, c.config.CalculateSprint(number)) {
|
||||
newValidators, err := c.spanner.GetCurrentValidators(number+1, c.authorizedSigner.Load().signer, c.getSpanForBlock)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sort.Sort(valset.ValidatorsByAddress(newValidators))
|
||||
|
||||
headerVals, err := valset.ParseValidators(header.Extra[extraVanity : len(header.Extra)-extraSeal])
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(newValidators) != len(headerVals) {
|
||||
return errInvalidSpanValidators
|
||||
}
|
||||
|
||||
for i, val := range newValidators {
|
||||
if !bytes.Equal(val.HeaderBytes(), headerVals[i].HeaderBytes()) {
|
||||
return errInvalidSpanValidators
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// verify the validator list in the last sprint block
|
||||
if isSprintStart(number, c.config.CalculateSprint(number)) {
|
||||
parentValidatorBytes := parent.Extra[extraVanity : len(parent.Extra)-extraSeal]
|
||||
|
Loading…
Reference in New Issue
Block a user