mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-22 11:31:02 +00:00
Add flags for pulsechain and pulsechain-testnet
This commit is contained in:
parent
76e6e7133e
commit
7ef8508d7b
@ -278,6 +278,9 @@ func main() {
|
|||||||
func prepare(ctx *cli.Context) {
|
func prepare(ctx *cli.Context) {
|
||||||
// If we're running a known preset, log it for convenience.
|
// If we're running a known preset, log it for convenience.
|
||||||
switch {
|
switch {
|
||||||
|
case ctx.IsSet(utils.PulseChainFlag.Name):
|
||||||
|
log.Info("Starting Geth on PulseChain mainnet...")
|
||||||
|
|
||||||
case ctx.IsSet(utils.GoerliFlag.Name):
|
case ctx.IsSet(utils.GoerliFlag.Name):
|
||||||
log.Info("Starting Geth on Görli testnet...")
|
log.Info("Starting Geth on Görli testnet...")
|
||||||
|
|
||||||
@ -287,6 +290,9 @@ func prepare(ctx *cli.Context) {
|
|||||||
case ctx.IsSet(utils.HoleskyFlag.Name):
|
case ctx.IsSet(utils.HoleskyFlag.Name):
|
||||||
log.Info("Starting Geth on Holesky testnet...")
|
log.Info("Starting Geth on Holesky testnet...")
|
||||||
|
|
||||||
|
case ctx.IsSet(utils.PulseChainTestnetFlag.Name):
|
||||||
|
log.Info("Starting Geth on PulseChain testnet...")
|
||||||
|
|
||||||
case ctx.IsSet(utils.DeveloperFlag.Name):
|
case ctx.IsSet(utils.DeveloperFlag.Name):
|
||||||
log.Info("Starting Geth in ephemeral dev mode...")
|
log.Info("Starting Geth in ephemeral dev mode...")
|
||||||
log.Warn(`You are running Geth in --dev mode. Please note the following:
|
log.Warn(`You are running Geth in --dev mode. Please note the following:
|
||||||
@ -315,7 +321,7 @@ func prepare(ctx *cli.Context) {
|
|||||||
!ctx.IsSet(utils.SepoliaFlag.Name) &&
|
!ctx.IsSet(utils.SepoliaFlag.Name) &&
|
||||||
!ctx.IsSet(utils.GoerliFlag.Name) &&
|
!ctx.IsSet(utils.GoerliFlag.Name) &&
|
||||||
!ctx.IsSet(utils.DeveloperFlag.Name) {
|
!ctx.IsSet(utils.DeveloperFlag.Name) {
|
||||||
// Nope, we're really on mainnet. Bump that cache up!
|
// Nope, we're really on mainnet or PulseChain. Bump that cache up!
|
||||||
log.Info("Bumping default cache on mainnet", "provided", ctx.Int(utils.CacheFlag.Name), "updated", 4096)
|
log.Info("Bumping default cache on mainnet", "provided", ctx.Int(utils.CacheFlag.Name), "updated", 4096)
|
||||||
ctx.Set(utils.CacheFlag.Name, strconv.Itoa(4096))
|
ctx.Set(utils.CacheFlag.Name, strconv.Itoa(4096))
|
||||||
}
|
}
|
||||||
|
@ -140,6 +140,10 @@ var (
|
|||||||
Usage: "Ethereum mainnet",
|
Usage: "Ethereum mainnet",
|
||||||
Category: flags.EthCategory,
|
Category: flags.EthCategory,
|
||||||
}
|
}
|
||||||
|
PulseChainFlag = &cli.BoolFlag{
|
||||||
|
Name: "pulsechain",
|
||||||
|
Usage: "PulseChain mainnet",
|
||||||
|
}
|
||||||
GoerliFlag = &cli.BoolFlag{
|
GoerliFlag = &cli.BoolFlag{
|
||||||
Name: "goerli",
|
Name: "goerli",
|
||||||
Usage: "Görli network: pre-configured proof-of-authority test network",
|
Usage: "Görli network: pre-configured proof-of-authority test network",
|
||||||
@ -155,6 +159,11 @@ var (
|
|||||||
Usage: "Holesky network: pre-configured proof-of-stake test network",
|
Usage: "Holesky network: pre-configured proof-of-stake test network",
|
||||||
Category: flags.EthCategory,
|
Category: flags.EthCategory,
|
||||||
}
|
}
|
||||||
|
PulseChainTestnetFlag = &cli.BoolFlag{
|
||||||
|
Name: "pulsechain-testnet",
|
||||||
|
Usage: "PulseChain testnet",
|
||||||
|
}
|
||||||
|
|
||||||
// Dev mode
|
// Dev mode
|
||||||
DeveloperFlag = &cli.BoolFlag{
|
DeveloperFlag = &cli.BoolFlag{
|
||||||
Name: "dev",
|
Name: "dev",
|
||||||
@ -916,9 +925,13 @@ var (
|
|||||||
GoerliFlag,
|
GoerliFlag,
|
||||||
SepoliaFlag,
|
SepoliaFlag,
|
||||||
HoleskyFlag,
|
HoleskyFlag,
|
||||||
|
PulseChainTestnetFlag,
|
||||||
}
|
}
|
||||||
// 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{MainnetFlag}, TestnetFlags...)
|
NetworkFlags = append([]cli.Flag{
|
||||||
|
MainnetFlag,
|
||||||
|
PulseChainFlag,
|
||||||
|
}, TestnetFlags...)
|
||||||
|
|
||||||
// DatabaseFlags is the flag group of all database flags.
|
// DatabaseFlags is the flag group of all database flags.
|
||||||
DatabaseFlags = []cli.Flag{
|
DatabaseFlags = []cli.Flag{
|
||||||
@ -936,6 +949,9 @@ 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(PulseChainFlag.Name) {
|
||||||
|
return filepath.Join(path, "pulsechain")
|
||||||
|
}
|
||||||
if ctx.Bool(GoerliFlag.Name) {
|
if ctx.Bool(GoerliFlag.Name) {
|
||||||
return filepath.Join(path, "goerli")
|
return filepath.Join(path, "goerli")
|
||||||
}
|
}
|
||||||
@ -945,6 +961,9 @@ func MakeDataDir(ctx *cli.Context) string {
|
|||||||
if ctx.Bool(HoleskyFlag.Name) {
|
if ctx.Bool(HoleskyFlag.Name) {
|
||||||
return filepath.Join(path, "holesky")
|
return filepath.Join(path, "holesky")
|
||||||
}
|
}
|
||||||
|
if ctx.Bool(PulseChainTestnetFlag.Name) {
|
||||||
|
return filepath.Join(path, "pulsechain-testnet")
|
||||||
|
}
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
Fatalf("Cannot determine default data directory, please set manually (--datadir)")
|
Fatalf("Cannot determine default data directory, please set manually (--datadir)")
|
||||||
@ -1001,12 +1020,16 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
|
|||||||
return // Already set by config file, don't apply defaults.
|
return // Already set by config file, don't apply defaults.
|
||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
|
case ctx.Bool(PulseChainFlag.Name):
|
||||||
|
urls = params.PulseChainBootnodes
|
||||||
case ctx.Bool(HoleskyFlag.Name):
|
case ctx.Bool(HoleskyFlag.Name):
|
||||||
urls = params.HoleskyBootnodes
|
urls = params.HoleskyBootnodes
|
||||||
case ctx.Bool(SepoliaFlag.Name):
|
case ctx.Bool(SepoliaFlag.Name):
|
||||||
urls = params.SepoliaBootnodes
|
urls = params.SepoliaBootnodes
|
||||||
case ctx.Bool(GoerliFlag.Name):
|
case ctx.Bool(GoerliFlag.Name):
|
||||||
urls = params.GoerliBootnodes
|
urls = params.GoerliBootnodes
|
||||||
|
case ctx.Bool(PulseChainTestnetFlag.Name):
|
||||||
|
urls = params.PulseChainTestnetBootnodes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cfg.BootstrapNodes = mustParseBootnodes(urls)
|
cfg.BootstrapNodes = mustParseBootnodes(urls)
|
||||||
@ -1428,12 +1451,16 @@ 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(PulseChainFlag.Name) && cfg.DataDir == node.DefaultDataDir():
|
||||||
|
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "pulsechain")
|
||||||
case ctx.Bool(GoerliFlag.Name) && cfg.DataDir == node.DefaultDataDir():
|
case ctx.Bool(GoerliFlag.Name) && cfg.DataDir == node.DefaultDataDir():
|
||||||
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "goerli")
|
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "goerli")
|
||||||
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(HoleskyFlag.Name) && cfg.DataDir == node.DefaultDataDir():
|
case ctx.Bool(HoleskyFlag.Name) && cfg.DataDir == node.DefaultDataDir():
|
||||||
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "holesky")
|
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "holesky")
|
||||||
|
case ctx.Bool(PulseChainTestnetFlag.Name) && cfg.DataDir == node.DefaultDataDir():
|
||||||
|
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "pulsechain-testnet")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1585,7 +1612,7 @@ 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, GoerliFlag, SepoliaFlag, HoleskyFlag)
|
CheckExclusive(ctx, MainnetFlag, PulseChainFlag, DeveloperFlag, GoerliFlag, SepoliaFlag, HoleskyFlag, PulseChainTestnetFlag)
|
||||||
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
|
||||||
|
|
||||||
// Set configurations from CLI flags
|
// Set configurations from CLI flags
|
||||||
@ -1736,6 +1763,12 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
|||||||
}
|
}
|
||||||
cfg.Genesis = core.DefaultGenesisBlock()
|
cfg.Genesis = core.DefaultGenesisBlock()
|
||||||
SetDNSDiscoveryDefaults(cfg, params.MainnetGenesisHash)
|
SetDNSDiscoveryDefaults(cfg, params.MainnetGenesisHash)
|
||||||
|
case ctx.Bool(PulseChainFlag.Name):
|
||||||
|
if !ctx.IsSet(NetworkIdFlag.Name) {
|
||||||
|
cfg.NetworkId = 369
|
||||||
|
}
|
||||||
|
cfg.Genesis = core.DefaultPulseChainGenesisBlock()
|
||||||
|
SetDNSDiscoveryDefaults(cfg, params.MainnetGenesisHash)
|
||||||
case ctx.Bool(HoleskyFlag.Name):
|
case ctx.Bool(HoleskyFlag.Name):
|
||||||
if !ctx.IsSet(NetworkIdFlag.Name) {
|
if !ctx.IsSet(NetworkIdFlag.Name) {
|
||||||
cfg.NetworkId = 17000
|
cfg.NetworkId = 17000
|
||||||
@ -1754,6 +1787,12 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
|||||||
}
|
}
|
||||||
cfg.Genesis = core.DefaultGoerliGenesisBlock()
|
cfg.Genesis = core.DefaultGoerliGenesisBlock()
|
||||||
SetDNSDiscoveryDefaults(cfg, params.GoerliGenesisHash)
|
SetDNSDiscoveryDefaults(cfg, params.GoerliGenesisHash)
|
||||||
|
case ctx.Bool(PulseChainTestnetFlag.Name):
|
||||||
|
if !ctx.IsSet(NetworkIdFlag.Name) {
|
||||||
|
cfg.NetworkId = 942
|
||||||
|
}
|
||||||
|
cfg.Genesis = core.DefaultPulseChainTestnetGenesisBlock()
|
||||||
|
SetDNSDiscoveryDefaults(cfg, params.MainnetGenesisHash)
|
||||||
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
|
||||||
@ -2057,12 +2096,16 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
|
|||||||
switch {
|
switch {
|
||||||
case ctx.Bool(MainnetFlag.Name):
|
case ctx.Bool(MainnetFlag.Name):
|
||||||
genesis = core.DefaultGenesisBlock()
|
genesis = core.DefaultGenesisBlock()
|
||||||
|
case ctx.Bool(PulseChainFlag.Name):
|
||||||
|
genesis = core.DefaultPulseChainGenesisBlock()
|
||||||
case ctx.Bool(HoleskyFlag.Name):
|
case ctx.Bool(HoleskyFlag.Name):
|
||||||
genesis = core.DefaultHoleskyGenesisBlock()
|
genesis = core.DefaultHoleskyGenesisBlock()
|
||||||
case ctx.Bool(SepoliaFlag.Name):
|
case ctx.Bool(SepoliaFlag.Name):
|
||||||
genesis = core.DefaultSepoliaGenesisBlock()
|
genesis = core.DefaultSepoliaGenesisBlock()
|
||||||
case ctx.Bool(GoerliFlag.Name):
|
case ctx.Bool(GoerliFlag.Name):
|
||||||
genesis = core.DefaultGoerliGenesisBlock()
|
genesis = core.DefaultGoerliGenesisBlock()
|
||||||
|
case ctx.Bool(PulseChainTestnetFlag.Name):
|
||||||
|
genesis = core.DefaultPulseChainTestnetGenesisBlock()
|
||||||
case ctx.Bool(DeveloperFlag.Name):
|
case ctx.Bool(DeveloperFlag.Name):
|
||||||
Fatalf("Developer chains are ephemeral")
|
Fatalf("Developer chains are ephemeral")
|
||||||
}
|
}
|
||||||
|
@ -498,6 +498,18 @@ func DefaultGenesisBlock() *Genesis {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DefaultPulseChainGenesisBlock returns the PulseChain mainnet genesis block.
|
||||||
|
func DefaultPulseChainGenesisBlock() *Genesis {
|
||||||
|
return &Genesis{
|
||||||
|
Config: params.PulseChainConfig,
|
||||||
|
Nonce: 66,
|
||||||
|
ExtraData: hexutil.MustDecode("0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa"),
|
||||||
|
GasLimit: 5000,
|
||||||
|
Difficulty: big.NewInt(17179869184),
|
||||||
|
Alloc: decodePrealloc(mainnetAllocData),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// DefaultGoerliGenesisBlock returns the Görli network genesis block.
|
// DefaultGoerliGenesisBlock returns the Görli network genesis block.
|
||||||
func DefaultGoerliGenesisBlock() *Genesis {
|
func DefaultGoerliGenesisBlock() *Genesis {
|
||||||
return &Genesis{
|
return &Genesis{
|
||||||
@ -535,6 +547,18 @@ func DefaultHoleskyGenesisBlock() *Genesis {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DefaultPulseChainTestnetGenesisBlock returns the PulseChain testnet genesis block.
|
||||||
|
func DefaultPulseChainTestnetGenesisBlock() *Genesis {
|
||||||
|
return &Genesis{
|
||||||
|
Config: params.PulseChainTestnetConfig,
|
||||||
|
Nonce: 66,
|
||||||
|
ExtraData: hexutil.MustDecode("0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa"),
|
||||||
|
GasLimit: 5000,
|
||||||
|
Difficulty: big.NewInt(17179869184),
|
||||||
|
Alloc: decodePrealloc(mainnetAllocData),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// DeveloperGenesisBlock returns the 'geth --dev' genesis block.
|
// DeveloperGenesisBlock returns the 'geth --dev' genesis block.
|
||||||
func DeveloperGenesisBlock(gasLimit uint64, faucet *common.Address) *Genesis {
|
func DeveloperGenesisBlock(gasLimit uint64, faucet *common.Address) *Genesis {
|
||||||
// Override the default period to the user requested one
|
// Override the default period to the user requested one
|
||||||
|
@ -36,6 +36,14 @@ var HoleskyBootnodes = []string{
|
|||||||
"enode://a3435a0155a3e837c02f5e7f5662a2f1fbc25b48e4dc232016e1c51b544cb5b4510ef633ea3278c0e970fa8ad8141e2d4d0f9f95456c537ff05fdf9b31c15072@178.128.136.233:30303",
|
"enode://a3435a0155a3e837c02f5e7f5662a2f1fbc25b48e4dc232016e1c51b544cb5b4510ef633ea3278c0e970fa8ad8141e2d4d0f9f95456c537ff05fdf9b31c15072@178.128.136.233:30303",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PulseChainBootnodes are the enode URLs of the P2P bootstrap nodes running on
|
||||||
|
// the main PulseChain network.
|
||||||
|
var PulseChainBootnodes []string // TODO
|
||||||
|
|
||||||
|
// PulseChainTestnetBootnodes are the enode URLs of the P2P bootstrap nodes running on
|
||||||
|
// the main PulseChain network.
|
||||||
|
var PulseChainTestnetBootnodes []string // TODO
|
||||||
|
|
||||||
// SepoliaBootnodes are the enode URLs of the P2P bootstrap nodes running on the
|
// SepoliaBootnodes are the enode URLs of the P2P bootstrap nodes running on the
|
||||||
// Sepolia test network.
|
// Sepolia test network.
|
||||||
var SepoliaBootnodes = []string{
|
var SepoliaBootnodes = []string{
|
||||||
|
Loading…
Reference in New Issue
Block a user