From 5e4d726e2a05aee80a75e5f99fd699f220dd503e Mon Sep 17 00:00:00 2001 From: Delweng Date: Tue, 18 Apr 2023 15:49:09 +0800 Subject: [PATCH] params: remove `EIP150Hash` from chainconfig (#27087) The EIP150Hash was an idea where, after the fork, we hardcoded the forked hash as an extra defensive mechanism. It wasn't really used, since forks weren't contentious and for all the various testnets and private networks it's been a hassle to have around. This change removes that config field. --------- Signed-off-by: jsvisa --- consensus/clique/clique.go | 4 ---- consensus/ethash/consensus.go | 3 --- consensus/misc/eip1559_test.go | 1 - consensus/misc/forks.go | 43 ---------------------------------- core/vm/runtime/runtime.go | 1 - eth/tracers/js/tracer_test.go | 2 +- miner/stress/1559/main.go | 1 - miner/stress/clique/main.go | 1 - miner/stress/ethash/main.go | 1 - params/config.go | 10 +------- tests/difficulty_test.go | 3 --- 11 files changed, 2 insertions(+), 68 deletions(-) delete mode 100644 consensus/misc/forks.go diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index 1b9a1d923..2345a5ca0 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -304,10 +304,6 @@ func (c *Clique) verifyHeader(chain consensus.ChainHeaderReader, header *types.H if chain.Config().IsCancun(header.Time) { return fmt.Errorf("clique does not support cancun fork") } - // If all checks passed, validate any special fields for hard forks - if err := misc.VerifyForkHashes(chain.Config(), header, false); err != nil { - return err - } // All basic checks passed, verify cascading fields return c.verifyCascadingFields(chain, header, parents) } diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index 8f1b497cb..e3e0f28b3 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -326,9 +326,6 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainHeaderReader, header, pa if err := misc.VerifyDAOHeaderExtraData(chain.Config(), header); err != nil { return err } - if err := misc.VerifyForkHashes(chain.Config(), header, uncle); err != nil { - return err - } return nil } diff --git a/consensus/misc/eip1559_test.go b/consensus/misc/eip1559_test.go index 23cd9023d..1a9f96bc4 100644 --- a/consensus/misc/eip1559_test.go +++ b/consensus/misc/eip1559_test.go @@ -34,7 +34,6 @@ func copyConfig(original *params.ChainConfig) *params.ChainConfig { DAOForkBlock: original.DAOForkBlock, DAOForkSupport: original.DAOForkSupport, EIP150Block: original.EIP150Block, - EIP150Hash: original.EIP150Hash, EIP155Block: original.EIP155Block, EIP158Block: original.EIP158Block, ByzantiumBlock: original.ByzantiumBlock, diff --git a/consensus/misc/forks.go b/consensus/misc/forks.go deleted file mode 100644 index a6f3303ea..000000000 --- a/consensus/misc/forks.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2017 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -package misc - -import ( - "fmt" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/params" -) - -// VerifyForkHashes verifies that blocks conforming to network hard-forks do have -// the correct hashes, to avoid clients going off on different chains. This is an -// optional feature. -func VerifyForkHashes(config *params.ChainConfig, header *types.Header, uncle bool) error { - // We don't care about uncles - if uncle { - return nil - } - // If the homestead reprice hash is set, validate it - if config.EIP150Block != nil && config.EIP150Block.Cmp(header.Number) == 0 { - if config.EIP150Hash != (common.Hash{}) && config.EIP150Hash != header.Hash() { - return fmt.Errorf("homestead gas reprice fork: have %#x, want %#x", header.Hash(), config.EIP150Hash) - } - } - // All ok, return - return nil -} diff --git a/core/vm/runtime/runtime.go b/core/vm/runtime/runtime.go index 56ff5eeab..005ef0c75 100644 --- a/core/vm/runtime/runtime.go +++ b/core/vm/runtime/runtime.go @@ -57,7 +57,6 @@ func setDefaults(cfg *Config) { DAOForkBlock: new(big.Int), DAOForkSupport: false, EIP150Block: new(big.Int), - EIP150Hash: common.Hash{}, EIP155Block: new(big.Int), EIP158Block: new(big.Int), ByzantiumBlock: new(big.Int), diff --git a/eth/tracers/js/tracer_test.go b/eth/tracers/js/tracer_test.go index a61754352..bf6427faf 100644 --- a/eth/tracers/js/tracer_test.go +++ b/eth/tracers/js/tracer_test.go @@ -229,7 +229,7 @@ func TestNoStepExec(t *testing.T) { } func TestIsPrecompile(t *testing.T) { - chaincfg := ¶ms.ChainConfig{ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), DAOForkBlock: nil, DAOForkSupport: false, EIP150Block: big.NewInt(0), EIP150Hash: common.Hash{}, EIP155Block: big.NewInt(0), EIP158Block: big.NewInt(0), ByzantiumBlock: big.NewInt(100), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(200), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(300), LondonBlock: big.NewInt(0), TerminalTotalDifficulty: nil, Ethash: new(params.EthashConfig), Clique: nil} + chaincfg := ¶ms.ChainConfig{ChainID: big.NewInt(1), HomesteadBlock: big.NewInt(0), DAOForkBlock: nil, DAOForkSupport: false, EIP150Block: big.NewInt(0), EIP155Block: big.NewInt(0), EIP158Block: big.NewInt(0), ByzantiumBlock: big.NewInt(100), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(200), MuirGlacierBlock: big.NewInt(0), BerlinBlock: big.NewInt(300), LondonBlock: big.NewInt(0), TerminalTotalDifficulty: nil, Ethash: new(params.EthashConfig), Clique: nil} chaincfg.ByzantiumBlock = big.NewInt(100) chaincfg.IstanbulBlock = big.NewInt(200) chaincfg.BerlinBlock = big.NewInt(300) diff --git a/miner/stress/1559/main.go b/miner/stress/1559/main.go index c27875000..2e8b78d85 100644 --- a/miner/stress/1559/main.go +++ b/miner/stress/1559/main.go @@ -205,7 +205,6 @@ func makeGenesis(faucets []*ecdsa.PrivateKey) *core.Genesis { genesis.GasLimit = 8_000_000 genesis.Config.ChainID = big.NewInt(18) - genesis.Config.EIP150Hash = common.Hash{} genesis.Alloc = core.GenesisAlloc{} for _, faucet := range faucets { diff --git a/miner/stress/clique/main.go b/miner/stress/clique/main.go index 688c2b698..74962c6d5 100644 --- a/miner/stress/clique/main.go +++ b/miner/stress/clique/main.go @@ -153,7 +153,6 @@ func makeGenesis(faucets []*ecdsa.PrivateKey, sealers []*ecdsa.PrivateKey) *core genesis.Config.ChainID = big.NewInt(18) genesis.Config.Clique.Period = 1 - genesis.Config.EIP150Hash = common.Hash{} genesis.Alloc = core.GenesisAlloc{} for _, faucet := range faucets { diff --git a/miner/stress/ethash/main.go b/miner/stress/ethash/main.go index 6b6e7059d..6905bf01f 100644 --- a/miner/stress/ethash/main.go +++ b/miner/stress/ethash/main.go @@ -139,7 +139,6 @@ func makeGenesis(faucets []*ecdsa.PrivateKey) *core.Genesis { genesis.GasLimit = 25000000 genesis.Config.ChainID = big.NewInt(18) - genesis.Config.EIP150Hash = common.Hash{} genesis.Alloc = core.GenesisAlloc{} for _, faucet := range faucets { diff --git a/params/config.go b/params/config.go index 190eb737c..82d00bc8f 100644 --- a/params/config.go +++ b/params/config.go @@ -62,7 +62,6 @@ var ( DAOForkBlock: big.NewInt(1_920_000), DAOForkSupport: true, EIP150Block: big.NewInt(2_463_000), - EIP150Hash: common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"), EIP155Block: big.NewInt(2_675_000), EIP158Block: big.NewInt(2_675_000), ByzantiumBlock: big.NewInt(4_370_000), @@ -139,7 +138,6 @@ var ( DAOForkBlock: nil, DAOForkSupport: true, EIP150Block: big.NewInt(2), - EIP150Hash: common.HexToHash("0x9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9"), EIP155Block: big.NewInt(3), EIP158Block: big.NewInt(3), ByzantiumBlock: big.NewInt(1_035_301), @@ -231,7 +229,6 @@ var ( DAOForkBlock: nil, DAOForkSupport: false, EIP150Block: big.NewInt(0), - EIP150Hash: common.Hash{}, EIP155Block: big.NewInt(0), EIP158Block: big.NewInt(0), ByzantiumBlock: big.NewInt(0), @@ -261,7 +258,6 @@ var ( DAOForkBlock: nil, DAOForkSupport: false, EIP150Block: big.NewInt(0), - EIP150Hash: common.Hash{}, EIP155Block: big.NewInt(0), EIP158Block: big.NewInt(0), ByzantiumBlock: big.NewInt(0), @@ -291,7 +287,6 @@ var ( DAOForkBlock: nil, DAOForkSupport: false, EIP150Block: big.NewInt(0), - EIP150Hash: common.Hash{}, EIP155Block: big.NewInt(0), EIP158Block: big.NewInt(0), ByzantiumBlock: big.NewInt(0), @@ -321,7 +316,6 @@ var ( DAOForkBlock: nil, DAOForkSupport: false, EIP150Block: nil, - EIP150Hash: common.Hash{}, EIP155Block: nil, EIP158Block: nil, ByzantiumBlock: nil, @@ -415,9 +409,7 @@ type ChainConfig struct { DAOForkSupport bool `json:"daoForkSupport,omitempty"` // Whether the nodes supports or opposes the DAO hard-fork // EIP150 implements the Gas price changes (https://github.com/ethereum/EIPs/issues/150) - EIP150Block *big.Int `json:"eip150Block,omitempty"` // EIP150 HF block (nil = no fork) - EIP150Hash common.Hash `json:"eip150Hash,omitempty"` // EIP150 HF hash (needed for header only clients as only gas pricing changed) - + EIP150Block *big.Int `json:"eip150Block,omitempty"` // EIP150 HF block (nil = no fork) EIP155Block *big.Int `json:"eip155Block,omitempty"` // EIP155 HF block EIP158Block *big.Int `json:"eip158Block,omitempty"` // EIP158 HF block diff --git a/tests/difficulty_test.go b/tests/difficulty_test.go index a8273303e..03e14df7c 100644 --- a/tests/difficulty_test.go +++ b/tests/difficulty_test.go @@ -20,7 +20,6 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" ) @@ -31,7 +30,6 @@ var ( DAOForkBlock: big.NewInt(1920000), DAOForkSupport: true, EIP150Block: big.NewInt(2463000), - EIP150Hash: common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"), EIP155Block: big.NewInt(2675000), EIP158Block: big.NewInt(2675000), ByzantiumBlock: big.NewInt(4370000), @@ -43,7 +41,6 @@ var ( DAOForkBlock: nil, DAOForkSupport: true, EIP150Block: big.NewInt(0), - EIP150Hash: common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"), EIP155Block: big.NewInt(10), EIP158Block: big.NewInt(10), ByzantiumBlock: big.NewInt(1_700_000),