Skip to content

Commit 8f12d76

Browse files
committed
params: remove redundant consts, disable metro on AllProtocolChanges
1 parent a0aa071 commit 8f12d76

File tree

10 files changed

+57
-107
lines changed

10 files changed

+57
-107
lines changed

cmd/geth/dao_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func TestDAOForkBlockNewChain(t *testing.T) {
8989
expectVote bool
9090
}{
9191
// Test DAO Default Mainnet
92-
{"", params.MainNetDAOForkBlock, true},
92+
{"", params.MainnetChainConfig.DAOForkBlock, true},
9393
// test DAO Init Old Privnet
9494
{daoOldGenesis, nil, false},
9595
// test DAO Default No Fork Privnet

cmd/swarm/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -380,11 +380,11 @@ func detectEnsAddr(client *rpc.Client) (common.Address, error) {
380380

381381
switch {
382382

383-
case version == "1" && block.Hash() == params.MainNetGenesisHash:
383+
case version == "1" && block.Hash() == params.MainnetGenesisHash:
384384
log.Info("using Mainnet ENS contract address", "addr", ens.MainNetAddress)
385385
return ens.MainNetAddress, nil
386386

387-
case version == "3" && block.Hash() == params.TestNetGenesisHash:
387+
case version == "3" && block.Hash() == params.TestnetGenesisHash:
388388
log.Info("using Testnet ENS contract address", "addr", ens.TestNetAddress)
389389
return ens.TestNetAddress, nil
390390

core/genesis.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig
143143
// Special case: don't change the existing config of a non-mainnet chain if no new
144144
// config is supplied. These chains would get AllProtocolChanges (and a compat error)
145145
// if we just continued here.
146-
if genesis == nil && stored != params.MainNetGenesisHash {
146+
if genesis == nil && stored != params.MainnetGenesisHash {
147147
return storedcfg, stored, nil
148148
}
149149

@@ -164,9 +164,9 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
164164
switch {
165165
case g != nil:
166166
return g.Config
167-
case ghash == params.MainNetGenesisHash:
167+
case ghash == params.MainnetGenesisHash:
168168
return params.MainnetChainConfig
169-
case ghash == params.TestNetGenesisHash:
169+
case ghash == params.TestnetGenesisHash:
170170
return params.TestnetChainConfig
171171
default:
172172
return params.AllProtocolChanges

core/genesis_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ import (
3232

3333
func TestDefaultGenesisBlock(t *testing.T) {
3434
block, _ := DefaultGenesisBlock().ToBlock()
35-
if block.Hash() != params.MainNetGenesisHash {
36-
t.Errorf("wrong mainnet genesis hash, got %v, want %v", block.Hash(), params.MainNetGenesisHash)
35+
if block.Hash() != params.MainnetGenesisHash {
36+
t.Errorf("wrong mainnet genesis hash, got %v, want %v", block.Hash(), params.MainnetGenesisHash)
3737
}
3838
block, _ = DefaultTestnetGenesisBlock().ToBlock()
39-
if block.Hash() != params.TestNetGenesisHash {
40-
t.Errorf("wrong testnet genesis hash, got %v, want %v", block.Hash(), params.TestNetGenesisHash)
39+
if block.Hash() != params.TestnetGenesisHash {
40+
t.Errorf("wrong testnet genesis hash, got %v, want %v", block.Hash(), params.TestnetGenesisHash)
4141
}
4242
}
4343

@@ -73,7 +73,7 @@ func TestSetupGenesis(t *testing.T) {
7373
fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, error) {
7474
return SetupGenesisBlock(db, nil)
7575
},
76-
wantHash: params.MainNetGenesisHash,
76+
wantHash: params.MainnetGenesisHash,
7777
wantConfig: params.MainnetChainConfig,
7878
},
7979
{
@@ -82,7 +82,7 @@ func TestSetupGenesis(t *testing.T) {
8282
DefaultGenesisBlock().MustCommit(db)
8383
return SetupGenesisBlock(db, nil)
8484
},
85-
wantHash: params.MainNetGenesisHash,
85+
wantHash: params.MainnetGenesisHash,
8686
wantConfig: params.MainnetChainConfig,
8787
},
8888
{
@@ -100,8 +100,8 @@ func TestSetupGenesis(t *testing.T) {
100100
customg.MustCommit(db)
101101
return SetupGenesisBlock(db, DefaultTestnetGenesisBlock())
102102
},
103-
wantErr: &GenesisMismatchError{Stored: customghash, New: params.TestNetGenesisHash},
104-
wantHash: params.TestNetGenesisHash,
103+
wantErr: &GenesisMismatchError{Stored: customghash, New: params.TestnetGenesisHash},
104+
wantHash: params.TestnetGenesisHash,
105105
wantConfig: params.TestnetChainConfig,
106106
},
107107
{

light/lightchain.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func NewLightChain(odr OdrBackend, config *params.ChainConfig, engine consensus.
9494
if bc.genesisBlock == nil {
9595
return nil, core.ErrNoGenesis
9696
}
97-
if bc.genesisBlock.Hash() == params.MainNetGenesisHash {
97+
if bc.genesisBlock.Hash() == params.MainnetGenesisHash {
9898
// add trusted CHT
9999
WriteTrustedCht(bc.chainDb, TrustedCht{Number: 805, Root: common.HexToHash("85e4286fe0a730390245c49de8476977afdae0eb5530b277f62a52b12313d50f")})
100100
log.Info("Added trusted CHT for mainnet")

params/config.go

+17-11
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,29 @@ package params
1818

1919
import (
2020
"fmt"
21+
"math"
2122
"math/big"
2223

2324
"github.com/ethereum/go-ethereum/common"
2425
)
2526

27+
var (
28+
MainnetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") // Mainnet genesis hash to enforce below configs on
29+
TestnetGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d") // Testnet genesis hash to enforce below configs on
30+
)
31+
2632
var (
2733
// MainnetChainConfig is the chain parameters to run a node on the main network.
2834
MainnetChainConfig = &ChainConfig{
29-
ChainId: MainNetChainID,
30-
HomesteadBlock: MainNetHomesteadBlock,
31-
DAOForkBlock: MainNetDAOForkBlock,
35+
ChainId: big.NewInt(1),
36+
HomesteadBlock: big.NewInt(1150000),
37+
DAOForkBlock: big.NewInt(1920000),
3238
DAOForkSupport: true,
33-
EIP150Block: MainNetHomesteadGasRepriceBlock,
34-
EIP150Hash: MainNetHomesteadGasRepriceHash,
35-
EIP155Block: MainNetSpuriousDragon,
36-
EIP158Block: MainNetSpuriousDragon,
37-
MetropolisBlock: MainNetMetropolisBlock,
39+
EIP150Block: big.NewInt(2463000),
40+
EIP150Hash: common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"),
41+
EIP155Block: big.NewInt(2675000),
42+
EIP158Block: big.NewInt(2675000),
43+
MetropolisBlock: big.NewInt(math.MaxInt64), // Don't enable yet
3844

3945
Ethash: new(EthashConfig),
4046
}
@@ -49,7 +55,7 @@ var (
4955
EIP150Hash: common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"),
5056
EIP155Block: big.NewInt(10),
5157
EIP158Block: big.NewInt(10),
52-
MetropolisBlock: TestNetMetropolisBlock,
58+
MetropolisBlock: big.NewInt(math.MaxInt64), // Don't enable yet
5359

5460
Ethash: new(EthashConfig),
5561
}
@@ -64,7 +70,7 @@ var (
6470
EIP150Hash: common.HexToHash("0x9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9"),
6571
EIP155Block: big.NewInt(3),
6672
EIP158Block: big.NewInt(3),
67-
MetropolisBlock: TestNetMetropolisBlock,
73+
MetropolisBlock: big.NewInt(math.MaxInt64), // Don't enable yet
6874

6975
Clique: &CliqueConfig{
7076
Period: 15,
@@ -80,7 +86,7 @@ var (
8086
// means that all fields must be set at all times. This forces
8187
// anyone adding flags to the config to also have to set these
8288
// fields.
83-
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}
89+
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}
8490
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}
8591
TestRules = TestChainConfig.Rules(new(big.Int))
8692
)

params/dao.go

-9
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ import (
2222
"github.com/ethereum/go-ethereum/common"
2323
)
2424

25-
// TestNetDAOForkBlock is the block number where the DAO hard-fork commences on
26-
// the Ethereum test network. It's enforced nil since it was decided not to do a
27-
// testnet transition.
28-
var TestNetDAOForkBlock *big.Int
29-
30-
// MainNetDAOForkBlock is the block number where the DAO hard-fork commences on
31-
// the Ethereum main network.
32-
var MainNetDAOForkBlock = big.NewInt(1920000)
33-
3425
// DAOForkBlockExtra is the block header extra-data field to set for the DAO fork
3526
// point and a number of consecutive blocks to allow fast/light syncers to correctly
3627
// pick the side they want ("dao-hard-fork").

params/util.go

-47
This file was deleted.

0 commit comments

Comments
 (0)