aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-11-29 22:12:40 +0800
committerGitHub <noreply@github.com>2016-11-29 22:12:40 +0800
commitfc9939c4e12e17d3b43d4238ddfd768b2edbf0dc (patch)
tree971e8b9337fb40ef36f8898f74b6224f660f8fc1
parent3807e520ec99dce5dc6ef28b237cd4be4a0992fe (diff)
parent7267f796e673a11fae3b6eda4bea19a8331f6c75 (diff)
downloaddexon-fc9939c4e12e17d3b43d4238ddfd768b2edbf0dc.tar
dexon-fc9939c4e12e17d3b43d4238ddfd768b2edbf0dc.tar.gz
dexon-fc9939c4e12e17d3b43d4238ddfd768b2edbf0dc.tar.bz2
dexon-fc9939c4e12e17d3b43d4238ddfd768b2edbf0dc.tar.lz
dexon-fc9939c4e12e17d3b43d4238ddfd768b2edbf0dc.tar.xz
dexon-fc9939c4e12e17d3b43d4238ddfd768b2edbf0dc.tar.zst
dexon-fc9939c4e12e17d3b43d4238ddfd768b2edbf0dc.zip
Merge pull request #3376 from karalabe/drop-dao-flags
cmd: drop DAO related choice flags since ETC diverged
-rw-r--r--cmd/geth/dao_test.go87
-rw-r--r--cmd/geth/main.go2
-rw-r--r--cmd/utils/flags.go16
3 files changed, 17 insertions, 88 deletions
diff --git a/cmd/geth/dao_test.go b/cmd/geth/dao_test.go
index 06578b612..f9ce80218 100644
--- a/cmd/geth/dao_test.go
+++ b/cmd/geth/dao_test.go
@@ -83,75 +83,28 @@ var daoGenesisForkBlock = big.NewInt(314)
// TestDAOForkBlockNewChain tests that the DAO hard-fork number and the nodes support/opposition is correctly
// set in the database after various initialization procedures and invocations.
func TestDAOForkBlockNewChain(t *testing.T) {
- for _, arg := range []struct {
+ for i, arg := range []struct {
testnet bool
genesis string
- votes [][2]bool
expectBlock *big.Int
expectVote bool
}{
// Test DAO Default Mainnet
- {false, "", [][2]bool{{false, false}}, params.MainNetDAOForkBlock, true},
- // test DAO Support Mainnet
- {false, "", [][2]bool{{true, false}}, params.MainNetDAOForkBlock, true},
- // test DAO Oppose Mainnet
- {false, "", [][2]bool{{false, true}}, params.MainNetDAOForkBlock, false},
- // test DAO Switch To Support Mainnet
- {false, "", [][2]bool{{false, true}, {true, false}}, params.MainNetDAOForkBlock, true},
- // test DAO Switch To Oppose Mainnet
- {false, "", [][2]bool{{true, false}, {false, true}}, params.MainNetDAOForkBlock, false},
+ {false, "", params.MainNetDAOForkBlock, true},
// test DAO Default Testnet
- {true, "", [][2]bool{{false, false}}, params.TestNetDAOForkBlock, true},
- // test DAO Support Testnet
- {true, "", [][2]bool{{true, false}}, params.TestNetDAOForkBlock, true},
- // test DAO Oppose Testnet
- {true, "", [][2]bool{{false, true}}, params.TestNetDAOForkBlock, false},
- // test DAO Switch To Support Testnet
- {true, "", [][2]bool{{false, true}, {true, false}}, params.TestNetDAOForkBlock, true},
- // test DAO Switch To Oppose Testnet
- {true, "", [][2]bool{{true, false}, {false, true}}, params.TestNetDAOForkBlock, false},
+ {true, "", params.TestNetDAOForkBlock, true},
// test DAO Init Old Privnet
- {false, daoOldGenesis, [][2]bool{}, nil, false},
- // test DAO Default Old Privnet
- {false, daoOldGenesis, [][2]bool{{false, false}}, nil, false},
- // test DAO Support Old Privnet
- {false, daoOldGenesis, [][2]bool{{true, false}}, nil, true},
- // test DAO Oppose Old Privnet
- {false, daoOldGenesis, [][2]bool{{false, true}}, nil, false},
- // test DAO Switch To Support Old Privnet
- {false, daoOldGenesis, [][2]bool{{false, true}, {true, false}}, nil, true},
- // test DAO Switch To Oppose Old Privnet
- {false, daoOldGenesis, [][2]bool{{true, false}, {false, true}}, nil, false},
- // test DAO Init No Fork Privnet
- {false, daoNoForkGenesis, [][2]bool{}, daoGenesisForkBlock, false},
+ {false, daoOldGenesis, nil, false},
// test DAO Default No Fork Privnet
- {false, daoNoForkGenesis, [][2]bool{{false, false}}, daoGenesisForkBlock, false},
- // test DAO Support No Fork Privnet
- {false, daoNoForkGenesis, [][2]bool{{true, false}}, daoGenesisForkBlock, true},
- // test DAO Oppose No Fork Privnet
- {false, daoNoForkGenesis, [][2]bool{{false, true}}, daoGenesisForkBlock, false},
- // test DAO Switch To Support No Fork Privnet
- {false, daoNoForkGenesis, [][2]bool{{false, true}, {true, false}}, daoGenesisForkBlock, true},
- // test DAO Switch To Oppose No Fork Privnet
- {false, daoNoForkGenesis, [][2]bool{{true, false}, {false, true}}, daoGenesisForkBlock, false},
- // test DAO Init Pro Fork Privnet
- {false, daoProForkGenesis, [][2]bool{}, daoGenesisForkBlock, true},
+ {false, daoNoForkGenesis, daoGenesisForkBlock, false},
// test DAO Default Pro Fork Privnet
- {false, daoProForkGenesis, [][2]bool{{false, false}}, daoGenesisForkBlock, true},
- // test DAO Support Pro Fork Privnet
- {false, daoProForkGenesis, [][2]bool{{true, false}}, daoGenesisForkBlock, true},
- // test DAO Oppose Pro Fork Privnet
- {false, daoProForkGenesis, [][2]bool{{false, true}}, daoGenesisForkBlock, false},
- // test DAO Switch To Support Pro Fork Privnet
- {false, daoProForkGenesis, [][2]bool{{false, true}, {true, false}}, daoGenesisForkBlock, true},
- // test DAO Switch To Oppose Pro Fork Privnet
- {false, daoProForkGenesis, [][2]bool{{true, false}, {false, true}}, daoGenesisForkBlock, false},
+ {false, daoProForkGenesis, daoGenesisForkBlock, true},
} {
- testDAOForkBlockNewChain(t, arg.testnet, arg.genesis, arg.votes, arg.expectBlock, arg.expectVote)
+ testDAOForkBlockNewChain(t, i, arg.testnet, arg.genesis, arg.expectBlock, arg.expectVote)
}
}
-func testDAOForkBlockNewChain(t *testing.T, testnet bool, genesis string, votes [][2]bool, expectBlock *big.Int, expectVote bool) {
+func testDAOForkBlockNewChain(t *testing.T, test int, testnet bool, genesis string, expectBlock *big.Int, expectVote bool) {
// Create a temporary data directory to use and inspect later
datadir := tmpdir(t)
defer os.RemoveAll(datadir)
@@ -160,21 +113,15 @@ func testDAOForkBlockNewChain(t *testing.T, testnet bool, genesis string, votes
if genesis != "" {
json := filepath.Join(datadir, "genesis.json")
if err := ioutil.WriteFile(json, []byte(genesis), 0600); err != nil {
- t.Fatalf("failed to write genesis file: %v", err)
+ t.Fatalf("test %d: failed to write genesis file: %v", test, err)
}
runGeth(t, "--datadir", datadir, "init", json).cmd.Wait()
- }
- for _, vote := range votes {
+ } else {
+ // Force chain initialization
args := []string{"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none", "--ipcdisable", "--datadir", datadir}
if testnet {
args = append(args, "--testnet")
}
- if vote[0] {
- args = append(args, "--support-dao-fork")
- }
- if vote[1] {
- args = append(args, "--oppose-dao-fork")
- }
geth := runGeth(t, append(args, []string{"--exec", "2+2", "console"}...)...)
geth.cmd.Wait()
}
@@ -185,7 +132,7 @@ func testDAOForkBlockNewChain(t *testing.T, testnet bool, genesis string, votes
}
db, err := ethdb.NewLDBDatabase(path, 0, 0)
if err != nil {
- t.Fatalf("failed to open test database: %v", err)
+ t.Fatalf("test %d: failed to open test database: %v", test, err)
}
defer db.Close()
@@ -198,20 +145,20 @@ func testDAOForkBlockNewChain(t *testing.T, testnet bool, genesis string, votes
}
config, err := core.GetChainConfig(db, genesisHash)
if err != nil {
- t.Errorf("failed to retrieve chain config: %v", err)
+ t.Errorf("test %d: failed to retrieve chain config: %v", test, err)
return // we want to return here, the other checks can't make it past this point (nil panic).
}
// Validate the DAO hard-fork block number against the expected value
if config.DAOForkBlock == nil {
if expectBlock != nil {
- t.Errorf("dao hard-fork block mismatch: have nil, want %v", expectBlock)
+ t.Errorf("test %d: dao hard-fork block mismatch: have nil, want %v", test, expectBlock)
}
} else if expectBlock == nil {
- t.Errorf("dao hard-fork block mismatch: have %v, want nil", config.DAOForkBlock)
+ t.Errorf("test %d: dao hard-fork block mismatch: have %v, want nil", test, config.DAOForkBlock)
} else if config.DAOForkBlock.Cmp(expectBlock) != 0 {
- t.Errorf("dao hard-fork block mismatch: have %v, want %v", config.DAOForkBlock, expectBlock)
+ t.Errorf("test %d: dao hard-fork block mismatch: have %v, want %v", test, config.DAOForkBlock, expectBlock)
}
if config.DAOForkSupport != expectVote {
- t.Errorf("dao hard-fork support mismatch: have %v, want %v", config.DAOForkSupport, expectVote)
+ t.Errorf("test %d: dao hard-fork support mismatch: have %v, want %v", test, config.DAOForkSupport, expectVote)
}
}
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index bcf9edbf0..4164d4383 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -140,8 +140,6 @@ participating.
utils.MaxPendingPeersFlag,
utils.EtherbaseFlag,
utils.GasPriceFlag,
- utils.SupportDAOFork,
- utils.OpposeDAOFork,
utils.MinerThreadsFlag,
utils.MiningEnabledFlag,
utils.AutoDAGFlag,
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index abd344df0..01a742d85 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -177,15 +177,6 @@ var (
Usage: "Number of trie node generations to keep in memory",
Value: int(state.MaxTrieCacheGen),
}
- // Fork settings
- SupportDAOFork = cli.BoolFlag{
- Name: "support-dao-fork",
- Usage: "Updates the chain rules to support the DAO hard-fork",
- }
- OpposeDAOFork = cli.BoolFlag{
- Name: "oppose-dao-fork",
- Usage: "Updates the chain rules to oppose the DAO hard-fork",
- }
// Miner settings
MiningEnabledFlag = cli.BoolFlag{
Name: "mine",
@@ -901,13 +892,6 @@ func MakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *params.ChainCon
config.ChainId = params.MainNetChainID
}
}
- // Force override any existing configs if explicitly requested
- switch {
- case ctx.GlobalBool(SupportDAOFork.Name):
- config.DAOForkSupport = true
- case ctx.GlobalBool(OpposeDAOFork.Name):
- config.DAOForkSupport = false
- }
return config
}