diff options
-rw-r--r-- | cmd/geth/dao_test.go | 2 | ||||
-rw-r--r-- | cmd/swarm/main.go | 4 | ||||
-rw-r--r-- | core/genesis.go | 6 | ||||
-rw-r--r-- | core/genesis_test.go | 16 | ||||
-rw-r--r-- | light/lightchain.go | 2 | ||||
-rw-r--r-- | params/config.go | 28 | ||||
-rw-r--r-- | params/dao.go | 9 | ||||
-rw-r--r-- | params/util.go | 47 | ||||
-rw-r--r-- | tests/state_test.go | 46 | ||||
-rw-r--r-- | tests/vm_test_util.go | 4 |
10 files changed, 57 insertions, 107 deletions
diff --git a/cmd/geth/dao_test.go b/cmd/geth/dao_test.go index 8cc66aabf..a8dbc5163 100644 --- a/cmd/geth/dao_test.go +++ b/cmd/geth/dao_test.go @@ -89,7 +89,7 @@ func TestDAOForkBlockNewChain(t *testing.T) { expectVote bool }{ // Test DAO Default Mainnet - {"", params.MainNetDAOForkBlock, true}, + {"", params.MainnetChainConfig.DAOForkBlock, true}, // test DAO Init Old Privnet {daoOldGenesis, nil, false}, // test DAO Default No Fork Privnet diff --git a/cmd/swarm/main.go b/cmd/swarm/main.go index 6b4feb0bc..4ae06a1c9 100644 --- a/cmd/swarm/main.go +++ b/cmd/swarm/main.go @@ -380,11 +380,11 @@ func detectEnsAddr(client *rpc.Client) (common.Address, error) { switch { - case version == "1" && block.Hash() == params.MainNetGenesisHash: + case version == "1" && block.Hash() == params.MainnetGenesisHash: log.Info("using Mainnet ENS contract address", "addr", ens.MainNetAddress) return ens.MainNetAddress, nil - case version == "3" && block.Hash() == params.TestNetGenesisHash: + case version == "3" && block.Hash() == params.TestnetGenesisHash: log.Info("using Testnet ENS contract address", "addr", ens.TestNetAddress) return ens.TestNetAddress, nil diff --git a/core/genesis.go b/core/genesis.go index 5815d5901..d587011f0 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -143,7 +143,7 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig // Special case: don't change the existing config of a non-mainnet chain if no new // config is supplied. These chains would get AllProtocolChanges (and a compat error) // if we just continued here. - if genesis == nil && stored != params.MainNetGenesisHash { + if genesis == nil && stored != params.MainnetGenesisHash { return storedcfg, stored, nil } @@ -164,9 +164,9 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig { switch { case g != nil: return g.Config - case ghash == params.MainNetGenesisHash: + case ghash == params.MainnetGenesisHash: return params.MainnetChainConfig - case ghash == params.TestNetGenesisHash: + case ghash == params.TestnetGenesisHash: return params.TestnetChainConfig default: return params.AllProtocolChanges diff --git a/core/genesis_test.go b/core/genesis_test.go index 4312a80b8..bc82fe54e 100644 --- a/core/genesis_test.go +++ b/core/genesis_test.go @@ -32,12 +32,12 @@ import ( func TestDefaultGenesisBlock(t *testing.T) { block, _ := DefaultGenesisBlock().ToBlock() - if block.Hash() != params.MainNetGenesisHash { - t.Errorf("wrong mainnet genesis hash, got %v, want %v", block.Hash(), params.MainNetGenesisHash) + if block.Hash() != params.MainnetGenesisHash { + t.Errorf("wrong mainnet genesis hash, got %v, want %v", block.Hash(), params.MainnetGenesisHash) } block, _ = DefaultTestnetGenesisBlock().ToBlock() - if block.Hash() != params.TestNetGenesisHash { - t.Errorf("wrong testnet genesis hash, got %v, want %v", block.Hash(), params.TestNetGenesisHash) + if block.Hash() != params.TestnetGenesisHash { + t.Errorf("wrong testnet genesis hash, got %v, want %v", block.Hash(), params.TestnetGenesisHash) } } @@ -73,7 +73,7 @@ func TestSetupGenesis(t *testing.T) { fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, error) { return SetupGenesisBlock(db, nil) }, - wantHash: params.MainNetGenesisHash, + wantHash: params.MainnetGenesisHash, wantConfig: params.MainnetChainConfig, }, { @@ -82,7 +82,7 @@ func TestSetupGenesis(t *testing.T) { DefaultGenesisBlock().MustCommit(db) return SetupGenesisBlock(db, nil) }, - wantHash: params.MainNetGenesisHash, + wantHash: params.MainnetGenesisHash, wantConfig: params.MainnetChainConfig, }, { @@ -100,8 +100,8 @@ func TestSetupGenesis(t *testing.T) { customg.MustCommit(db) return SetupGenesisBlock(db, DefaultTestnetGenesisBlock()) }, - wantErr: &GenesisMismatchError{Stored: customghash, New: params.TestNetGenesisHash}, - wantHash: params.TestNetGenesisHash, + wantErr: &GenesisMismatchError{Stored: customghash, New: params.TestnetGenesisHash}, + wantHash: params.TestnetGenesisHash, wantConfig: params.TestnetChainConfig, }, { diff --git a/light/lightchain.go b/light/lightchain.go index 87436f4a5..8bbf529cc 100644 --- a/light/lightchain.go +++ b/light/lightchain.go @@ -94,7 +94,7 @@ func NewLightChain(odr OdrBackend, config *params.ChainConfig, engine consensus. if bc.genesisBlock == nil { return nil, core.ErrNoGenesis } - if bc.genesisBlock.Hash() == params.MainNetGenesisHash { + if bc.genesisBlock.Hash() == params.MainnetGenesisHash { // add trusted CHT WriteTrustedCht(bc.chainDb, TrustedCht{Number: 805, Root: common.HexToHash("85e4286fe0a730390245c49de8476977afdae0eb5530b277f62a52b12313d50f")}) log.Info("Added trusted CHT for mainnet") diff --git a/params/config.go b/params/config.go index 50268f633..f4bb6172b 100644 --- a/params/config.go +++ b/params/config.go @@ -18,23 +18,29 @@ package params import ( "fmt" + "math" "math/big" "github.com/ethereum/go-ethereum/common" ) var ( + MainnetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") // Mainnet genesis hash to enforce below configs on + TestnetGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d") // Testnet genesis hash to enforce below configs on +) + +var ( // MainnetChainConfig is the chain parameters to run a node on the main network. MainnetChainConfig = &ChainConfig{ - ChainId: MainNetChainID, - HomesteadBlock: MainNetHomesteadBlock, - DAOForkBlock: MainNetDAOForkBlock, + ChainId: big.NewInt(1), + HomesteadBlock: big.NewInt(1150000), + DAOForkBlock: big.NewInt(1920000), DAOForkSupport: true, - EIP150Block: MainNetHomesteadGasRepriceBlock, - EIP150Hash: MainNetHomesteadGasRepriceHash, - EIP155Block: MainNetSpuriousDragon, - EIP158Block: MainNetSpuriousDragon, - MetropolisBlock: MainNetMetropolisBlock, + EIP150Block: big.NewInt(2463000), + EIP150Hash: common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"), + EIP155Block: big.NewInt(2675000), + EIP158Block: big.NewInt(2675000), + MetropolisBlock: big.NewInt(math.MaxInt64), // Don't enable yet Ethash: new(EthashConfig), } @@ -49,7 +55,7 @@ var ( EIP150Hash: common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"), EIP155Block: big.NewInt(10), EIP158Block: big.NewInt(10), - MetropolisBlock: TestNetMetropolisBlock, + MetropolisBlock: big.NewInt(math.MaxInt64), // Don't enable yet Ethash: new(EthashConfig), } @@ -64,7 +70,7 @@ var ( EIP150Hash: common.HexToHash("0x9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9"), EIP155Block: big.NewInt(3), EIP158Block: big.NewInt(3), - MetropolisBlock: TestNetMetropolisBlock, + MetropolisBlock: big.NewInt(math.MaxInt64), // Don't enable yet Clique: &CliqueConfig{ Period: 15, @@ -80,7 +86,7 @@ var ( // means that all fields must be set at all times. This forces // anyone adding flags to the config to also have to set these // fields. - AllProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), new(EthashConfig), nil} + AllProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(math.MaxInt64) /*disabled*/, new(EthashConfig), nil} TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil} TestRules = TestChainConfig.Rules(new(big.Int)) ) diff --git a/params/dao.go b/params/dao.go index ef8e838ff..da3c8dfc9 100644 --- a/params/dao.go +++ b/params/dao.go @@ -22,15 +22,6 @@ import ( "github.com/ethereum/go-ethereum/common" ) -// TestNetDAOForkBlock is the block number where the DAO hard-fork commences on -// the Ethereum test network. It's enforced nil since it was decided not to do a -// testnet transition. -var TestNetDAOForkBlock *big.Int - -// MainNetDAOForkBlock is the block number where the DAO hard-fork commences on -// the Ethereum main network. -var MainNetDAOForkBlock = big.NewInt(1920000) - // DAOForkBlockExtra is the block header extra-data field to set for the DAO fork // point and a number of consecutive blocks to allow fast/light syncers to correctly // pick the side they want ("dao-hard-fork"). diff --git a/params/util.go b/params/util.go deleted file mode 100644 index d4d43d047..000000000 --- a/params/util.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2015 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 <http://www.gnu.org/licenses/>. - -package params - -import ( - "math" - "math/big" - - "github.com/ethereum/go-ethereum/common" -) - -var ( - TestNetGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d") // Testnet genesis hash to enforce below configs on - MainNetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") // Mainnet genesis hash to enforce below configs on - - TestNetHomesteadBlock = big.NewInt(0) // Testnet homestead block - MainNetHomesteadBlock = big.NewInt(1150000) // Mainnet homestead block - - TestNetHomesteadGasRepriceBlock = big.NewInt(0) // Testnet gas reprice block - MainNetHomesteadGasRepriceBlock = big.NewInt(2463000) // Mainnet gas reprice block - - TestNetHomesteadGasRepriceHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d") // Testnet gas reprice block hash (used by fast sync) - MainNetHomesteadGasRepriceHash = common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0") // Mainnet gas reprice block hash (used by fast sync) - - TestNetSpuriousDragon = big.NewInt(10) - MainNetSpuriousDragon = big.NewInt(2675000) - - TestNetMetropolisBlock = big.NewInt(math.MaxInt64) - MainNetMetropolisBlock = big.NewInt(math.MaxInt64) - - TestNetChainID = big.NewInt(3) // Test net default chain ID - MainNetChainID = big.NewInt(1) // main net default chain ID -) diff --git a/tests/state_test.go b/tests/state_test.go index 97c4e5eeb..29180942b 100644 --- a/tests/state_test.go +++ b/tests/state_test.go @@ -684,7 +684,7 @@ func TestEIP158Create(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "stCreateTest.json") @@ -697,7 +697,7 @@ func TestEIP158Specific(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "stEIP158SpecificTest.json") @@ -710,7 +710,7 @@ func TestEIP158NonZeroCalls(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "stNonZeroCallsTest.json") @@ -723,7 +723,7 @@ func TestEIP158ZeroCalls(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "stZeroCallsTest.json") @@ -736,7 +736,7 @@ func TestEIP158_150Specific(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "EIP150", "stEIPSpecificTest.json") @@ -749,7 +749,7 @@ func TestEIP158_150SingleCodeGasPrice(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "EIP150", "stEIPsingleCodeGasPrices.json") @@ -762,7 +762,7 @@ func TestEIP158_150MemExpandingCalls(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "EIP150", "stMemExpandingEIPCalls.json") @@ -775,7 +775,7 @@ func TestEIP158HomesteadStateSystemOperations(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stSystemOperationsTest.json") @@ -788,7 +788,7 @@ func TestEIP158HomesteadStatePreCompiledContracts(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stPreCompiledContracts.json") @@ -801,7 +801,7 @@ func TestEIP158HomesteadStateRecursiveCreate(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stSpecialTest.json") @@ -814,7 +814,7 @@ func TestEIP158HomesteadStateRefund(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stRefundTest.json") @@ -827,7 +827,7 @@ func TestEIP158HomesteadStateInitCode(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stInitCodeTest.json") @@ -840,7 +840,7 @@ func TestEIP158HomesteadStateLog(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stLogTests.json") @@ -853,7 +853,7 @@ func TestEIP158HomesteadStateTransaction(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stTransactionTest.json") @@ -866,7 +866,7 @@ func TestEIP158HomesteadCallCreateCallCode(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stCallCreateCallCodeTest.json") @@ -879,7 +879,7 @@ func TestEIP158HomesteadCallCodes(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stCallCodes.json") @@ -892,7 +892,7 @@ func TestEIP158HomesteadMemory(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stMemoryTest.json") @@ -905,7 +905,7 @@ func TestEIP158HomesteadMemoryStress(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } if os.Getenv("TEST_VM_COMPLEX") == "" { @@ -921,7 +921,7 @@ func TestEIP158HomesteadQuadraticComplexity(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } if os.Getenv("TEST_VM_COMPLEX") == "" { @@ -937,7 +937,7 @@ func TestEIP158HomesteadWallet(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stWalletTest.json") @@ -950,7 +950,7 @@ func TestEIP158HomesteadDelegateCodes(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stCallDelegateCodes.json") @@ -963,7 +963,7 @@ func TestEIP158HomesteadDelegateCodesCallCode(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stCallDelegateCodesCallCode.json") @@ -976,7 +976,7 @@ func TestEIP158HomesteadBounds(t *testing.T) { chainConfig := ¶ms.ChainConfig{ HomesteadBlock: new(big.Int), EIP150Block: big.NewInt(2457000), - EIP158Block: params.MainNetSpuriousDragon, + EIP158Block: params.MainnetChainConfig.EIP158Block, } fn := filepath.Join(stateTestDir, "EIP158", "Homestead", "stBoundsTest.json") diff --git a/tests/vm_test_util.go b/tests/vm_test_util.go index d2ddee039..e7fe74f49 100644 --- a/tests/vm_test_util.go +++ b/tests/vm_test_util.go @@ -215,8 +215,8 @@ func runVmTest(test VmTest) error { func RunVm(statedb *state.StateDB, env, exec map[string]string) ([]byte, []*types.Log, *big.Int, error) { chainConfig := ¶ms.ChainConfig{ - HomesteadBlock: params.MainNetHomesteadBlock, - DAOForkBlock: params.MainNetDAOForkBlock, + HomesteadBlock: params.MainnetChainConfig.HomesteadBlock, + DAOForkBlock: params.MainnetChainConfig.DAOForkBlock, DAOForkSupport: true, } var ( |