bypass header check for signer data loaded from snapshot

This commit is contained in:
Tuna 2018-08-20 10:17:58 +07:00
parent deedbd0f4d
commit 01f2f84188

View file

@ -306,9 +306,6 @@ func (c *Posv) verifyHeader(chain consensus.ChainReader, header *types.Header, p
if !checkpoint && signersBytes != 0 { if !checkpoint && signersBytes != 0 {
return errExtraSigners return errExtraSigners
} }
if checkpoint && signersBytes%common.AddressLength != 0 {
return errInvalidCheckpointSigners
}
// Ensure that the mix digest is zero as we don't have fork protection currently // Ensure that the mix digest is zero as we don't have fork protection currently
if header.MixDigest != (common.Hash{}) { if header.MixDigest != (common.Hash{}) {
return errInvalidMixDigest return errInvalidMixDigest
@ -354,22 +351,6 @@ func (c *Posv) verifyCascadingFields(chain consensus.ChainReader, header *types.
if parent.Time.Uint64()+c.config.Period > header.Time.Uint64() { if parent.Time.Uint64()+c.config.Period > header.Time.Uint64() {
return ErrInvalidTimestamp return ErrInvalidTimestamp
} }
// Retrieve the snapshot needed to verify this header and cache it
snap, err := c.snapshot(chain, number-1, header.ParentHash, parents)
if err != nil {
return err
}
// If the block is a checkpoint block, verify the signer list
if number%c.config.Epoch == 0 {
signers := make([]byte, len(snap.Signers)*common.AddressLength)
for i, signer := range snap.signers() {
copy(signers[i*common.AddressLength:], signer[:])
}
extraSuffix := len(header.Extra) - extraSeal
if !bytes.Equal(header.Extra[extraVanity:extraSuffix], signers) {
return errInvalidCheckpointSigners
}
}
// All basic checks passed, verify the seal and return // All basic checks passed, verify the seal and return
return c.verifySeal(chain, header, parents) return c.verifySeal(chain, header, parents)
} }