Add ellaism flags/configs in geth executable

This commit is contained in:
Ellaismer 2018-03-27 03:19:46 -04:00
parent a2fa4961c0
commit 5525c96bb5
4 changed files with 48 additions and 1 deletions

View file

@ -135,6 +135,10 @@ var (
Name: "testnet", Name: "testnet",
Usage: "Ropsten network: pre-configured proof-of-work test network", 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{ RinkebyFlag = cli.BoolFlag{
Name: "rinkeby", Name: "rinkeby",
Usage: "Rinkeby network: pre-configured proof-of-authority test network", 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) { if ctx.GlobalBool(TestnetFlag.Name) {
return filepath.Join(path, "testnet") return filepath.Join(path, "testnet")
} }
if ctx.GlobalBool(EllaismFlag.Name) {
return filepath.Join(path, "ellaism")
}
if ctx.GlobalBool(RinkebyFlag.Name) { if ctx.GlobalBool(RinkebyFlag.Name) {
return filepath.Join(path, "rinkeby") return filepath.Join(path, "rinkeby")
} }
@ -597,6 +604,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
} }
case ctx.GlobalBool(TestnetFlag.Name): case ctx.GlobalBool(TestnetFlag.Name):
urls = params.TestnetBootnodes urls = params.TestnetBootnodes
case ctx.GlobalBool(EllaismFlag.Name):
urls = params.EllaismBootnodes
case ctx.GlobalBool(RinkebyFlag.Name): case ctx.GlobalBool(RinkebyFlag.Name):
urls = params.RinkebyBootnodes urls = params.RinkebyBootnodes
case cfg.BootstrapNodes != nil: case cfg.BootstrapNodes != nil:
@ -883,6 +892,8 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
cfg.DataDir = "" // unless explicitly requested, use memory databases cfg.DataDir = "" // unless explicitly requested, use memory databases
case ctx.GlobalBool(TestnetFlag.Name): case ctx.GlobalBool(TestnetFlag.Name):
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "testnet") cfg.DataDir = filepath.Join(node.DefaultDataDir(), "testnet")
case ctx.GlobalBool(EllaismFlag.Name):
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "ellaism")
case ctx.GlobalBool(RinkebyFlag.Name): case ctx.GlobalBool(RinkebyFlag.Name):
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby") 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. // SetEthConfig applies eth-related command line flags to the config.
func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
// Avoid conflicting network flags // Avoid conflicting network flags
checkExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag) checkExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag, EllaismFlag)
checkExclusive(ctx, FastSyncFlag, LightModeFlag, SyncModeFlag) checkExclusive(ctx, FastSyncFlag, LightModeFlag, SyncModeFlag)
checkExclusive(ctx, LightServFlag, LightModeFlag) checkExclusive(ctx, LightServFlag, LightModeFlag)
checkExclusive(ctx, LightServFlag, SyncModeFlag, "light") checkExclusive(ctx, LightServFlag, SyncModeFlag, "light")
@ -1078,6 +1089,11 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
cfg.NetworkId = 3 cfg.NetworkId = 3
} }
cfg.Genesis = core.DefaultTestnetGenesisBlock() 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): case ctx.GlobalBool(RinkebyFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) { if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 4 cfg.NetworkId = 4
@ -1203,6 +1219,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
switch { switch {
case ctx.GlobalBool(TestnetFlag.Name): case ctx.GlobalBool(TestnetFlag.Name):
genesis = core.DefaultTestnetGenesisBlock() genesis = core.DefaultTestnetGenesisBlock()
case ctx.GlobalBool(EllaismFlag.Name):
genesis = core.DefaultEllaismGenesisBlock()
case ctx.GlobalBool(RinkebyFlag.Name): case ctx.GlobalBool(RinkebyFlag.Name):
genesis = core.DefaultRinkebyGenesisBlock() genesis = core.DefaultRinkebyGenesisBlock()
case ctx.GlobalBool(DeveloperFlag.Name): case ctx.GlobalBool(DeveloperFlag.Name):

View file

@ -214,6 +214,8 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
return params.MainnetChainConfig return params.MainnetChainConfig
case ghash == params.TestnetGenesisHash: case ghash == params.TestnetGenesisHash:
return params.TestnetChainConfig return params.TestnetChainConfig
case ghash == params.EllaismGenesisHash:
return params.EllaismChainConfig
default: default:
return params.AllEthashProtocolChanges 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. // DefaultTestnetGenesisBlock returns the Ropsten network genesis block.
func DefaultTestnetGenesisBlock() *Genesis { func DefaultTestnetGenesisBlock() *Genesis {
return &Genesis{ return &Genesis{

View file

@ -141,6 +141,12 @@ func NewNode(datadir string, config *NodeConfig) (stack *Node, _ error) {
config.EthereumNetworkID = 3 config.EthereumNetworkID = 3
} }
} }
if config.EthereumGenesis == EllaismGenesis() {
genesis.Config = params.EllaismChainConfig
if config.EthereumNetworkID == 1 {
config.EthereumNetworkID = 64
}
}
} }
// Register the Ethereum protocol if requested // Register the Ethereum protocol if requested
if config.EthereumEnabled { if config.EthereumEnabled {

View file

@ -32,6 +32,15 @@ func MainnetGenesis() string {
return "" 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. // TestnetGenesis returns the JSON spec to use for the Ethereum test network.
func TestnetGenesis() string { func TestnetGenesis() string {
enc, err := json.Marshal(core.DefaultTestnetGenesisBlock()) enc, err := json.Marshal(core.DefaultTestnetGenesisBlock())