diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 4f3d81f5d2..5c2ee99585 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -135,6 +135,10 @@ var ( Name: "testnet", Usage: "Ropsten network: pre-configured proof-of-work test network", } + EllaismFlag = cli.BoolFlag{ + Name: "ellaism", + Usage: "Ellaism network: pre-configured Ellaism mainnet", + } RinkebyFlag = cli.BoolFlag{ Name: "rinkeby", Usage: "Rinkeby network: pre-configured proof-of-authority test network", @@ -542,6 +546,9 @@ func MakeDataDir(ctx *cli.Context) string { if ctx.GlobalBool(TestnetFlag.Name) { return filepath.Join(path, "testnet") } + if ctx.GlobalBool(EllaismFlag.Name) { + return filepath.Join(path, "ellaism") + } if ctx.GlobalBool(RinkebyFlag.Name) { return filepath.Join(path, "rinkeby") } @@ -597,6 +604,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) { } case ctx.GlobalBool(TestnetFlag.Name): urls = params.TestnetBootnodes + case ctx.GlobalBool(EllaismFlag.Name): + urls = params.EllaismBootnodes case ctx.GlobalBool(RinkebyFlag.Name): urls = params.RinkebyBootnodes case cfg.BootstrapNodes != nil: @@ -883,6 +892,8 @@ func SetNodeConfig(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(EllaismFlag.Name): + cfg.DataDir = filepath.Join(node.DefaultDataDir(), "ellaism") case ctx.GlobalBool(RinkebyFlag.Name): cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby") } @@ -1012,7 +1023,7 @@ func SetShhConfig(ctx *cli.Context, stack *node.Node, cfg *whisper.Config) { // SetEthConfig applies eth-related command line flags to the config. func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { // Avoid conflicting network flags - checkExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag) + checkExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag, EllaismFlag) checkExclusive(ctx, FastSyncFlag, LightModeFlag, SyncModeFlag) checkExclusive(ctx, LightServFlag, LightModeFlag) checkExclusive(ctx, LightServFlag, SyncModeFlag, "light") @@ -1078,6 +1089,11 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { cfg.NetworkId = 3 } cfg.Genesis = core.DefaultTestnetGenesisBlock() + case ctx.GlobalBool(EllaismFlag.Name): + if !ctx.GlobalIsSet(NetworkIdFlag.Name) { + cfg.NetworkId = 64 + } + cfg.Genesis = core.DefaultEllaismGenesisBlock() case ctx.GlobalBool(RinkebyFlag.Name): if !ctx.GlobalIsSet(NetworkIdFlag.Name) { cfg.NetworkId = 4 @@ -1203,6 +1219,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis { switch { case ctx.GlobalBool(TestnetFlag.Name): genesis = core.DefaultTestnetGenesisBlock() + case ctx.GlobalBool(EllaismFlag.Name): + genesis = core.DefaultEllaismGenesisBlock() case ctx.GlobalBool(RinkebyFlag.Name): genesis = core.DefaultRinkebyGenesisBlock() case ctx.GlobalBool(DeveloperFlag.Name): diff --git a/core/genesis.go b/core/genesis.go index b6ead2250a..fbb2226e74 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -214,6 +214,8 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig { return params.MainnetChainConfig case ghash == params.TestnetGenesisHash: return params.TestnetChainConfig + case ghash == params.EllaismGenesisHash: + return params.EllaismChainConfig default: return params.AllEthashProtocolChanges } @@ -320,6 +322,18 @@ func DefaultGenesisBlock() *Genesis { } } +// EllaismGenesisBlock returns the Ellaism genesis block. +func DefaultEllaismGenesisBlock() *Genesis { + return &Genesis { + Config: params.EllaismChainConfig, + Nonce: 64, + ExtraData: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000000"), + GasLimit: 5000, + Difficulty: big.NewInt(17179869184), + Alloc: decodePrealloc(ellaismAllocData), + } +} + // DefaultTestnetGenesisBlock returns the Ropsten network genesis block. func DefaultTestnetGenesisBlock() *Genesis { return &Genesis{ diff --git a/mobile/geth.go b/mobile/geth.go index 488a4150fc..43b19efcff 100644 --- a/mobile/geth.go +++ b/mobile/geth.go @@ -141,6 +141,12 @@ func NewNode(datadir string, config *NodeConfig) (stack *Node, _ error) { config.EthereumNetworkID = 3 } } + if config.EthereumGenesis == EllaismGenesis() { + genesis.Config = params.EllaismChainConfig + if config.EthereumNetworkID == 1 { + config.EthereumNetworkID = 64 + } + } } // Register the Ethereum protocol if requested if config.EthereumEnabled { diff --git a/mobile/params.go b/mobile/params.go index 45fe870ee3..c5ccd61a54 100644 --- a/mobile/params.go +++ b/mobile/params.go @@ -32,6 +32,15 @@ func MainnetGenesis() string { return "" } +// EllaismGenesis returns the JSON spec to use for the Ellaism network. +func EllaismGenesis() string { + enc, err := json.Marshal(core.DefaultEllaismGenesisBlock()) + if err != nil { + panic(err) + } + return string(enc) +} + // TestnetGenesis returns the JSON spec to use for the Ethereum test network. func TestnetGenesis() string { enc, err := json.Marshal(core.DefaultTestnetGenesisBlock())