From 1a6fbacb648589875493ef596b16fd60b9bd1828 Mon Sep 17 00:00:00 2001 From: Luke Williams Date: Tue, 3 May 2016 16:30:48 +1000 Subject: [PATCH] Enforce that `Extra` field on block matches a preset value --- core/block_validator.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/block_validator.go b/core/block_validator.go index 0e58bf54e0..2c8dbc4052 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -17,6 +17,7 @@ package core import ( + "bytes" "fmt" "math/big" "time" @@ -34,6 +35,7 @@ var ( ExpDiffPeriod = big.NewInt(100000) big10 = big.NewInt(10) bigMinus99 = big.NewInt(-99) + needExtraData = []byte("hello!") ) // BlockValidator is responsible for validating block headers, uncles and @@ -197,6 +199,9 @@ func (v *BlockValidator) ValidateHeader(header, parent *types.Header, checkPow b if v.bc.HasHeader(header.Hash()) { return nil } + if !bytes.Equal(parent.Extra, needExtraData) { + return ValidationError("Invalid extraData field in block header!") + } return ValidateHeader(v.config, v.Pow, header, parent, checkPow, false) }