diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-10-29 22:21:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-29 22:21:26 +0800 |
commit | 63d293cdbe14cf00045b888522ef36d21c907c26 (patch) | |
tree | dc2251251b9bd72eac05ebdf17b146788c148ae7 /cmd | |
parent | 79789af2e7fce8807d21a8eedbf42d41a7c55848 (diff) | |
parent | f0dbec0c93a772b0f3553399126d8c49bfcc85d4 (diff) | |
download | dexon-63d293cdbe14cf00045b888522ef36d21c907c26.tar.gz dexon-63d293cdbe14cf00045b888522ef36d21c907c26.tar.zst dexon-63d293cdbe14cf00045b888522ef36d21c907c26.zip |
Merge pull request #3195 from karalabe/fix-testnet-fastsync
cmd/utils, core, params: explicitly pick reprice fork for fast sync
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/geth/dao_test.go | 10 | ||||
-rw-r--r-- | cmd/utils/flags.go | 54 |
2 files changed, 40 insertions, 24 deletions
diff --git a/cmd/geth/dao_test.go b/cmd/geth/dao_test.go index 59730b17f..56e77ba0b 100644 --- a/cmd/geth/dao_test.go +++ b/cmd/geth/dao_test.go @@ -116,19 +116,19 @@ func TestDAOInitOldPrivnet(t *testing.T) { testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{}, nil, false) } func TestDAODefaultOldPrivnet(t *testing.T) { - testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{false, false}}, params.MainNetDAOForkBlock, true) + testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{false, false}}, nil, false) } func TestDAOSupportOldPrivnet(t *testing.T) { - testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{true, false}}, params.MainNetDAOForkBlock, true) + testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{true, false}}, nil, true) } func TestDAOOpposeOldPrivnet(t *testing.T) { - testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{false, true}}, params.MainNetDAOForkBlock, false) + testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{false, true}}, nil, false) } func TestDAOSwitchToSupportOldPrivnet(t *testing.T) { - testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{false, true}, {true, false}}, params.MainNetDAOForkBlock, true) + testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{false, true}, {true, false}}, nil, true) } func TestDAOSwitchToOpposeOldPrivnet(t *testing.T) { - testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{true, false}, {false, true}}, params.MainNetDAOForkBlock, false) + testDAOForkBlockNewChain(t, false, daoOldGenesis, [][2]bool{{true, false}, {false, true}}, nil, false) } func TestDAOInitNoForkPrivnet(t *testing.T) { testDAOForkBlockNewChain(t, false, daoNoForkGenesis, [][2]bool{}, daoGenesisForkBlock, false) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index abfb4d1e7..edb0873f6 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -781,27 +781,43 @@ func MakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *core.ChainConfi Fatalf("Could not make chain configuration: %v", err) } } - // Set any missing fields due to them being unset or system upgrade - if config.HomesteadBlock == nil { - if ctx.GlobalBool(TestNetFlag.Name) { - config.HomesteadBlock = params.TestNetHomesteadBlock - } else { - config.HomesteadBlock = params.MainNetHomesteadBlock + // Check whether we are allowed to set default config params or not: + // - If no genesis is set, we're running either mainnet or testnet (private nets use `geth init`) + // - If a genesis is already set, ensure we have a configuration for it (mainnet or testnet) + defaults := genesis == nil || + (genesis.Hash() == params.MainNetGenesisHash && !ctx.GlobalBool(TestNetFlag.Name)) || + (genesis.Hash() == params.TestNetGenesisHash && ctx.GlobalBool(TestNetFlag.Name)) + + // Set any missing chainConfig fields due to them being unset or system upgrade + if defaults { + if config.HomesteadBlock == nil { + if ctx.GlobalBool(TestNetFlag.Name) { + config.HomesteadBlock = params.TestNetHomesteadBlock + } else { + config.HomesteadBlock = params.MainNetHomesteadBlock + } } - } - if config.DAOForkBlock == nil { - if ctx.GlobalBool(TestNetFlag.Name) { - config.DAOForkBlock = params.TestNetDAOForkBlock - } else { - config.DAOForkBlock = params.MainNetDAOForkBlock + if config.DAOForkBlock == nil { + if ctx.GlobalBool(TestNetFlag.Name) { + config.DAOForkBlock = params.TestNetDAOForkBlock + } else { + config.DAOForkBlock = params.MainNetDAOForkBlock + } + config.DAOForkSupport = true } - config.DAOForkSupport = true - } - if config.HomesteadGasRepriceBlock == nil { - if ctx.GlobalBool(TestNetFlag.Name) { - config.HomesteadGasRepriceBlock = params.TestNetHomesteadGasRepriceBlock - } else { - config.HomesteadGasRepriceBlock = params.MainNetHomesteadGasRepriceBlock + if config.HomesteadGasRepriceBlock == nil { + if ctx.GlobalBool(TestNetFlag.Name) { + config.HomesteadGasRepriceBlock = params.TestNetHomesteadGasRepriceBlock + } else { + config.HomesteadGasRepriceBlock = params.MainNetHomesteadGasRepriceBlock + } + } + if config.HomesteadGasRepriceHash == (common.Hash{}) { + if ctx.GlobalBool(TestNetFlag.Name) { + config.HomesteadGasRepriceHash = params.TestNetHomesteadGasRepriceHash + } else { + config.HomesteadGasRepriceHash = params.MainNetHomesteadGasRepriceHash + } } } // Force override any existing configs if explicitly requested |