diff --git a/common/types_test.go b/common/types_test.go index e481db96c35f..0bf9cb4ba959 100644 --- a/common/types_test.go +++ b/common/types_test.go @@ -151,7 +151,7 @@ func BenchmarkAddressHex(b *testing.B) { } func TestRemoveItemInArray(t *testing.T) { - array := []Address{HexToAddress("0x0000003"),HexToAddress("0x0000001"), HexToAddress("0x0000002"),HexToAddress("0x0000003")} + array := []Address{HexToAddress("0x0000003"), HexToAddress("0x0000001"), HexToAddress("0x0000002"), HexToAddress("0x0000003")} remove := []Address{HexToAddress("0x0000002"), HexToAddress("0x0000004"), HexToAddress("0x0000003")} array = RemoveItemFromArray(array, remove) if len(array) != 1 { diff --git a/consensus/errors.go b/consensus/errors.go index c4ff2de5394f..cb3d7eecb094 100644 --- a/consensus/errors.go +++ b/consensus/errors.go @@ -35,5 +35,7 @@ var ( // plus one. ErrInvalidNumber = errors.New("invalid block number") - ErrMissingValidatorSignature = errors.New("missing validator in header") + ErrFailValidatorSignature = errors.New("missing validator in header") + + ErrNoValidatorSignature = errors.New("no validator in header") ) diff --git a/consensus/posv/posv.go b/consensus/posv/posv.go index 43c9cf893af2..f168e92c84d1 100644 --- a/consensus/posv/posv.go +++ b/consensus/posv/posv.go @@ -370,6 +370,9 @@ func (c *Posv) verifyCascadingFields(chain consensus.ChainReader, header *types. if parent.Time.Uint64()+c.config.Period > header.Time.Uint64() { return ErrInvalidTimestamp } + if header.Number.Uint64() > c.config.Epoch && len(header.Validator) == 0 { + return consensus.ErrNoValidatorSignature + } // Retrieve the snapshot needed to verify this header and cache it snap, err := c.snapshot(chain, number-1, header.ParentHash, parents) if err != nil { @@ -959,7 +962,7 @@ func (c *Posv) RecoverValidator(header *types.Header) (common.Address, error) { // Retrieve the signature from the header.Validator // len equals 65 bytes if len(header.Validator) != extraSeal { - return common.Address{}, consensus.ErrMissingValidatorSignature + return common.Address{}, consensus.ErrFailValidatorSignature } // Recover the public key and the Ethereum address pubkey, err := crypto.Ecrecover(sigHash(header).Bytes(), header.Validator) diff --git a/eth/fetcher/fetcher.go b/eth/fetcher/fetcher.go index 01f8748c5f2e..4b748c9d1da2 100644 --- a/eth/fetcher/fetcher.go +++ b/eth/fetcher/fetcher.go @@ -669,7 +669,7 @@ func (f *Fetcher) insert(peer string, block *types.Block) { time.Sleep(delay) log.Info("Receive future block", "number", block.NumberU64(), "hash", block.Hash().Hex(), "delay", delay) goto again - case consensus.ErrMissingValidatorSignature: + case consensus.ErrNoValidatorSignature: newBlock := block if f.appendM2HeaderHook != nil { if newBlock, err = f.appendM2HeaderHook(block); err != nil {