@@ -41,13 +41,13 @@ var (
41
41
//
42
42
// BlockValidator implements Validator.
43
43
type BlockValidator struct {
44
- config * ChainConfig // Chain configuration options
45
- bc * BlockChain // Canonical block chain
46
- Pow pow.PoW // Proof of work used for validating
44
+ config * params. ChainConfig // Chain configuration options
45
+ bc * BlockChain // Canonical block chain
46
+ Pow pow.PoW // Proof of work used for validating
47
47
}
48
48
49
49
// NewBlockValidator returns a new block validator which is safe for re-use
50
- func NewBlockValidator (config * ChainConfig , blockchain * BlockChain , pow pow.PoW ) * BlockValidator {
50
+ func NewBlockValidator (config * params. ChainConfig , blockchain * BlockChain , pow pow.PoW ) * BlockValidator {
51
51
validator := & BlockValidator {
52
52
config : config ,
53
53
Pow : pow ,
@@ -128,7 +128,7 @@ func (v *BlockValidator) ValidateState(block, parent *types.Block, statedb *stat
128
128
}
129
129
// Validate the state root against the received state root and throw
130
130
// an error if they don't match.
131
- if root := statedb .IntermediateRoot (); header .Root != root {
131
+ if root := statedb .IntermediateRoot (v . config . IsEIP158 ( header . Number ) ); header .Root != root {
132
132
return fmt .Errorf ("invalid merkle root: header=%x computed=%x" , header .Root , root )
133
133
}
134
134
return nil
@@ -203,7 +203,7 @@ func (v *BlockValidator) ValidateHeader(header, parent *types.Header, checkPow b
203
203
// Validates a header. Returns an error if the header is invalid.
204
204
//
205
205
// See YP section 4.3.4. "Block Header Validity"
206
- func ValidateHeader (config * ChainConfig , pow pow.PoW , header * types.Header , parent * types.Header , checkPow , uncle bool ) error {
206
+ func ValidateHeader (config * params. ChainConfig , pow pow.PoW , header * types.Header , parent * types.Header , checkPow , uncle bool ) error {
207
207
if big .NewInt (int64 (len (header .Extra ))).Cmp (params .MaximumExtraDataSize ) == 1 {
208
208
return fmt .Errorf ("Header extra data too long (%d)" , len (header .Extra ))
209
209
}
@@ -251,9 +251,9 @@ func ValidateHeader(config *ChainConfig, pow pow.PoW, header *types.Header, pare
251
251
if err := ValidateDAOHeaderExtraData (config , header ); err != nil {
252
252
return err
253
253
}
254
- if config .HomesteadGasRepriceBlock != nil && config .HomesteadGasRepriceBlock .Cmp (header .Number ) == 0 {
255
- if config .HomesteadGasRepriceHash != (common.Hash {}) && config .HomesteadGasRepriceHash != header .Hash () {
256
- return ValidationError ("Homestead gas reprice fork hash mismatch: have 0x%x, want 0x%x" , header .Hash (), config .HomesteadGasRepriceHash )
254
+ if config .EIP150Block != nil && config .EIP150Block .Cmp (header .Number ) == 0 {
255
+ if config .EIP150Hash != (common.Hash {}) && config .EIP150Hash != header .Hash () {
256
+ return ValidationError ("Homestead gas reprice fork hash mismatch: have 0x%x, want 0x%x" , header .Hash (), config .EIP150Hash )
257
257
}
258
258
}
259
259
return nil
@@ -262,7 +262,7 @@ func ValidateHeader(config *ChainConfig, pow pow.PoW, header *types.Header, pare
262
262
// CalcDifficulty is the difficulty adjustment algorithm. It returns
263
263
// the difficulty that a new block should have when created at time
264
264
// given the parent block's time and difficulty.
265
- func CalcDifficulty (config * ChainConfig , time , parentTime uint64 , parentNumber , parentDiff * big.Int ) * big.Int {
265
+ func CalcDifficulty (config * params. ChainConfig , time , parentTime uint64 , parentNumber , parentDiff * big.Int ) * big.Int {
266
266
if config .IsHomestead (new (big.Int ).Add (parentNumber , common .Big1 )) {
267
267
return calcDifficultyHomestead (time , parentTime , parentNumber , parentDiff )
268
268
} else {
0 commit comments