Skip to content

Commit

Permalink
Merge pull request ethereum#293 from nguyenbatam/ignore_faster_with_b…
Browse files Browse the repository at this point in the history
…lock_no_validator_m2

ignore faster with block no M2 Validator
  • Loading branch information
nguyenbatam authored Nov 21, 2018
2 parents c674e76 + 08cda1b commit 2a7e0dd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion common/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion consensus/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
5 changes: 4 additions & 1 deletion consensus/posv/posv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion eth/fetcher/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2a7e0dd

Please sign in to comment.