aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-11-26 13:54:28 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:54 +0800
commit32e1c5ad4d6e57e4d555577fa586324f10b7319e (patch)
treecce99e6243b10c46226355fd58787f47a0b1c64a
parent622ae7fe3ef067d4f395937a9bb0f783a7c1e6c7 (diff)
downloaddexon-32e1c5ad4d6e57e4d555577fa586324f10b7319e.tar
dexon-32e1c5ad4d6e57e4d555577fa586324f10b7319e.tar.gz
dexon-32e1c5ad4d6e57e4d555577fa586324f10b7319e.tar.bz2
dexon-32e1c5ad4d6e57e4d555577fa586324f10b7319e.tar.lz
dexon-32e1c5ad4d6e57e4d555577fa586324f10b7319e.tar.xz
dexon-32e1c5ad4d6e57e4d555577fa586324f10b7319e.tar.zst
dexon-32e1c5ad4d6e57e4d555577fa586324f10b7319e.zip
core: add Taipei testnet (#47)
Add a new testnet named Taipei.
-rw-r--r--cmd/gdex/consolecmd.go2
-rw-r--r--cmd/gdex/main.go1
-rw-r--r--cmd/gdex/usage.go3
-rw-r--r--cmd/utils/flags.go28
-rw-r--r--core/genesis.go14
-rw-r--r--params/bootnodes.go10
-rw-r--r--params/config.go31
-rwxr-xr-xtest/run_test.sh14
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 0fb94b89e..1ca7cd766 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 496e20ecf..d67817096 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 fd5ea757d..03b0841b0 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -130,12 +130,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",
@@ -158,7 +162,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")`,
@@ -650,6 +654,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)")
@@ -702,6 +709,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.
}
@@ -727,6 +736,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.
}
@@ -1001,6 +1012,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")
}
}
@@ -1157,7 +1170,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)
@@ -1222,6 +1235,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
@@ -1375,6 +1393,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 0b59f4bbb..4b0e878fe 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -393,7 +393,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,
@@ -405,6 +405,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 059d9b2c0..d194564b2 100644
--- a/params/config.go
+++ b/params/config.go
@@ -71,7 +71,7 @@ var (
BloomRoot: common.HexToHash("0xec1b454d4c6322c78ccedf76ac922a8698c3cac4d98748a84af4995b7bd3d744"),
}
- // 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),
@@ -101,6 +101,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 \