cmd/utils: add network flags for worldland mainnet and testnet

This commit is contained in:
Your Name 2024-04-23 13:10:37 +09:00
parent b1853568f5
commit 87a1904e6f

View file

@ -122,7 +122,7 @@ var (
Value: ethconfig.Defaults.NetworkId, Value: ethconfig.Defaults.NetworkId,
Category: flags.EthCategory, Category: flags.EthCategory,
} }
MainnetFlag = &cli.BoolFlag{ /*MainnetFlag = &cli.BoolFlag{
Name: "mainnet", Name: "mainnet",
Usage: "Ethereum mainnet", Usage: "Ethereum mainnet",
Category: flags.EthCategory, Category: flags.EthCategory,
@ -151,6 +151,20 @@ var (
Name: "kiln", Name: "kiln",
Usage: "Kiln network: pre-configured proof-of-work to proof-of-stake test network", Usage: "Kiln network: pre-configured proof-of-work to proof-of-stake test network",
Category: flags.EthCategory, Category: flags.EthCategory,
}*/
// EccPoW settings
LveFlag = &cli.BoolFlag{
Name: "lve",
Usage: "LVE Network: Error-Correction Codes Proof-of-Work Main Network",
}
// Worldland settings
SeoulFlag = &cli.BoolFlag{
Name: "seoul",
Usage: "Seoul Network: Error-Correction Codes Proof-of-Work Main Network",
}
GwangjuFlag = &cli.BoolFlag{
Name: "gwangju",
Usage: "Gwangju network: Error-Correction Codes Proof-of-Work Test Network",
} }
// Dev mode // Dev mode
@ -981,15 +995,18 @@ var (
var ( var (
// TestnetFlags is the flag group of all built-in supported testnets. // TestnetFlags is the flag group of all built-in supported testnets.
TestnetFlags = []cli.Flag{ TestnetFlags = []cli.Flag{
RopstenFlag, /*RopstenFlag,
RinkebyFlag, RinkebyFlag,
GoerliFlag, GoerliFlag,
SepoliaFlag, SepoliaFlag,
KilnFlag, KilnFlag,*/
GwangjuFlag,
} }
// NetworkFlags is the flag group of all built-in supported networks. // NetworkFlags is the flag group of all built-in supported networks.
NetworkFlags = append([]cli.Flag{ NetworkFlags = append([]cli.Flag{
MainnetFlag, //MainnetFlag,
LveFlag,
SeoulFlag,
}, TestnetFlags...) }, TestnetFlags...)
// DatabasePathFlags is the flag group of all database path flags. // DatabasePathFlags is the flag group of all database path flags.
@ -1005,7 +1022,7 @@ var (
// then a subdirectory of the specified datadir will be used. // then a subdirectory of the specified datadir will be used.
func MakeDataDir(ctx *cli.Context) string { func MakeDataDir(ctx *cli.Context) string {
if path := ctx.String(DataDirFlag.Name); path != "" { if path := ctx.String(DataDirFlag.Name); path != "" {
if ctx.Bool(RopstenFlag.Name) { /*if ctx.Bool(RopstenFlag.Name) {
// Maintain compatibility with older Geth configurations storing the // Maintain compatibility with older Geth configurations storing the
// Ropsten database in `testnet` instead of `ropsten`. // Ropsten database in `testnet` instead of `ropsten`.
return filepath.Join(path, "ropsten") return filepath.Join(path, "ropsten")
@ -1021,6 +1038,15 @@ func MakeDataDir(ctx *cli.Context) string {
} }
if ctx.Bool(KilnFlag.Name) { if ctx.Bool(KilnFlag.Name) {
return filepath.Join(path, "kiln") return filepath.Join(path, "kiln")
}*/
if ctx.Bool(LveFlag.Name) {
return filepath.Join(path, "lve")
}
if ctx.Bool(SeoulFlag.Name) {
return filepath.Join(path, "seoul")
}
if ctx.Bool(GwangjuFlag.Name) {
return filepath.Join(path, "gwangju")
} }
return path return path
} }
@ -1068,7 +1094,7 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
switch { switch {
case ctx.IsSet(BootnodesFlag.Name): case ctx.IsSet(BootnodesFlag.Name):
urls = SplitAndTrim(ctx.String(BootnodesFlag.Name)) urls = SplitAndTrim(ctx.String(BootnodesFlag.Name))
case ctx.Bool(RopstenFlag.Name): /*case ctx.Bool(RopstenFlag.Name):
urls = params.RopstenBootnodes urls = params.RopstenBootnodes
case ctx.Bool(SepoliaFlag.Name): case ctx.Bool(SepoliaFlag.Name):
urls = params.SepoliaBootnodes urls = params.SepoliaBootnodes
@ -1077,9 +1103,14 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
case ctx.Bool(GoerliFlag.Name): case ctx.Bool(GoerliFlag.Name):
urls = params.GoerliBootnodes urls = params.GoerliBootnodes
case ctx.Bool(KilnFlag.Name): case ctx.Bool(KilnFlag.Name):
urls = params.KilnBootnodes urls = params.KilnBootnodes*/
case ctx.Bool(LveFlag.Name):
urls = params.LveBootnodes
case ctx.Bool(SeoulFlag.Name):
urls = params.SeoulBootnodes
case ctx.Bool(GwangjuFlag.Name):
urls = params.GwangjuBootnodes
} }
// don't apply defaults if BootstrapNodes is already set // don't apply defaults if BootstrapNodes is already set
if cfg.BootstrapNodes != nil { if cfg.BootstrapNodes != nil {
return return
@ -1516,7 +1547,7 @@ func SetDataDir(ctx *cli.Context, cfg *node.Config) {
cfg.DataDir = ctx.String(DataDirFlag.Name) cfg.DataDir = ctx.String(DataDirFlag.Name)
case ctx.Bool(DeveloperFlag.Name): case ctx.Bool(DeveloperFlag.Name):
cfg.DataDir = "" // unless explicitly requested, use memory databases cfg.DataDir = "" // unless explicitly requested, use memory databases
case ctx.Bool(RopstenFlag.Name) && cfg.DataDir == node.DefaultDataDir(): /*case ctx.Bool(RopstenFlag.Name) && cfg.DataDir == node.DefaultDataDir():
// Maintain compatibility with older Geth configurations storing the // Maintain compatibility with older Geth configurations storing the
// Ropsten database in `testnet` instead of `ropsten`. // Ropsten database in `testnet` instead of `ropsten`.
legacyPath := filepath.Join(node.DefaultDataDir(), "testnet") legacyPath := filepath.Join(node.DefaultDataDir(), "testnet")
@ -1535,7 +1566,13 @@ func SetDataDir(ctx *cli.Context, cfg *node.Config) {
case ctx.Bool(SepoliaFlag.Name) && cfg.DataDir == node.DefaultDataDir(): case ctx.Bool(SepoliaFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "sepolia") cfg.DataDir = filepath.Join(node.DefaultDataDir(), "sepolia")
case ctx.Bool(KilnFlag.Name) && cfg.DataDir == node.DefaultDataDir(): case ctx.Bool(KilnFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "kiln") cfg.DataDir = filepath.Join(node.DefaultDataDir(), "kiln")*/
case ctx.Bool(LveFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "lve")
case ctx.Bool(SeoulFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "seoul")
case ctx.Bool(GwangjuFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "gwangju")
} }
} }
@ -1726,7 +1763,8 @@ func CheckExclusive(ctx *cli.Context, args ...interface{}) {
// 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 *ethconfig.Config) { func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
// Avoid conflicting network flags // Avoid conflicting network flags
CheckExclusive(ctx, MainnetFlag, DeveloperFlag, RopstenFlag, RinkebyFlag, GoerliFlag, SepoliaFlag, KilnFlag) //CheckExclusive(ctx, MainnetFlag, DeveloperFlag, RopstenFlag, RinkebyFlag, GoerliFlag, SepoliaFlag, KilnFlag, LveFlag, SeoulFlag, GwangjuFlag)
CheckExclusive(ctx, DeveloperFlag, LveFlag, SeoulFlag, GwangjuFlag)
CheckExclusive(ctx, LightServeFlag, SyncModeFlag, "light") CheckExclusive(ctx, LightServeFlag, SyncModeFlag, "light")
CheckExclusive(ctx, DeveloperFlag, ExternalSignerFlag) // Can't use both ephemeral unlocked and external signer CheckExclusive(ctx, DeveloperFlag, ExternalSignerFlag) // Can't use both ephemeral unlocked and external signer
if ctx.String(GCModeFlag.Name) == "archive" && ctx.Uint64(TxLookupLimitFlag.Name) != 0 { if ctx.String(GCModeFlag.Name) == "archive" && ctx.Uint64(TxLookupLimitFlag.Name) != 0 {
@ -1861,7 +1899,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
} }
// Override any default configs for hard coded networks. // Override any default configs for hard coded networks.
switch { switch {
case ctx.Bool(MainnetFlag.Name): /*case ctx.Bool(MainnetFlag.Name):
if !ctx.IsSet(NetworkIdFlag.Name) { if !ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 1 cfg.NetworkId = 1
} }
@ -1906,7 +1944,25 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
cfg.NetworkId = 1337802 cfg.NetworkId = 1337802
} }
cfg.Genesis = core.DefaultKilnGenesisBlock() cfg.Genesis = core.DefaultKilnGenesisBlock()
SetDNSDiscoveryDefaults(cfg, params.KilnGenesisHash) SetDNSDiscoveryDefaults(cfg, params.KilnGenesisHash)*/
case ctx.Bool(LveFlag.Name):
if !ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 12345
}
cfg.Genesis = core.DefaultLveGenesisBlock()
SetDNSDiscoveryDefaults(cfg, params.LveGenesisHash)
case ctx.Bool(SeoulFlag.Name):
if !ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 103
}
cfg.Genesis = core.DefaultSeoulGenesisBlock()
SetDNSDiscoveryDefaults(cfg, params.SeoulGenesisHash)
case ctx.Bool(GwangjuFlag.Name):
if !ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 10395
}
cfg.Genesis = core.DefaultGwangjuGenesisBlock()
SetDNSDiscoveryDefaults(cfg, params.GwangjuGenesisHash)
case ctx.Bool(DeveloperFlag.Name): case ctx.Bool(DeveloperFlag.Name):
if !ctx.IsSet(NetworkIdFlag.Name) { if !ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 1337 cfg.NetworkId = 1337
@ -2146,7 +2202,7 @@ func MakeChainDatabase(ctx *cli.Context, stack *node.Node, readonly bool) ethdb.
func MakeGenesis(ctx *cli.Context) *core.Genesis { func MakeGenesis(ctx *cli.Context) *core.Genesis {
var genesis *core.Genesis var genesis *core.Genesis
switch { switch {
case ctx.Bool(MainnetFlag.Name): /*case ctx.Bool(MainnetFlag.Name):
genesis = core.DefaultGenesisBlock() genesis = core.DefaultGenesisBlock()
case ctx.Bool(RopstenFlag.Name): case ctx.Bool(RopstenFlag.Name):
genesis = core.DefaultRopstenGenesisBlock() genesis = core.DefaultRopstenGenesisBlock()
@ -2157,7 +2213,13 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
case ctx.Bool(GoerliFlag.Name): case ctx.Bool(GoerliFlag.Name):
genesis = core.DefaultGoerliGenesisBlock() genesis = core.DefaultGoerliGenesisBlock()
case ctx.Bool(KilnFlag.Name): case ctx.Bool(KilnFlag.Name):
genesis = core.DefaultKilnGenesisBlock() genesis = core.DefaultKilnGenesisBlock()*/
case ctx.Bool(LveFlag.Name):
genesis = core.DefaultLveGenesisBlock()
case ctx.Bool(SeoulFlag.Name):
genesis = core.DefaultSeoulGenesisBlock()
case ctx.Bool(GwangjuFlag.Name):
genesis = core.DefaultGwangjuGenesisBlock()
case ctx.Bool(DeveloperFlag.Name): case ctx.Bool(DeveloperFlag.Name):
Fatalf("Developer chains are ephemeral") Fatalf("Developer chains are ephemeral")
} }
@ -2174,11 +2236,22 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (*core.BlockChain, ethdb.Data
if err != nil { if err != nil {
Fatalf("%v", err) Fatalf("%v", err)
} }
/*eccpowConfig, err := core.LoadEccpowConfig(chainDb, gspec)
if err != nil {
Fatalf("%v", err)
}*/
ethashConfig := ethconfig.Defaults.Ethash ethashConfig := ethconfig.Defaults.Ethash
if ctx.Bool(FakePoWFlag.Name) { if ctx.Bool(FakePoWFlag.Name) {
ethashConfig.PowMode = ethash.ModeFake ethashConfig.PowMode = ethash.ModeFake
} }
engine := ethconfig.CreateConsensusEngine(stack, &ethashConfig, cliqueConfig, nil, false, chainDb)
eccpowConfig := ethconfig.Defaults.Eccpow
if ctx.Bool(FakePoWFlag.Name) {
ethashConfig.PowMode = ethash.ModeFake
}
engine := ethconfig.CreateConsensusEngine(stack, &ethashConfig, cliqueConfig, &eccpowConfig, nil, false, chainDb)
if gcmode := ctx.String(GCModeFlag.Name); gcmode != "full" && gcmode != "archive" { if gcmode := ctx.String(GCModeFlag.Name); gcmode != "full" && gcmode != "archive" {
Fatalf("--%s must be either 'full' or 'archive'", GCModeFlag.Name) Fatalf("--%s must be either 'full' or 'archive'", GCModeFlag.Name)
} }