cmd: drop DAO related choice flags since ETC diverged

This commit is contained in:
Péter Szilágyi 2016-11-29 15:50:27 +02:00
parent 3807e520ec
commit 7267f796e6
No known key found for this signature in database
GPG Key ID: 119A76381CCB7DD2
3 changed files with 17 additions and 88 deletions

View File

@ -83,75 +83,28 @@ var daoGenesisForkBlock = big.NewInt(314)
// TestDAOForkBlockNewChain tests that the DAO hard-fork number and the nodes support/opposition is correctly // 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. // set in the database after various initialization procedures and invocations.
func TestDAOForkBlockNewChain(t *testing.T) { func TestDAOForkBlockNewChain(t *testing.T) {
for _, arg := range []struct { for i, arg := range []struct {
testnet bool testnet bool
genesis string genesis string
votes [][2]bool
expectBlock *big.Int expectBlock *big.Int
expectVote bool expectVote bool
}{ }{
// Test DAO Default Mainnet // Test DAO Default Mainnet
{false, "", [][2]bool{{false, false}}, params.MainNetDAOForkBlock, true}, {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},
// test DAO Default Testnet // test DAO Default Testnet
{true, "", [][2]bool{{false, false}}, params.TestNetDAOForkBlock, true}, {true, "", 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},
// test DAO Init Old Privnet // test DAO Init Old Privnet
{false, daoOldGenesis, [][2]bool{}, nil, false}, {false, daoOldGenesis, 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},
// test DAO Default No Fork Privnet // test DAO Default No Fork Privnet
{false, daoNoForkGenesis, [][2]bool{{false, false}}, daoGenesisForkBlock, false}, {false, daoNoForkGenesis, 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},
// test DAO Default Pro Fork Privnet // test DAO Default Pro Fork Privnet
{false, daoProForkGenesis, [][2]bool{{false, false}}, daoGenesisForkBlock, true}, {false, daoProForkGenesis, 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},
} { } {
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 // Create a temporary data directory to use and inspect later
datadir := tmpdir(t) datadir := tmpdir(t)
defer os.RemoveAll(datadir) defer os.RemoveAll(datadir)
@ -160,21 +113,15 @@ func testDAOForkBlockNewChain(t *testing.T, testnet bool, genesis string, votes
if genesis != "" { if genesis != "" {
json := filepath.Join(datadir, "genesis.json") json := filepath.Join(datadir, "genesis.json")
if err := ioutil.WriteFile(json, []byte(genesis), 0600); err != nil { 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() runGeth(t, "--datadir", datadir, "init", json).cmd.Wait()
} } else {
for _, vote := range votes { // Force chain initialization
args := []string{"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none", "--ipcdisable", "--datadir", datadir} args := []string{"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none", "--ipcdisable", "--datadir", datadir}
if testnet { if testnet {
args = append(args, "--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 := runGeth(t, append(args, []string{"--exec", "2+2", "console"}...)...)
geth.cmd.Wait() geth.cmd.Wait()
} }
@ -185,7 +132,7 @@ func testDAOForkBlockNewChain(t *testing.T, testnet bool, genesis string, votes
} }
db, err := ethdb.NewLDBDatabase(path, 0, 0) db, err := ethdb.NewLDBDatabase(path, 0, 0)
if err != nil { 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() defer db.Close()
@ -198,20 +145,20 @@ func testDAOForkBlockNewChain(t *testing.T, testnet bool, genesis string, votes
} }
config, err := core.GetChainConfig(db, genesisHash) config, err := core.GetChainConfig(db, genesisHash)
if err != nil { 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). 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 // Validate the DAO hard-fork block number against the expected value
if config.DAOForkBlock == nil { if config.DAOForkBlock == nil {
if expectBlock != 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 { } 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 { } 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 { 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)
} }
} }

View File

@ -140,8 +140,6 @@ participating.
utils.MaxPendingPeersFlag, utils.MaxPendingPeersFlag,
utils.EtherbaseFlag, utils.EtherbaseFlag,
utils.GasPriceFlag, utils.GasPriceFlag,
utils.SupportDAOFork,
utils.OpposeDAOFork,
utils.MinerThreadsFlag, utils.MinerThreadsFlag,
utils.MiningEnabledFlag, utils.MiningEnabledFlag,
utils.AutoDAGFlag, utils.AutoDAGFlag,

View File

@ -177,15 +177,6 @@ var (
Usage: "Number of trie node generations to keep in memory", Usage: "Number of trie node generations to keep in memory",
Value: int(state.MaxTrieCacheGen), 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 // Miner settings
MiningEnabledFlag = cli.BoolFlag{ MiningEnabledFlag = cli.BoolFlag{
Name: "mine", Name: "mine",
@ -901,13 +892,6 @@ func MakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *params.ChainCon
config.ChainId = params.MainNetChainID 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 return config
} }