mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
drop peer if received bad block data which does not include the validator field (#494)
Co-authored-by: wjrjerome <wjrjerome@babylonchain.io>
This commit is contained in:
parent
e5317a0ff6
commit
816dce9527
3 changed files with 5 additions and 2 deletions
|
|
@ -36,7 +36,8 @@ func (x *XDPoS_v2) verifyHeader(chain consensus.ChainReader, header *types.Heade
|
|||
}
|
||||
|
||||
if len(header.Validator) == 0 {
|
||||
return consensus.ErrNoValidatorSignature
|
||||
// This should never happen, if it does, then it means the peer is sending us invalid data.
|
||||
return consensus.ErrNoValidatorSignatureV2
|
||||
}
|
||||
|
||||
if fullVerify {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ var (
|
|||
|
||||
ErrNoValidatorSignature = errors.New("no validator in header")
|
||||
|
||||
ErrNoValidatorSignatureV2 = errors.New("no validator in v2 header")
|
||||
|
||||
ErrNotReadyToPropose = errors.New("not ready to propose, QC is not ready")
|
||||
|
||||
ErrNotReadyToMine = errors.New("Not ready to mine, it's not your turn")
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ func TestShouldVerifyBlock(t *testing.T) {
|
|||
noValidatorBlock := blockchain.GetBlockByNumber(902).Header()
|
||||
noValidatorBlock.Validator = []byte{}
|
||||
err = adaptor.VerifyHeader(blockchain, noValidatorBlock, true)
|
||||
assert.Equal(t, consensus.ErrNoValidatorSignature, err)
|
||||
assert.Equal(t, consensus.ErrNoValidatorSignatureV2, err)
|
||||
|
||||
blockFromFuture := blockchain.GetBlockByNumber(902).Header()
|
||||
blockFromFuture.Time = big.NewInt(time.Now().Unix() + 10000)
|
||||
|
|
|
|||
Loading…
Reference in a new issue