diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 2f7d37fdd..7dc2bd11b 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -278,6 +278,9 @@ func main() { func prepare(ctx *cli.Context) { // If we're running a known preset, log it for convenience. switch { + case ctx.IsSet(utils.PulseChainFlag.Name): + log.Info("Starting Geth on PulseChain mainnet...") + case ctx.IsSet(utils.GoerliFlag.Name): log.Info("Starting Geth on Görli testnet...") @@ -287,6 +290,9 @@ func prepare(ctx *cli.Context) { case ctx.IsSet(utils.HoleskyFlag.Name): 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): log.Info("Starting Geth in ephemeral dev mode...") 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.GoerliFlag.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) ctx.Set(utils.CacheFlag.Name, strconv.Itoa(4096)) } diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index b813e5297..b965e678d 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -140,6 +140,10 @@ var ( Usage: "Ethereum mainnet", Category: flags.EthCategory, } + PulseChainFlag = &cli.BoolFlag{ + Name: "pulsechain", + Usage: "PulseChain mainnet", + } GoerliFlag = &cli.BoolFlag{ Name: "goerli", 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", Category: flags.EthCategory, } + PulseChainTestnetFlag = &cli.BoolFlag{ + Name: "pulsechain-testnet", + Usage: "PulseChain testnet", + } + // Dev mode DeveloperFlag = &cli.BoolFlag{ Name: "dev", @@ -916,9 +925,13 @@ var ( GoerliFlag, SepoliaFlag, HoleskyFlag, + PulseChainTestnetFlag, } // 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 = []cli.Flag{ @@ -936,6 +949,9 @@ var ( // then a subdirectory of the specified datadir will be used. func MakeDataDir(ctx *cli.Context) string { if path := ctx.String(DataDirFlag.Name); path != "" { + if ctx.Bool(PulseChainFlag.Name) { + return filepath.Join(path, "pulsechain") + } if ctx.Bool(GoerliFlag.Name) { return filepath.Join(path, "goerli") } @@ -945,6 +961,9 @@ func MakeDataDir(ctx *cli.Context) string { if ctx.Bool(HoleskyFlag.Name) { return filepath.Join(path, "holesky") } + if ctx.Bool(PulseChainTestnetFlag.Name) { + return filepath.Join(path, "pulsechain-testnet") + } return path } 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. } switch { + case ctx.Bool(PulseChainFlag.Name): + urls = params.PulseChainBootnodes case ctx.Bool(HoleskyFlag.Name): urls = params.HoleskyBootnodes case ctx.Bool(SepoliaFlag.Name): urls = params.SepoliaBootnodes case ctx.Bool(GoerliFlag.Name): urls = params.GoerliBootnodes + case ctx.Bool(PulseChainTestnetFlag.Name): + urls = params.PulseChainTestnetBootnodes } } cfg.BootstrapNodes = mustParseBootnodes(urls) @@ -1428,12 +1451,16 @@ func SetDataDir(ctx *cli.Context, cfg *node.Config) { cfg.DataDir = ctx.String(DataDirFlag.Name) case ctx.Bool(DeveloperFlag.Name): 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(): cfg.DataDir = filepath.Join(node.DefaultDataDir(), "goerli") case ctx.Bool(SepoliaFlag.Name) && cfg.DataDir == node.DefaultDataDir(): cfg.DataDir = filepath.Join(node.DefaultDataDir(), "sepolia") case ctx.Bool(HoleskyFlag.Name) && cfg.DataDir == node.DefaultDataDir(): 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. func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { // 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 // Set configurations from CLI flags @@ -1736,6 +1763,12 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { } cfg.Genesis = core.DefaultGenesisBlock() 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): if !ctx.IsSet(NetworkIdFlag.Name) { cfg.NetworkId = 17000 @@ -1754,6 +1787,12 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { } cfg.Genesis = core.DefaultGoerliGenesisBlock() 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): if !ctx.IsSet(NetworkIdFlag.Name) { cfg.NetworkId = 1337 @@ -2057,12 +2096,16 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis { switch { case ctx.Bool(MainnetFlag.Name): genesis = core.DefaultGenesisBlock() + case ctx.Bool(PulseChainFlag.Name): + genesis = core.DefaultPulseChainGenesisBlock() case ctx.Bool(HoleskyFlag.Name): genesis = core.DefaultHoleskyGenesisBlock() case ctx.Bool(SepoliaFlag.Name): genesis = core.DefaultSepoliaGenesisBlock() case ctx.Bool(GoerliFlag.Name): genesis = core.DefaultGoerliGenesisBlock() + case ctx.Bool(PulseChainTestnetFlag.Name): + genesis = core.DefaultPulseChainTestnetGenesisBlock() case ctx.Bool(DeveloperFlag.Name): Fatalf("Developer chains are ephemeral") } diff --git a/core/genesis.go b/core/genesis.go index 54570ac61..d46471c4f 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -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. func DefaultGoerliGenesisBlock() *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. func DeveloperGenesisBlock(gasLimit uint64, faucet *common.Address) *Genesis { // Override the default period to the user requested one diff --git a/params/bootnodes.go b/params/bootnodes.go index 5e2c7c218..ad86d8078 100644 --- a/params/bootnodes.go +++ b/params/bootnodes.go @@ -36,6 +36,14 @@ var HoleskyBootnodes = []string{ "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 // Sepolia test network. var SepoliaBootnodes = []string{