From e9aca9bd6a050d73aff8ac0e5d4509df11082f1a Mon Sep 17 00:00:00 2001 From: Shane Bammel Date: Mon, 30 Jan 2023 19:09:40 -0600 Subject: [PATCH] Add PulseChain network flags --- cmd/validator/accounts/accounts.go | 10 ++++++ .../slashing-protection.go | 4 +++ cmd/validator/wallet/wallet.go | 4 +++ config/features/config.go | 22 ++++++++++++ config/features/flags.go | 16 +++++++++ config/params/BUILD.bazel | 2 ++ config/params/mainnet_pulsechain_config.go | 13 +++++++ config/params/testnet_pulsechain_config.go | 34 +++++++++++++++++++ config/params/values.go | 24 +++++++------ runtime/version/version.go | 2 +- validator/accounts/accounts_exit.go | 1 + 11 files changed, 120 insertions(+), 12 deletions(-) create mode 100644 config/params/mainnet_pulsechain_config.go create mode 100644 config/params/testnet_pulsechain_config.go diff --git a/cmd/validator/accounts/accounts.go b/cmd/validator/accounts/accounts.go index c88d69154..8e0a0df42 100644 --- a/cmd/validator/accounts/accounts.go +++ b/cmd/validator/accounts/accounts.go @@ -27,7 +27,9 @@ var Commands = &cli.Command{ flags.WalletPasswordFileFlag, flags.DeletePublicKeysFlag, features.Mainnet, + features.PulseChain, features.PraterTestnet, + features.PulseChainTestnet, features.SepoliaTestnet, features.HoleskyTestnet, cmd.AcceptTosFlag, @@ -63,7 +65,9 @@ var Commands = &cli.Command{ flags.GrpcRetriesFlag, flags.GrpcRetryDelayFlag, features.Mainnet, + features.PulseChain, features.PraterTestnet, + features.PulseChainTestnet, features.SepoliaTestnet, features.HoleskyTestnet, cmd.AcceptTosFlag, @@ -97,7 +101,9 @@ var Commands = &cli.Command{ flags.BackupPublicKeysFlag, flags.BackupPasswordFile, features.Mainnet, + features.PulseChain, features.PraterTestnet, + features.PulseChainTestnet, features.SepoliaTestnet, features.HoleskyTestnet, cmd.AcceptTosFlag, @@ -128,7 +134,9 @@ var Commands = &cli.Command{ flags.AccountPasswordFileFlag, flags.ImportPrivateKeyFileFlag, features.Mainnet, + features.PulseChain, features.PraterTestnet, + features.PulseChainTestnet, features.SepoliaTestnet, features.HoleskyTestnet, cmd.AcceptTosFlag, @@ -171,7 +179,9 @@ var Commands = &cli.Command{ flags.ForceExitFlag, flags.VoluntaryExitJSONOutputPath, features.Mainnet, + features.PulseChain, features.PraterTestnet, + features.PulseChainTestnet, features.SepoliaTestnet, features.HoleskyTestnet, cmd.AcceptTosFlag, diff --git a/cmd/validator/slashing-protection/slashing-protection.go b/cmd/validator/slashing-protection/slashing-protection.go index 7ad11868e..7e60e3ede 100644 --- a/cmd/validator/slashing-protection/slashing-protection.go +++ b/cmd/validator/slashing-protection/slashing-protection.go @@ -22,7 +22,9 @@ var Commands = &cli.Command{ cmd.DataDirFlag, flags.SlashingProtectionExportDirFlag, features.Mainnet, + features.PulseChain, features.PraterTestnet, + features.PulseChainTestnet, features.SepoliaTestnet, features.HoleskyTestnet, features.EnableMinimalSlashingProtection, @@ -51,7 +53,9 @@ var Commands = &cli.Command{ cmd.DataDirFlag, flags.SlashingProtectionJSONFileFlag, features.Mainnet, + features.PulseChain, features.PraterTestnet, + features.PulseChainTestnet, features.SepoliaTestnet, features.HoleskyTestnet, features.EnableMinimalSlashingProtection, diff --git a/cmd/validator/wallet/wallet.go b/cmd/validator/wallet/wallet.go index cf2b529fd..6c99824b7 100644 --- a/cmd/validator/wallet/wallet.go +++ b/cmd/validator/wallet/wallet.go @@ -31,7 +31,9 @@ var Commands = &cli.Command{ flags.Mnemonic25thWordFileFlag, flags.SkipMnemonic25thWordCheckFlag, features.Mainnet, + features.PulseChain, features.PraterTestnet, + features.PulseChainTestnet, features.SepoliaTestnet, features.HoleskyTestnet, cmd.AcceptTosFlag, @@ -63,7 +65,9 @@ var Commands = &cli.Command{ flags.Mnemonic25thWordFileFlag, flags.SkipMnemonic25thWordCheckFlag, features.Mainnet, + features.PulseChain, features.PraterTestnet, + features.PulseChainTestnet, features.SepoliaTestnet, features.HoleskyTestnet, cmd.AcceptTosFlag, diff --git a/config/features/config.go b/config/features/config.go index 43f1c3d10..22d323447 100644 --- a/config/features/config.go +++ b/config/features/config.go @@ -130,6 +130,20 @@ func configureTestnet(ctx *cli.Context) error { } applyPraterFeatureFlags(ctx) params.UsePraterNetworkConfig() + } else if ctx.Bool(PulseChain.Name) { + log.Warn("Running on PulseChain Mainnet") + if err := params.SetActive(params.PulseChainConfig().Copy()); err != nil { + return err + } + applyPulseChainFeatureFlags(ctx) + params.UsePulseChainNetworkConfig() + } else if ctx.Bool(PulseChainTestnet.Name) { + log.Warn("Running on PulseChain Testnet") + if err := params.SetActive(params.PulseChainTestnetConfig().Copy()); err != nil { + return err + } + applyPulseChainTestnetFeatureFlags(ctx) + params.UsePulseChainTestnetNetworkConfig() } else if ctx.Bool(SepoliaTestnet.Name) { log.Info("Running on the Sepolia Beacon Chain Testnet") if err := params.SetActive(params.SepoliaConfig().Copy()); err != nil { @@ -161,6 +175,14 @@ func configureTestnet(ctx *cli.Context) error { func applyPraterFeatureFlags(ctx *cli.Context) { } +// Insert feature flags within the function to be enabled for PulseChain mainnet. +func applyPulseChainFeatureFlags(ctx *cli.Context) { +} + +// Insert feature flags within the function to be enabled for PulseChain testnet. +func applyPulseChainTestnetFeatureFlags(ctx *cli.Context) { +} + // Insert feature flags within the function to be enabled for Sepolia testnet. func applySepoliaFeatureFlags(ctx *cli.Context) { } diff --git a/config/features/flags.go b/config/features/flags.go index d64fb49f8..a9a515fef 100644 --- a/config/features/flags.go +++ b/config/features/flags.go @@ -14,6 +14,11 @@ var ( Usage: "Runs Prysm configured for the Prater / Goerli test network.", Aliases: []string{"goerli"}, } + // PulseChainTestnet flag for the multiclient Ethereum consensus testnet. + PulseChainTestnet = &cli.BoolFlag{ + Name: "pulsechain-testnet", + Usage: "Run Prysm configured for the PulseChain beacon chain test network", + } // SepoliaTestnet flag for the multiclient Ethereum consensus testnet. SepoliaTestnet = &cli.BoolFlag{ Name: "sepolia", @@ -30,6 +35,11 @@ var ( Name: "mainnet", Usage: "Runs on Ethereum main network. This is the default and can be omitted.", } + // PulseChain flag for the multiclient Ethereum consensus mainnet. + PulseChain = &cli.BoolFlag{ + Name: "pulsechain", + Usage: "Run Prysm configured for the PulseChain beacon chain mainnnet", + } devModeFlag = &cli.BoolFlag{ Name: "dev", Usage: "Enables experimental features still in development. These features may not be stable.", @@ -184,8 +194,10 @@ var ValidatorFlags = append(deprecatedFlags, []cli.Flag{ writeWalletPasswordOnWebOnboarding, HoleskyTestnet, PraterTestnet, + PulseChainTestnet, SepoliaTestnet, Mainnet, + PulseChain, dynamicKeyReloadDebounceInterval, attestTimely, enableSlashingProtectionPruning, @@ -209,8 +221,10 @@ var BeaconChainFlags = append(deprecatedBeaconFlags, append(deprecatedFlags, []c disableGRPCConnectionLogging, HoleskyTestnet, PraterTestnet, + PulseChainTestnet, SepoliaTestnet, Mainnet, + PulseChain, disablePeerScorer, disableBroadcastSlashingFlag, enableSlasherFlag, @@ -239,7 +253,9 @@ var E2EBeaconChainFlags = []string{ // NetworkFlags contains a list of network flags. var NetworkFlags = []cli.Flag{ Mainnet, + PulseChain, PraterTestnet, + PulseChainTestnet, SepoliaTestnet, HoleskyTestnet, } diff --git a/config/params/BUILD.bazel b/config/params/BUILD.bazel index a9cb1ff30..dae53af4e 100644 --- a/config/params/BUILD.bazel +++ b/config/params/BUILD.bazel @@ -12,11 +12,13 @@ go_library( "io_config.go", "loader.go", "mainnet_config.go", + "mainnet_pulsechain_config.go", "minimal_config.go", "network_config.go", "testnet_e2e_config.go", "testnet_holesky_config.go", "testnet_prater_config.go", + "testnet_pulsechain_config.go", "testnet_sepolia_config.go", "testutils.go", "testutils_develop.go", # keep diff --git a/config/params/mainnet_pulsechain_config.go b/config/params/mainnet_pulsechain_config.go new file mode 100644 index 000000000..b539bbb43 --- /dev/null +++ b/config/params/mainnet_pulsechain_config.go @@ -0,0 +1,13 @@ +package params + +// UsePulseChainNetworkConfig uses the PulseChain beacon chain mainnet network config. +func UsePulseChainNetworkConfig() { + // TODO + UsePulseChainTestnetNetworkConfig() +} + +// PulseChainConfig defines the config for the PulseChain beacon chain mainnet. +func PulseChainConfig() *BeaconChainConfig { + // TODO + return PulseChainTestnetConfig() +} diff --git a/config/params/testnet_pulsechain_config.go b/config/params/testnet_pulsechain_config.go new file mode 100644 index 000000000..4d7485093 --- /dev/null +++ b/config/params/testnet_pulsechain_config.go @@ -0,0 +1,34 @@ +package params + +// UsePulseChainTestnetNetworkConfig uses the PulseChain beacon chain testnet network config. +func UsePulseChainTestnetNetworkConfig() { + cfg := BeaconNetworkConfig().Copy() + cfg.ContractDeploymentBlock = 16492700 + cfg.BootstrapNodes = []string{ + // TODO: Add bootnode ENRs + } + OverrideBeaconNetworkConfig(cfg) +} + +// PulseChainTestnetConfig defines the config for the PulseChain beacon chain testnet. +func PulseChainTestnetConfig() *BeaconChainConfig { + cfg := MainnetConfig().Copy() + cfg.ConfigName = PulseChainTestnetName + cfg.TerminalTotalDifficulty = "58750003716598352947541" + cfg.MinGenesisActiveValidatorCount = 5000 + cfg.MinGenesisTime = 1674864000 + cfg.GenesisForkVersion = []byte{0x00, 0x00, 0x09, 0x42} + cfg.GenesisDelay = 300 + cfg.AltairForkVersion = []byte{0x00, 0x00, 0x09, 0x43} + cfg.AltairForkEpoch = 1 + cfg.BellatrixForkVersion = []byte{0x00, 0x00, 0x09, 0x44} + cfg.BellatrixForkEpoch = 2 + cfg.SecondsPerSlot = 10 + cfg.MaxEffectiveBalance = 32 * 1e15 + cfg.EjectionBalance = 16 * 1e15 + cfg.DepositChainID = 942 + cfg.DepositNetworkID = 942 + cfg.DepositContractAddress = "0x3693693693693693693693693693693693693693" + cfg.InitializeForkSchedule() + return cfg +} diff --git a/config/params/values.go b/config/params/values.go index 34dccb721..202f068d7 100644 --- a/config/params/values.go +++ b/config/params/values.go @@ -1,15 +1,17 @@ package params const ( - DevnetName = "devnet" - EndToEndName = "end-to-end" - EndToEndMainnetName = "end-to-end-mainnet" - InteropName = "interop" - MainnetName = "mainnet" - MainnetTestName = "mainnet-test" - MinimalName = "minimal" - PraterName = "prater" - GoerliName = "goerli" - SepoliaName = "sepolia" - HoleskyName = "holesky" + DevnetName = "devnet" + EndToEndName = "end-to-end" + EndToEndMainnetName = "end-to-end-mainnet" + InteropName = "interop" + MainnetName = "mainnet" + PulseChainName = "pulsechain-mainnet" + MainnetTestName = "mainnet-test" + MinimalName = "minimal" + PraterName = "prater" + GoerliName = "goerli" + SepoliaName = "sepolia" + HoleskyName = "holesky" + PulseChainTestnetName = "pulsechain-testnet-v3" ) diff --git a/runtime/version/version.go b/runtime/version/version.go index a7ba86974..644731ea6 100644 --- a/runtime/version/version.go +++ b/runtime/version/version.go @@ -45,5 +45,5 @@ func BuildData() string { gitCommit = strings.TrimRight(string(commit), "\r\n") } } - return fmt.Sprintf("Prysm/%s/%s", gitTag, gitCommit) + return fmt.Sprintf("Prysm-Pulse/%s/%s", gitTag, gitCommit) } diff --git a/validator/accounts/accounts_exit.go b/validator/accounts/accounts_exit.go index 8499b4016..a3b0a162e 100644 --- a/validator/accounts/accounts_exit.go +++ b/validator/accounts/accounts_exit.go @@ -171,6 +171,7 @@ func displayExitInfo(rawExitedKeys [][]byte, trimmedExitedKeys []string) { } func formatBeaconChaURL(key []byte) string { + // TODO: Add URLs for PulseChain explorer. baseURL := "https://%sbeaconcha.in/validator/%s" keyWithout0x := hexutil.Encode(key)[2:]