From 20718c049c3988f6aac25bee2d33f959ad517deb Mon Sep 17 00:00:00 2001 From: Mission Liao Date: Mon, 25 Feb 2019 19:08:17 +0800 Subject: params: add Yilan network (#207) * Add Yilan network * Fixup: remove dummy log --- cmd/gdex/consolecmd.go | 2 ++ cmd/gdex/main.go | 1 + cmd/gdex/usage.go | 1 + cmd/utils/flags.go | 24 ++++++++++++++++++++++-- core/genesis.go | 14 ++++++++++++++ core/genesis_alloc.go | 1 + core/genesis_test.go | 10 ++++++++++ dex/blockproposer.go | 1 - dex/handler.go | 2 +- params/bootnodes.go | 8 +++++++- params/config.go | 37 +++++++++++++++++++++++++++++++++++++ 11 files changed, 96 insertions(+), 5 deletions(-) diff --git a/cmd/gdex/consolecmd.go b/cmd/gdex/consolecmd.go index 8b9d58dad..bc447fefd 100644 --- a/cmd/gdex/consolecmd.go +++ b/cmd/gdex/consolecmd.go @@ -126,6 +126,8 @@ func remoteConsole(ctx *cli.Context) error { path = filepath.Join(path, "testnet") } else if ctx.GlobalBool(utils.TaipeiFlag.Name) { path = filepath.Join(path, "taipei") + } else if ctx.GlobalBool(utils.YilanFlag.Name) { + path = filepath.Join(path, "yilan") } } endpoint = fmt.Sprintf("%s/gdex.ipc", path) diff --git a/cmd/gdex/main.go b/cmd/gdex/main.go index a2597c098..dcd46e796 100644 --- a/cmd/gdex/main.go +++ b/cmd/gdex/main.go @@ -123,6 +123,7 @@ var ( utils.DeveloperPeriodFlag, utils.TestnetFlag, utils.TaipeiFlag, + utils.YilanFlag, utils.VMEnableDebugFlag, utils.NetworkIdFlag, utils.ConstantinopleOverrideFlag, diff --git a/cmd/gdex/usage.go b/cmd/gdex/usage.go index 910b6498b..093115b93 100644 --- a/cmd/gdex/usage.go +++ b/cmd/gdex/usage.go @@ -74,6 +74,7 @@ var AppHelpFlagGroups = []flagGroup{ utils.NetworkIdFlag, utils.TestnetFlag, utils.TaipeiFlag, + utils.YilanFlag, utils.SyncModeFlag, utils.GCModeFlag, utils.EthStatsURLFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index d26bbb065..c6d60d0bb 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -130,7 +130,7 @@ var ( } NetworkIdFlag = cli.Uint64Flag{ Name: "networkid", - Usage: "Network identifier (integer, 237=Mainnet, 238=Testnet, 239=Taipei) (default: 237)", + Usage: "Network identifier (integer, 237=Mainnet, 238=Testnet, 239=Taipei, 240=Yilan) (default: 237)", Value: eth.DefaultConfig.NetworkId, } TestnetFlag = cli.BoolFlag{ @@ -141,6 +141,10 @@ var ( Name: "taipei", Usage: "Taipei network: tapei public testnet", } + YilanFlag = cli.BoolFlag{ + Name: "yilan", + Usage: "Yilan network: yilan public testnet", + } ConstantinopleOverrideFlag = cli.Uint64Flag{ Name: "override.constantinople", Usage: "Manually specify constantinople fork-block, overriding the bundled setting", @@ -673,6 +677,9 @@ func MakeDataDir(ctx *cli.Context) string { if ctx.GlobalBool(TaipeiFlag.Name) { return filepath.Join(path, "taipei") } + if ctx.GlobalBool(YilanFlag.Name) { + return filepath.Join(path, "yilan") + } return path } Fatalf("Cannot determine default data directory, please set manually (--datadir)") @@ -727,6 +734,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) { urls = params.TestnetBootnodes case ctx.GlobalBool(TaipeiFlag.Name): urls = params.TaipeiBootnodes + case ctx.GlobalBool(YilanFlag.Name): + urls = params.YilanBootnodes case cfg.BootstrapNodes != nil: return // already set, don't apply defaults. } @@ -754,6 +763,8 @@ func setBootstrapNodesV5(ctx *cli.Context, cfg *p2p.Config) { } case ctx.GlobalBool(TaipeiFlag.Name): urls = params.TaipeiBootnodes + case ctx.GlobalBool(YilanFlag.Name): + urls = params.YilanBootnodes case cfg.BootstrapNodesV5 != nil: return // already set, don't apply defaults. } @@ -1030,6 +1041,8 @@ func setDataDir(ctx *cli.Context, cfg *node.Config) { cfg.DataDir = filepath.Join(node.DefaultDataDir(), "testnet") case ctx.GlobalBool(TaipeiFlag.Name): cfg.DataDir = filepath.Join(node.DefaultDataDir(), "taipei") + case ctx.GlobalBool(YilanFlag.Name): + cfg.DataDir = filepath.Join(node.DefaultDataDir(), "yilan") } } @@ -1186,7 +1199,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, TaipeiFlag) + checkExclusive(ctx, DeveloperFlag, TestnetFlag, TaipeiFlag, YilanFlag) checkExclusive(ctx, LightServFlag, SyncModeFlag, "light") ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore) @@ -1256,6 +1269,11 @@ func SetDexConfig(ctx *cli.Context, stack *node.Node, cfg *dex.Config) { cfg.NetworkId = 239 } cfg.Genesis = core.DefaultTaipeiGenesisBlock() + case ctx.GlobalBool(YilanFlag.Name): + if !ctx.GlobalIsSet(NetworkIdFlag.Name) { + cfg.NetworkId = 240 + } + cfg.Genesis = core.DefaultYilanGenesisBlock() case ctx.GlobalBool(DeveloperFlag.Name): if !ctx.GlobalIsSet(NetworkIdFlag.Name) { cfg.NetworkId = 1337 @@ -1428,6 +1446,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis { genesis = core.DefaultTestnetGenesisBlock() case ctx.GlobalBool(TaipeiFlag.Name): genesis = core.DefaultTaipeiGenesisBlock() + case ctx.GlobalBool(YilanFlag.Name): + genesis = core.DefaultYilanGenesisBlock() case ctx.GlobalBool(DeveloperFlag.Name): Fatalf("Developer chains are ephemeral") } diff --git a/core/genesis.go b/core/genesis.go index 40e8a06bf..ff4d9762a 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -237,6 +237,8 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig { return params.MainnetChainConfig case ghash == params.TestnetGenesisHash: return params.TestnetChainConfig + case ghash == params.YilanGenesisHash: + return params.YilanChainConfig default: return params.AllEthashProtocolChanges } @@ -435,6 +437,18 @@ func DefaultTaipeiGenesisBlock() *Genesis { } } +// DefaultYilanGenesisBlock returns the Yilan network genesis block. +func DefaultYilanGenesisBlock() *Genesis { + return &Genesis{ + Config: params.YilanChainConfig, + Nonce: 0x42, + ExtraData: hexutil.MustDecode("0x3535353535353535353535353535353535353535353535353535353535353535"), + GasLimit: 40000000, + Difficulty: big.NewInt(1), + Alloc: decodePrealloc(yilanAllocData), + } +} + // 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/core/genesis_alloc.go b/core/genesis_alloc.go index 8cea595d8..ff65c801e 100644 --- a/core/genesis_alloc.go +++ b/core/genesis_alloc.go @@ -25,3 +25,4 @@ const mainnetAllocData = testnetAllocData const testnetAllocData = "\xf9\x053\xf8\u0194\t\xfc\xb0\xfbfb+\xce~\x17\x86\x96\xfe\xc4p.D\x88k+\xf8\xaf\x8b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x8a\xd3\xc2\x1b\xce\xcc\xed\xa1\x00\x00\x00\x80\xb8A\x04Vx\xa0\xa7N +{=\xe29\xdd|\x0e\xfb\u03f7\x98p\xeb\xcb\aU\xb0\xd0\x05e\x1e\xae\x1c\xa0\xf4\xa7\u00c2\x95\xe5\x8b+\xa7\xeb^\u04a1z\bzv\u0218~\x12-O\xc5>\x9e\x1e\x04\x1a\x9eq\x8en\xf8R\x93Node - asia-east1-2\x9etestnet-asia-east1-2@dexon.org\x8casia-east1-2\x91https://dexon.org\xf8\u0194&(\xe3N\xe04\a29U\uff7b\x02\b\u02c8^\xc3\xcd\xf8\xaf\x8b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x8a\xd3\xc2\x1b\xce\xcc\xed\xa1\x00\x00\x00\x80\xb8A\x04\x94\xa3R\xd3_yv\xcb_\x15\xb1^i\xe9{v\xbb\xd1Z`\x87\x0e\x98r\u065a\xa4d\xd1\xfa\xbd}\f\xb6\xad\u0106\xbd\xdfqY\xe7\xbe\xc0\x17\xeds\x96\xd2\xf4-\u0349\xc1\xdc\u007fw\xdf\xc3]\xa8\x85\xbb\xf3\xf8R\x93Node - asia-east1-0\x9etestnet-asia-east1-0@dexon.org\x8casia-east1-0\x91https://dexon.org\xf8\u05546_\x0f\xb5\x82NlH\xdak\xa5\xae\xeaF\xf4V\xba:q0\xf8\xbe\x8b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x8a\xd3\xc2\x1b\xce\xcc\xed\xa1\x00\x00\x00\x80\xb8A\x04\x97Ka!\x8a\xa6_\xcd\x00S\xb9\xc5j\x03\x18\x9b\xa9\a\x93p\xba\xbc\x9f\xb5\xf4\xa4y\xe1\x1ac\x1d\x83\xc7.;l[\xdc:G\b\v\x0f\xa6\x0f\xa9Y\xf2\xc7yzeq\x92x\xd2*[k\xa7\x9e\xb2\xb6\xe0\xf8a\x98Node - asia-northeast1-1\xa3testnet-asia-northeast1-1@dexon.org\x91asia-northeast1-1\x91https://dexon.org\xf8\u0554`\xceWCm\x96%\x9f}\x90\u00e7}\xe9&\xb8'*\xf65\xf8\xbe\x8b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x8a\xd3\xc2\x1b\xce\xcc\xed\xa1\x00\x00\x00\x80\xb8A\x04\xfa\x90`=Bm\b\x9fx\xbb\b!\a\x05y[\bB\xa1Io\x99$*\x06\x89\x9d{}\u0737\x1f!|\x95h\xa9df\xec\xb1\x14\x12\x91r}A\xc7p\uf843\xa6\xe9\x00Y\x97\xba\x1dT\x9bu\xf2\xcd\xf8a\x98Node - asia-northeast1-0\xa3testnet-asia-northeast1-0@dexon.org\x91asia-northeast1-0\x91https://dexon.org\ua53f\x8cH\xa6 \xba\xccF\x90\u007f\x9b\x89s-%\xe4z-|\xf7\u050b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x80\x80\x80\u0100\x80\x80\x80\xea\x94\xe0\xf8Y4\x03S\x85F\x93\xf57\xea3q\x06\xa3>\x9f\xea\xb0\u050b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x80\x80\x80\u0100\x80\x80\x80\xf8\u0194\xf01\x10\x8e\x17\u04da\x9e\x8d\x8e\xe2a\x81\xe1\x85sF.\xe4\x85\xf8\xaf\x8b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x8a\xd3\xc2\x1b\xce\xcc\xed\xa1\x00\x00\x00\x80\xb8A\x04\x86\xfbL^Q^oA\b&\xcd\x00@\x10\xb0ly\xe7\xbb\x1f\x95\x89\x8e\x82\xaf\x957\x1c\xac\x9a4\x97s0\x86iN\x9du0\xf1T\u02ebe,\xd9ZE\u015f\x1b \xe9O\u0179RD\vN\xdc\b\xe8\xf8R\x93Node - asia-east1-1\x9etestnet-asia-east1-1@dexon.org\x8casia-east1-1\x91https://dexon.org\xf8\u0554\xf3\xbb\xe2@\x1b\xd0\xcb\xe7\x8ca\xdbc\x92\x84\x81\xf3\xbd\xc2\xfe\x1a\xf8\xbe\x8b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x8a\xd3\xc2\x1b\xce\xcc\xed\xa1\x00\x00\x00\x80\xb8A\x04\x96\xce\x05\xc4(\xbe%ge\x8e\xb9\x8d\xdf\xdd\xee\x15\xafg\x94\xbe\xabyQ#\xac\xa1n\x8f\u007f\x14\x91\xe53z\x15Q\xe4b]b8@K\xa0\x881\xcbk\xbd~\xce\xf0TU%AW\x14\u01b0\x10\xe6qc\xf8a\x98Node - asia-northeast1-2\xa3testnet-asia-northeast1-2@dexon.org\x91asia-northeast1-2\x91https://dexon.org" const taipeiAllocData = "\xf9\x053\xf8\u0194\t\xfc\xb0\xfbfb+\xce~\x17\x86\x96\xfe\xc4p.D\x88k+\xf8\xaf\x8b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x8a\xd3\xc2\x1b\xce\xcc\xed\xa1\x00\x00\x00\x80\xb8A\x04Vx\xa0\xa7N +{=\xe29\xdd|\x0e\xfb\u03f7\x98p\xeb\xcb\aU\xb0\xd0\x05e\x1e\xae\x1c\xa0\xf4\xa7\u00c2\x95\xe5\x8b+\xa7\xeb^\u04a1z\bzv\u0218~\x12-O\xc5>\x9e\x1e\x04\x1a\x9eq\x8en\xf8R\x93Node - asia-east1-2\x9etestnet-asia-east1-2@dexon.org\x8casia-east1-2\x91https://dexon.org\xf8\u0194&(\xe3N\xe04\a29U\uff7b\x02\b\u02c8^\xc3\xcd\xf8\xaf\x8b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x8a\xd3\xc2\x1b\xce\xcc\xed\xa1\x00\x00\x00\x80\xb8A\x04\x94\xa3R\xd3_yv\xcb_\x15\xb1^i\xe9{v\xbb\xd1Z`\x87\x0e\x98r\u065a\xa4d\xd1\xfa\xbd}\f\xb6\xad\u0106\xbd\xdfqY\xe7\xbe\xc0\x17\xeds\x96\xd2\xf4-\u0349\xc1\xdc\u007fw\xdf\xc3]\xa8\x85\xbb\xf3\xf8R\x93Node - asia-east1-0\x9etestnet-asia-east1-0@dexon.org\x8casia-east1-0\x91https://dexon.org\xf8\u05546_\x0f\xb5\x82NlH\xdak\xa5\xae\xeaF\xf4V\xba:q0\xf8\xbe\x8b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x8a\xd3\xc2\x1b\xce\xcc\xed\xa1\x00\x00\x00\x80\xb8A\x04\x97Ka!\x8a\xa6_\xcd\x00S\xb9\xc5j\x03\x18\x9b\xa9\a\x93p\xba\xbc\x9f\xb5\xf4\xa4y\xe1\x1ac\x1d\x83\xc7.;l[\xdc:G\b\v\x0f\xa6\x0f\xa9Y\xf2\xc7yzeq\x92x\xd2*[k\xa7\x9e\xb2\xb6\xe0\xf8a\x98Node - asia-northeast1-1\xa3testnet-asia-northeast1-1@dexon.org\x91asia-northeast1-1\x91https://dexon.org\xf8\u0554`\xceWCm\x96%\x9f}\x90\u00e7}\xe9&\xb8'*\xf65\xf8\xbe\x8b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x8a\xd3\xc2\x1b\xce\xcc\xed\xa1\x00\x00\x00\x80\xb8A\x04\xfa\x90`=Bm\b\x9fx\xbb\b!\a\x05y[\bB\xa1Io\x99$*\x06\x89\x9d{}\u0737\x1f!|\x95h\xa9df\xec\xb1\x14\x12\x91r}A\xc7p\uf843\xa6\xe9\x00Y\x97\xba\x1dT\x9bu\xf2\xcd\xf8a\x98Node - asia-northeast1-0\xa3testnet-asia-northeast1-0@dexon.org\x91asia-northeast1-0\x91https://dexon.org\ua53f\x8cH\xa6 \xba\xccF\x90\u007f\x9b\x89s-%\xe4z-|\xf7\u050b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x80\x80\x80\u0100\x80\x80\x80\xea\x94\xe0\xf8Y4\x03S\x85F\x93\xf57\xea3q\x06\xa3>\x9f\xea\xb0\u050b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x80\x80\x80\u0100\x80\x80\x80\xf8\u0194\xf01\x10\x8e\x17\u04da\x9e\x8d\x8e\xe2a\x81\xe1\x85sF.\xe4\x85\xf8\xaf\x8b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x8a\xd3\xc2\x1b\xce\xcc\xed\xa1\x00\x00\x00\x80\xb8A\x04\x86\xfbL^Q^oA\b&\xcd\x00@\x10\xb0ly\xe7\xbb\x1f\x95\x89\x8e\x82\xaf\x957\x1c\xac\x9a4\x97s0\x86iN\x9du0\xf1T\u02ebe,\xd9ZE\u015f\x1b \xe9O\u0179RD\vN\xdc\b\xe8\xf8R\x93Node - asia-east1-1\x9etestnet-asia-east1-1@dexon.org\x8casia-east1-1\x91https://dexon.org\xf8\u0554\xf3\xbb\xe2@\x1b\xd0\xcb\xe7\x8ca\xdbc\x92\x84\x81\xf3\xbd\xc2\xfe\x1a\xf8\xbe\x8b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x8a\xd3\xc2\x1b\xce\xcc\xed\xa1\x00\x00\x00\x80\xb8A\x04\x96\xce\x05\xc4(\xbe%ge\x8e\xb9\x8d\xdf\xdd\xee\x15\xafg\x94\xbe\xabyQ#\xac\xa1n\x8f\u007f\x14\x91\xe53z\x15Q\xe4b]b8@K\xa0\x881\xcbk\xbd~\xce\xf0TU%AW\x14\u01b0\x10\xe6qc\xf8a\x98Node - asia-northeast1-2\xa3testnet-asia-northeast1-2@dexon.org\x91asia-northeast1-2\x91https://dexon.org" +const yilanAllocData = "\xf9\x053\xf8\xbe\x94\x16\x0f \x11\xbd\xa9w\x8d\xfci\xfb\xd3\v\x1b\x11d\t\xa9\xd2\xf2\xf8\xa7\x8b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x8a\xd3\xc2\x1b\xce\xcc\xed\xa1\x00\x00\x00\x80\xb8A\x04M\xd1\xd4~\x1a\xb9\x9aZc\xb9\xcbD\xed\x8d\xe9\xa9V\xdbr\x14\x94\x89\xb5\xbc|#\xa8\xcc!\"\xf3\xee\xed\x01\x10B\xa8WW\u0570\x0eLz\x91\xdd'\t\x8f^\xa1\xab\x92'zV\x00t\x15\x1c\xf4&#\x93\xf8J\x91Node - us-east1-0\x9ayilan-us-east1-0@dexon.org\x8aus-east1-0\x91https://dexon.org\xf8\u0294>P\xe4\n\u007fE\x9e\xabN\t\x04\xfa\xaaf>r\x8f\x01u,\xf8\xb3\x8b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x8a\xd3\xc2\x1b\xce\xcc\xed\xa1\x00\x00\x00\x80\xb8A\x04k8\xc7\xe3\x1e\xa5E\xd0EC\f\xf4>\x9b\xfc\u057f\x0eEY\x82\xe8\x13\x1c\xd7\x06\x8aK\xae\xaa\xe5\xaeN \v?Ol\xbaO>\x8e\x04J\xad\x88 m!)T]\x10)\xe0\xa4\x1bst\x87\xd5\u01189\xf8V\x95Node - europe-west4-0\x9eyilan-europe-west4-0@dexon.org\x8eeurope-west4-0\x91https://dexon.org\xf8\u04d4\x87\xbc\xba\xd4\u048b\x19\x87>\xed^\xc7c\u021e<\f\xfb\xcf_\xf8\xbc\x8b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x8a\xd3\xc2\x1b\xce\xcc\xed\xa1\x00\x00\x00\x80\xb8A\x04\x16\xfb\xdc,\xc1\x1bN\x1a\xf1\x00$w\uf6cc\xe0\xdf\xe5\x14'\x8f\xa7\xe9@c\xe8\xa7V\xbd\xb1\u0313\x16(U\xb9|J\x87@\\\a4\x94\xdd\x1c\x8f7\xd9\bq\xa9n9\xf1BL,'\x8bO`\x18\xdb\xf8_\x98Node - asia-northeast1-0\xa1yilan-asia-northeast1-0@dexon.org\x91asia-northeast1-0\x91https://dexon.org\xf8\u0114\x88\x1a|\u02426\u0264\xfe\u007fUj\xbc\x90E*\xbfW(\x89\xf8\xad\x8b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x8a\xd3\xc2\x1b\xce\xcc\xed\xa1\x00\x00\x00\x80\xb8A\x04d\xa6,2\xbd;^s,G\x1d\xebv\xd37\\\xf0\x1f\xd32\xc6\f\x14m\xd7\xe9@\xc1\x14\x8c\xe1\x10\x03n\xb4\x8ctz{A\xcf\u0772m\x1f\xfa\xfa\x84\xbdsSq\xd6\xf3\xff#\x1a\x1b\x8e\xf4\x14\u0391\x98\xf8P\x93Node - asia-east1-0\x9cyilan-asia-east1-0@dexon.org\x8casia-east1-0\x91https://dexon.org\xf8\ub510\x8d\xb9\x9f\xea\xb0\u050b\x01\xa7\x847\x9d\x99\xdbB\x00\x00\x00\x80\x80\x80\u0100\x80\x80\x80" diff --git a/core/genesis_test.go b/core/genesis_test.go index 9db96c271..c083ed9aa 100644 --- a/core/genesis_test.go +++ b/core/genesis_test.go @@ -104,6 +104,16 @@ func TestSetupGenesis(t *testing.T) { wantHash: params.TestnetGenesisHash, wantConfig: params.TestnetChainConfig, }, + { + name: "custom block in DB, genesis == yilan", + fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, error) { + customg.MustCommit(db) + return SetupGenesisBlock(db, DefaultYilanGenesisBlock()) + }, + wantErr: &GenesisMismatchError{Stored: customghash, New: params.YilanGenesisHash}, + wantHash: params.YilanGenesisHash, + wantConfig: params.YilanChainConfig, + }, { name: "compatible config in DB", fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, error) { diff --git a/dex/blockproposer.go b/dex/blockproposer.go index 21b8ddbde..9827e1ed0 100644 --- a/dex/blockproposer.go +++ b/dex/blockproposer.go @@ -54,7 +54,6 @@ func (b *blockProposer) Start() error { var err error var c *dexCore.Consensus - if b.dMoment.After(time.Now()) { c = b.initConsensus() } else { diff --git a/dex/handler.go b/dex/handler.go index f56c6f5dc..474852913 100644 --- a/dex/handler.go +++ b/dex/handler.go @@ -1248,7 +1248,7 @@ func (pm *ProtocolManager) peerSetLoop() { // NodeInfo represents a short summary of the Ethereum sub-protocol metadata // known about the host peer. type NodeInfo struct { - Network uint64 `json:"network"` // DEXON network ID (237=Mainnet, 238=Taiwan, 239=Taipei) + Network uint64 `json:"network"` // DEXON network ID (237=Mainnet, 238=Taiwan, 239=Taipei, 240=Yilan) Number uint64 `json:"number"` // Total difficulty of the host's blockchain Genesis common.Hash `json:"genesis"` // SHA3 hash of the host's genesis block Config *params.ChainConfig `json:"config"` // Chain configuration for the fork rules diff --git a/params/bootnodes.go b/params/bootnodes.go index 2530215bf..d655680fb 100644 --- a/params/bootnodes.go +++ b/params/bootnodes.go @@ -28,12 +28,18 @@ var TestnetBootnodes = []string{ "enode://0478aa13c91aa0db8e93b668313b7eb0532fbdb24f64772375373b14dbe326c238ad09ab4469f6442c9a9753f1275aeec2e531912c14a958ed1feb4ae7e227ef@35.234.27.122:30301", } -// TestnetBootnodes are the enode URLs of the P2P bootstrap nodes running on the +// TaipeiBootnodes are the enode URLs of the P2P bootstrap nodes running on the // Taipei test network. var TaipeiBootnodes = []string{ "enode://0478aa13c91aa0db8e93b668313b7eb0532fbdb24f64772375373b14dbe326c238ad09ab4469f6442c9a9753f1275aeec2e531912c14a958ed1feb4ae7e227ef@34.80.219.23:30301", } +// YilanBootnodes are the enode URLs of the P2P bootstrap nodes running on the +// Yilan test network. +var YilanBootnodes = []string{ + "enode://0478aa13c91aa0db8e93b668313b7eb0532fbdb24f64772375373b14dbe326c238ad09ab4469f6442c9a9753f1275aeec2e531912c14a958ed1feb4ae7e227ef@34.80.4.56:30301", +} + // DiscoveryV5Bootnodes are the enode URLs of the P2P bootstrap nodes for the // experimental RLPx v5 topic-discovery network. var DiscoveryV5Bootnodes = []string{} diff --git a/params/config.go b/params/config.go index c9a648bd8..8e20a15a4 100644 --- a/params/config.go +++ b/params/config.go @@ -28,6 +28,7 @@ import ( var ( MainnetGenesisHash = common.HexToHash("0xf80aae99a7c44bc54d7b0cc8a16645fa3ea65c01b180339f17b31a698b031271") TestnetGenesisHash = common.HexToHash("0x7f704c8d0a773d0fcca231d40bf39495553886bf8800b4a06920786a802103e1") + YilanGenesisHash = common.HexToHash("0x394f057bc19b7762eaccd7e250afa213e9b0e60d1204a234fd11ed03eabfb90e") ) // TrustedCheckpoints associates each known checkpoint with the genesis hash of @@ -168,6 +169,42 @@ var ( BloomRoot: common.HexToHash("0x5ac25c84bd18a9cbe878d4609a80220f57f85037a112644532412ba0d498a31b"), } + // YilanChainConfig contains the chain parameters to run a node on the Yilan test network. + YilanChainConfig = &ChainConfig{ + ChainID: big.NewInt(240), + DMoment: 1550802900, + 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: big.NewInt(0), + Dexcon: &DexconConfig{ + GenesisCRSText: "In DEXON, we trust, at Yilan", + Owner: common.HexToAddress("BF8C48A620bacc46907f9B89732D25E47A2D7Cf7"), + MinStake: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e6)), + LockupPeriod: 86400 * 3 * 1000, + MiningVelocity: 0.1875, + NextHalvingSupply: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(2e7)), + LastHalvedAmount: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(4e6)), + BlockGasLimit: 40000000, + LambdaBA: 250, + LambdaDKG: 10000, + NotarySetSize: 4, + DKGSetSize: 4, + RoundLength: 1200, + MinBlockInterval: 1000, + FineValues: []*big.Int{ + new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e4)), + new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e4)), + new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e5)), + }, + MinGasPrice: new(big.Int).Mul(big.NewInt(1e9), big.NewInt(1)), + }, + } + // AllEthashProtocolChanges contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers into the Ethash consensus. // -- cgit