diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-11-26 13:54:28 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2018-12-19 20:54:27 +0800 |
commit | 18c57d4af12b9a532897459d8ad11579436b9bab (patch) | |
tree | c3f440ef44e1ea1da23783ef94fd05ba0cff9c4b | |
parent | ce9dd85433e342b9ee13848414bc694921be1100 (diff) | |
download | dexon-18c57d4af12b9a532897459d8ad11579436b9bab.tar.gz dexon-18c57d4af12b9a532897459d8ad11579436b9bab.tar.zst dexon-18c57d4af12b9a532897459d8ad11579436b9bab.zip |
core: add Taipei testnet (#47)
Add a new testnet named Taipei.
-rw-r--r-- | cmd/gdex/consolecmd.go | 2 | ||||
-rw-r--r-- | cmd/gdex/main.go | 1 | ||||
-rw-r--r-- | cmd/gdex/usage.go | 3 | ||||
-rw-r--r-- | cmd/utils/flags.go | 28 | ||||
-rw-r--r-- | core/genesis.go | 14 | ||||
-rw-r--r-- | params/bootnodes.go | 10 | ||||
-rw-r--r-- | params/config.go | 31 | ||||
-rwxr-xr-x | test/run_test.sh | 14 |
8 files changed, 89 insertions, 14 deletions
diff --git a/cmd/gdex/consolecmd.go b/cmd/gdex/consolecmd.go index 9915e1ee0..8b9d58dad 100644 --- a/cmd/gdex/consolecmd.go +++ b/cmd/gdex/consolecmd.go @@ -124,6 +124,8 @@ func remoteConsole(ctx *cli.Context) error { if path != "" { if ctx.GlobalBool(utils.TestnetFlag.Name) { path = filepath.Join(path, "testnet") + } else if ctx.GlobalBool(utils.TaipeiFlag.Name) { + path = filepath.Join(path, "taipei") } } endpoint = fmt.Sprintf("%s/gdex.ipc", path) diff --git a/cmd/gdex/main.go b/cmd/gdex/main.go index dd08bb353..c4a7956e4 100644 --- a/cmd/gdex/main.go +++ b/cmd/gdex/main.go @@ -122,6 +122,7 @@ var ( utils.DeveloperFlag, utils.DeveloperPeriodFlag, utils.TestnetFlag, + utils.TaipeiFlag, utils.VMEnableDebugFlag, utils.NetworkIdFlag, utils.ConstantinopleOverrideFlag, diff --git a/cmd/gdex/usage.go b/cmd/gdex/usage.go index 9b930e081..e657e032b 100644 --- a/cmd/gdex/usage.go +++ b/cmd/gdex/usage.go @@ -65,7 +65,7 @@ type flagGroup struct { // AppHelpFlagGroups is the application flags, grouped by functionality. var AppHelpFlagGroups = []flagGroup{ { - Name: "ETHEREUM", + Name: "DEXON", Flags: []cli.Flag{ configFileFlag, utils.DataDirFlag, @@ -73,6 +73,7 @@ var AppHelpFlagGroups = []flagGroup{ utils.NoUSBFlag, utils.NetworkIdFlag, utils.TestnetFlag, + utils.TaipeiFlag, utils.SyncModeFlag, utils.GCModeFlag, utils.EthStatsURLFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 77a2f07f7..7f6b41f6f 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -129,12 +129,16 @@ var ( } NetworkIdFlag = cli.Uint64Flag{ Name: "networkid", - Usage: "Network identifier (integer, 237=Mainnet, 238=Testnet) (default: 237)", + Usage: "Network identifier (integer, 237=Mainnet, 238=Testnet, 239=Taipei) (default: 237)", Value: eth.DefaultConfig.NetworkId, } TestnetFlag = cli.BoolFlag{ Name: "testnet", - Usage: "Ropsten network: pre-configured proof-of-work test network", + Usage: "Taiwan network: default public testnet", + } + TaipeiFlag = cli.BoolFlag{ + Name: "taipei", + Usage: "Taipei network: tapei public testnet", } ConstantinopleOverrideFlag = cli.Uint64Flag{ Name: "override.constantinople", @@ -157,7 +161,7 @@ var ( Usage: "Document Root for HTTPClient file scheme", Value: DirectoryString{homeDir()}, } - defaultSyncMode = eth.DefaultConfig.SyncMode + defaultSyncMode = dex.DefaultConfig.SyncMode SyncModeFlag = TextMarshalerFlag{ Name: "syncmode", Usage: `Blockchain sync mode ("fast", "full", or "light")`, @@ -645,6 +649,9 @@ func MakeDataDir(ctx *cli.Context) string { if ctx.GlobalBool(TestnetFlag.Name) { return filepath.Join(path, "testnet") } + if ctx.GlobalBool(TaipeiFlag.Name) { + return filepath.Join(path, "taipei") + } return path } Fatalf("Cannot determine default data directory, please set manually (--datadir)") @@ -697,6 +704,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) { } case ctx.GlobalBool(TestnetFlag.Name): urls = params.TestnetBootnodes + case ctx.GlobalBool(TaipeiFlag.Name): + urls = params.TaipeiBootnodes case cfg.BootstrapNodes != nil: return // already set, don't apply defaults. } @@ -722,6 +731,8 @@ func setBootstrapNodesV5(ctx *cli.Context, cfg *p2p.Config) { } else { urls = strings.Split(ctx.GlobalString(BootnodesFlag.Name), ",") } + case ctx.GlobalBool(TaipeiFlag.Name): + urls = params.TaipeiBootnodes case cfg.BootstrapNodesV5 != nil: return // already set, don't apply defaults. } @@ -996,6 +1007,8 @@ func setDataDir(ctx *cli.Context, cfg *node.Config) { cfg.DataDir = "" // unless explicitly requested, use memory databases case ctx.GlobalBool(TestnetFlag.Name): cfg.DataDir = filepath.Join(node.DefaultDataDir(), "testnet") + case ctx.GlobalBool(TaipeiFlag.Name): + cfg.DataDir = filepath.Join(node.DefaultDataDir(), "taipei") } } @@ -1152,7 +1165,7 @@ func SetShhConfig(ctx *cli.Context, stack *node.Node, cfg *whisper.Config) { // SetDexConfig applies eth-related command line flags to the config. func SetDexConfig(ctx *cli.Context, stack *node.Node, cfg *dex.Config) { // Avoid conflicting network flags - checkExclusive(ctx, DeveloperFlag, TestnetFlag) + checkExclusive(ctx, DeveloperFlag, TestnetFlag, TaipeiFlag) checkExclusive(ctx, LightServFlag, SyncModeFlag, "light") ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore) @@ -1214,6 +1227,11 @@ func SetDexConfig(ctx *cli.Context, stack *node.Node, cfg *dex.Config) { cfg.NetworkId = 238 } cfg.Genesis = core.DefaultTestnetGenesisBlock() + case ctx.GlobalBool(TaipeiFlag.Name): + if !ctx.GlobalIsSet(NetworkIdFlag.Name) { + cfg.NetworkId = 239 + } + cfg.Genesis = core.DefaultTaipeiGenesisBlock() case ctx.GlobalBool(DeveloperFlag.Name): if !ctx.GlobalIsSet(NetworkIdFlag.Name) { cfg.NetworkId = 1337 @@ -1350,6 +1368,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis { switch { case ctx.GlobalBool(TestnetFlag.Name): genesis = core.DefaultTestnetGenesisBlock() + case ctx.GlobalBool(TaipeiFlag.Name): + genesis = core.DefaultTaipeiGenesisBlock() case ctx.GlobalBool(DeveloperFlag.Name): Fatalf("Developer chains are ephemeral") } diff --git a/core/genesis.go b/core/genesis.go index 57b7c619b..c3bb976d3 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -392,7 +392,7 @@ func DefaultGenesisBlock() *Genesis { } } -// DefaultTestnetGenesisBlock returns the Ropsten network genesis block. +// DefaultTestnetGenesisBlock returns the Taiwan network genesis block. func DefaultTestnetGenesisBlock() *Genesis { return &Genesis{ Config: params.TestnetChainConfig, @@ -404,6 +404,18 @@ func DefaultTestnetGenesisBlock() *Genesis { } } +// DefaultTaipeiGenesisBlock returns the Taipei network genesis block. +func DefaultTaipeiGenesisBlock() *Genesis { + return &Genesis{ + Config: params.TaipeiChainConfig, + Nonce: 0x42, + ExtraData: hexutil.MustDecode("0x3535353535353535353535353535353535353535353535353535353535353535"), + GasLimit: 40000000, + Difficulty: big.NewInt(1), + Alloc: decodePrealloc(testnetAllocData), + } +} + // DeveloperGenesisBlock returns the 'geth --dev' genesis block. Note, this must // be seeded with the func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis { diff --git a/params/bootnodes.go b/params/bootnodes.go index 3c6ec8555..742b696db 100644 --- a/params/bootnodes.go +++ b/params/bootnodes.go @@ -23,9 +23,15 @@ var MainnetBootnodes = []string{ } // TestnetBootnodes are the enode URLs of the P2P bootstrap nodes running on the -// Ropsten test network. +// Taiwan test network. var TestnetBootnodes = []string{ - "enode://0478aa13c91aa0db8e93b668313b7eb0532fbdb24f64772375373b14dbe326c238ad09ab4469f6442c9a9753f1275aeec2e531912c14a958ed1feb4ae7e227ef@127.0.0.1:30301", + "enode://0478aa13c91aa0db8e93b668313b7eb0532fbdb24f64772375373b14dbe326c238ad09ab4469f6442c9a9753f1275aeec2e531912c14a958ed1feb4ae7e227ef@35.187.157.218:30301", +} + +// TestnetBootnodes are the enode URLs of the P2P bootstrap nodes running on the +// Taipei test network. +var TaipeiBootnodes = []string{ + "enode://0478aa13c91aa0db8e93b668313b7eb0532fbdb24f64772375373b14dbe326c238ad09ab4469f6442c9a9753f1275aeec2e531912c14a958ed1feb4ae7e227ef@35.229.247.207:30301", } // DiscoveryV5Bootnodes are the enode URLs of the P2P bootstrap nodes for the diff --git a/params/config.go b/params/config.go index 150990080..6c40f2154 100644 --- a/params/config.go +++ b/params/config.go @@ -70,7 +70,7 @@ var ( BloomRoot: common.HexToHash("0x8006c5e44b14d90d7cc9cd5fa1cb48cf53697ee3bbbf4b76fdfa70b0242500a9"), } - // TestnetChainConfig contains the chain parameters to run a node on the Ropsten test network. + // TestnetChainConfig contains the chain parameters to run a node on the Taiwan test network. TestnetChainConfig = &ChainConfig{ ChainID: big.NewInt(238), HomesteadBlock: big.NewInt(0), @@ -99,6 +99,35 @@ var ( }, } + // TaipeiChainConfig contains the chain parameters to run a node on the Taipei test network. + TaipeiChainConfig = &ChainConfig{ + ChainID: big.NewInt(239), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: true, + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: nil, + Dexcon: &DexconConfig{ + GenesisCRSText: "In DEXON, we trust.", + Owner: common.HexToAddress("BF8C48A620bacc46907f9B89732D25E47A2D7Cf7"), + MinStake: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e5)), + BlockReward: big.NewInt(1e18), + BlockGasLimit: 40000000, + NumChains: 6, + LambdaBA: 250, + LambdaDKG: 2500, + K: 0, + PhiRatio: 0.667, + NotarySetSize: 4, + DKGSetSize: 4, + RoundInterval: 600000, + MinBlockInterval: 900, + }, + } + // TestnetTrustedCheckpoint contains the light client trusted checkpoint for the Ropsten test network. TestnetTrustedCheckpoint = &TrustedCheckpoint{ Name: "testnet", diff --git a/test/run_test.sh b/test/run_test.sh index 4818f89b2..b8b893145 100755 --- a/test/run_test.sh +++ b/test/run_test.sh @@ -1,13 +1,17 @@ #!/bin/bash +if [ "$1" != "--testnet" ] && [ "$1" != "--taipei" ]; then + echo 'invalid network specified' + exit 1 +fi + +NETWORK="${1}" + GDEX=../build/bin/gdex # Kill all previous instances. pkill -9 -f gdex -# Start bootnode. -bootnode -nodekey bootnode.key --verbosity=9 > bootnode.log 2>&1 & - logsdir=$PWD/log-$(date '+%Y-%m-%d-%H:%M:%S') mkdir $logsdir @@ -19,7 +23,7 @@ datadir=$PWD/Dexon.rpc rm -rf $datadir $GDEX --datadir=$datadir init genesis.json $GDEX \ - --testnet \ + ${NETWORK} \ --verbosity=4 \ --gcmode=archive \ --datadir=$datadir --nodekey=testrpc.nodekey \ @@ -36,7 +40,7 @@ for i in $(seq 0 3); do rm -rf $datadir $GDEX --datadir=$datadir init genesis.json $GDEX \ - --testnet \ + ${NETWORK} \ --bp \ --verbosity=4 \ --gcmode=archive \ |