From 8639b0fae975a5e65dea16fe5321168ac0aef128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 24 Oct 2016 11:40:58 +0300 Subject: cmd/utils, core, params: explicitly pick reprice fork for fast sync --- core/block_validator.go | 10 +++++++++- core/config.go | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/block_validator.go b/core/block_validator.go index e5bc6178b..3f5aa10ff 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -248,7 +248,15 @@ func ValidateHeader(config *ChainConfig, pow pow.PoW, header *types.Header, pare } } // If all checks passed, validate the extra-data field for hard forks - return ValidateDAOHeaderExtraData(config, header) + if err := ValidateDAOHeaderExtraData(config, header); err != nil { + return err + } + if config.HomesteadGasRepriceBlock != nil && config.HomesteadGasRepriceBlock.Cmp(header.Number) == 0 { + if config.HomesteadGasRepriceHash != (common.Hash{}) && config.HomesteadGasRepriceHash != header.Hash() { + return ValidationError("Homestead gas reprice fork hash mismatch: have 0x%x, want 0x%x", header.Hash(), config.HomesteadGasRepriceBlock) + } + } + return nil } // CalcDifficulty is the difficulty adjustment algorithm. It returns diff --git a/core/config.go b/core/config.go index 3ab04e520..96e39ea3c 100644 --- a/core/config.go +++ b/core/config.go @@ -20,6 +20,7 @@ import ( "errors" "math/big" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" ) @@ -36,7 +37,8 @@ type ChainConfig struct { DAOForkBlock *big.Int `json:"daoForkBlock"` // TheDAO hard-fork switch block (nil = no fork) DAOForkSupport bool `json:"daoForkSupport"` // Whether the nodes supports or opposes the DAO hard-fork - HomesteadGasRepriceBlock *big.Int `json:"homesteadGasRepriceBlock"` // Homestead gas reprice switch block (nil = no fork) + HomesteadGasRepriceBlock *big.Int `json:"homesteadGasRepriceBlock"` // Homestead gas reprice switch block (nil = no fork) + HomesteadGasRepriceHash common.Hash `json:"homesteadGasRepriceHash"` // Homestead gas reprice switch block hash (fast sync aid) VmConfig vm.Config `json:"-"` } -- cgit v1.2.3