Skip to content

Commit

Permalink
Organize validator flags (#14028)
Browse files Browse the repository at this point in the history
* Organize validator flags

* whitespace

* fix comment in test

* remove unneeded flags
  • Loading branch information
rkapka authored May 31, 2024
1 parent 968e82b commit b08e691
Show file tree
Hide file tree
Showing 16 changed files with 109 additions and 98 deletions.
8 changes: 4 additions & 4 deletions cmd/prysmctl/validator/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ var Commands = []*cli.Command{
flags.InteropStartIndex,
cmd.GrpcMaxCallRecvMsgSizeFlag,
flags.CertFlag,
flags.GrpcHeadersFlag,
flags.GrpcRetriesFlag,
flags.GrpcRetryDelayFlag,
flags.GRPCHeadersFlag,
flags.GRPCRetriesFlag,
flags.GRPCRetryDelayFlag,
flags.ExitAllFlag,
flags.ForceExitFlag,
flags.VoluntaryExitJSONOutputPath,
flags.VoluntaryExitJSONOutputPathFlag,
features.Mainnet,
features.SepoliaTestnet,
features.HoleskyTestnet,
Expand Down
16 changes: 8 additions & 8 deletions cmd/validator/accounts/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ var Commands = &cli.Command{
flags.BeaconRPCProviderFlag,
cmd.GrpcMaxCallRecvMsgSizeFlag,
flags.CertFlag,
flags.GrpcHeadersFlag,
flags.GrpcRetriesFlag,
flags.GrpcRetryDelayFlag,
flags.GRPCHeadersFlag,
flags.GRPCRetriesFlag,
flags.GRPCRetryDelayFlag,
features.Mainnet,
features.SepoliaTestnet,
features.HoleskyTestnet,
Expand Down Expand Up @@ -93,7 +93,7 @@ var Commands = &cli.Command{
flags.WalletPasswordFileFlag,
flags.BackupDirFlag,
flags.BackupPublicKeysFlag,
flags.BackupPasswordFile,
flags.BackupPasswordFileFlag,
features.Mainnet,
features.SepoliaTestnet,
features.HoleskyTestnet,
Expand Down Expand Up @@ -160,12 +160,12 @@ var Commands = &cli.Command{
flags.InteropStartIndex,
cmd.GrpcMaxCallRecvMsgSizeFlag,
flags.CertFlag,
flags.GrpcHeadersFlag,
flags.GrpcRetriesFlag,
flags.GrpcRetryDelayFlag,
flags.GRPCHeadersFlag,
flags.GRPCRetriesFlag,
flags.GRPCRetryDelayFlag,
flags.ExitAllFlag,
flags.ForceExitFlag,
flags.VoluntaryExitJSONOutputPath,
flags.VoluntaryExitJSONOutputPathFlag,
features.Mainnet,
features.SepoliaTestnet,
features.HoleskyTestnet,
Expand Down
8 changes: 4 additions & 4 deletions cmd/validator/accounts/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ func accountsBackup(c *cli.Context) error {
dialOpts := client.ConstructDialOptions(
c.Int(cmd.GrpcMaxCallRecvMsgSizeFlag.Name),
c.String(flags.CertFlag.Name),
c.Uint(flags.GrpcRetriesFlag.Name),
c.Duration(flags.GrpcRetryDelayFlag.Name),
c.Uint(flags.GRPCRetriesFlag.Name),
c.Duration(flags.GRPCRetryDelayFlag.Name),
)
grpcHeaders := strings.Split(c.String(flags.GrpcHeadersFlag.Name), ",")
grpcHeaders := strings.Split(c.String(flags.GRPCHeadersFlag.Name), ",")

opts := []accounts.Option{
accounts.WithWallet(w),
Expand Down Expand Up @@ -62,7 +62,7 @@ func accountsBackup(c *cli.Context) error {
// Ask the user for their desired password for their backed up accounts.
backupsPassword, err := prompt.InputPassword(
c,
flags.BackupPasswordFile,
flags.BackupPasswordFileFlag,
"Enter a new password for your backed up accounts",
"Confirm new password",
true,
Expand Down
6 changes: 3 additions & 3 deletions cmd/validator/accounts/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ func accountsDelete(c *cli.Context) error {
dialOpts := client.ConstructDialOptions(
c.Int(cmd.GrpcMaxCallRecvMsgSizeFlag.Name),
c.String(flags.CertFlag.Name),
c.Uint(flags.GrpcRetriesFlag.Name),
c.Duration(flags.GrpcRetryDelayFlag.Name),
c.Uint(flags.GRPCRetriesFlag.Name),
c.Duration(flags.GRPCRetryDelayFlag.Name),
)
grpcHeaders := strings.Split(c.String(flags.GrpcHeadersFlag.Name), ",")
grpcHeaders := strings.Split(c.String(flags.GRPCHeadersFlag.Name), ",")

opts := []accounts.Option{
accounts.WithWallet(w),
Expand Down
8 changes: 4 additions & 4 deletions cmd/validator/accounts/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ func setupWalletCtx(
set.String(flags.DeletePublicKeysFlag.Name, cfg.deletePublicKeys, "")
set.String(flags.VoluntaryExitPublicKeysFlag.Name, cfg.voluntaryExitPublicKeys, "")
set.String(flags.BackupDirFlag.Name, cfg.backupDir, "")
set.String(flags.BackupPasswordFile.Name, cfg.backupPasswordFile, "")
set.String(flags.BackupPasswordFileFlag.Name, cfg.backupPasswordFile, "")
set.String(flags.BackupPublicKeysFlag.Name, cfg.backupPublicKeys, "")
set.String(flags.WalletPasswordFileFlag.Name, cfg.walletPasswordFile, "")
set.String(flags.AccountPasswordFileFlag.Name, cfg.accountPasswordFile, "")
set.Int64(flags.NumAccountsFlag.Name, cfg.numAccounts, "")
set.Bool(flags.SkipDepositConfirmationFlag.Name, cfg.skipDepositConfirm, "")
set.Bool(flags.SkipMnemonic25thWordCheckFlag.Name, true, "")
set.Bool(flags.ExitAllFlag.Name, cfg.exitAll, "")
set.String(flags.GrpcHeadersFlag.Name, cfg.grpcHeaders, "")
set.String(flags.GRPCHeadersFlag.Name, cfg.grpcHeaders, "")

if cfg.privateKeyFile != "" {
set.String(flags.ImportPrivateKeyFileFlag.Name, cfg.privateKeyFile, "")
Expand All @@ -120,13 +120,13 @@ func setupWalletCtx(
assert.NoError(tb, set.Set(flags.VoluntaryExitPublicKeysFlag.Name, cfg.voluntaryExitPublicKeys))
assert.NoError(tb, set.Set(flags.BackupDirFlag.Name, cfg.backupDir))
assert.NoError(tb, set.Set(flags.BackupPublicKeysFlag.Name, cfg.backupPublicKeys))
assert.NoError(tb, set.Set(flags.BackupPasswordFile.Name, cfg.backupPasswordFile))
assert.NoError(tb, set.Set(flags.BackupPasswordFileFlag.Name, cfg.backupPasswordFile))
assert.NoError(tb, set.Set(flags.WalletPasswordFileFlag.Name, cfg.walletPasswordFile))
assert.NoError(tb, set.Set(flags.AccountPasswordFileFlag.Name, cfg.accountPasswordFile))
assert.NoError(tb, set.Set(flags.NumAccountsFlag.Name, strconv.Itoa(int(cfg.numAccounts))))
assert.NoError(tb, set.Set(flags.SkipDepositConfirmationFlag.Name, strconv.FormatBool(cfg.skipDepositConfirm)))
assert.NoError(tb, set.Set(flags.ExitAllFlag.Name, strconv.FormatBool(cfg.exitAll)))
assert.NoError(tb, set.Set(flags.GrpcHeadersFlag.Name, cfg.grpcHeaders))
assert.NoError(tb, set.Set(flags.GRPCHeadersFlag.Name, cfg.grpcHeaders))
return cli.NewContext(&app, set, nil)
}

Expand Down
8 changes: 4 additions & 4 deletions cmd/validator/accounts/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ func Exit(c *cli.Context, r io.Reader) error {
dialOpts := client.ConstructDialOptions(
c.Int(cmd.GrpcMaxCallRecvMsgSizeFlag.Name),
c.String(flags.CertFlag.Name),
c.Uint(flags.GrpcRetriesFlag.Name),
c.Duration(flags.GrpcRetryDelayFlag.Name),
c.Uint(flags.GRPCRetriesFlag.Name),
c.Duration(flags.GRPCRetryDelayFlag.Name),
)
grpcHeaders := strings.Split(c.String(flags.GrpcHeadersFlag.Name), ",")
grpcHeaders := strings.Split(c.String(flags.GRPCHeadersFlag.Name), ",")
beaconRPCProvider := c.String(flags.BeaconRPCProviderFlag.Name)
if !c.IsSet(flags.Web3SignerURLFlag.Name) && !c.IsSet(flags.WalletDirFlag.Name) && !c.IsSet(flags.InteropNumValidators.Name) {
return errors.Errorf("No validators found, please provide a prysm wallet directory via flag --%s "+
Expand Down Expand Up @@ -83,7 +83,7 @@ func Exit(c *cli.Context, r io.Reader) error {
accounts.WithBeaconRPCProvider(beaconRPCProvider),
accounts.WithBeaconRESTApiProvider(c.String(flags.BeaconRESTApiProviderFlag.Name)),
accounts.WithGRPCHeaders(grpcHeaders),
accounts.WithExitJSONOutputPath(c.String(flags.VoluntaryExitJSONOutputPath.Name)),
accounts.WithExitJSONOutputPath(c.String(flags.VoluntaryExitJSONOutputPathFlag.Name)),
}
// Get full set of public keys from the keymanager.
validatingPublicKeys, err := km.FetchValidatingPublicKeys(c.Context)
Expand Down
6 changes: 3 additions & 3 deletions cmd/validator/accounts/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ func accountsImport(c *cli.Context) error {
dialOpts := client.ConstructDialOptions(
c.Int(cmd.GrpcMaxCallRecvMsgSizeFlag.Name),
c.String(flags.CertFlag.Name),
c.Uint(flags.GrpcRetriesFlag.Name),
c.Duration(flags.GrpcRetryDelayFlag.Name),
c.Uint(flags.GRPCRetriesFlag.Name),
c.Duration(flags.GRPCRetryDelayFlag.Name),
)
grpcHeaders := strings.Split(c.String(flags.GrpcHeadersFlag.Name), ",")
grpcHeaders := strings.Split(c.String(flags.GRPCHeadersFlag.Name), ",")

opts := []accounts.Option{
accounts.WithWallet(w),
Expand Down
6 changes: 3 additions & 3 deletions cmd/validator/accounts/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ func accountsList(c *cli.Context) error {
dialOpts := client.ConstructDialOptions(
c.Int(cmd.GrpcMaxCallRecvMsgSizeFlag.Name),
c.String(flags.CertFlag.Name),
c.Uint(flags.GrpcRetriesFlag.Name),
c.Duration(flags.GrpcRetryDelayFlag.Name),
c.Uint(flags.GRPCRetriesFlag.Name),
c.Duration(flags.GRPCRetryDelayFlag.Name),
)
grpcHeaders := strings.Split(c.String(flags.GrpcHeadersFlag.Name), ",")
grpcHeaders := strings.Split(c.String(flags.GRPCHeadersFlag.Name), ",")

opts := []accounts.Option{
accounts.WithWallet(w),
Expand Down
33 changes: 12 additions & 21 deletions cmd/validator/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,20 @@ var (
Name: "graffiti",
Usage: "String to include in proposed blocks.",
}
// GrpcRetriesFlag defines the number of times to retry a failed gRPC request.
GrpcRetriesFlag = &cli.UintFlag{
// GRPCRetriesFlag defines the number of times to retry a failed gRPC request.
GRPCRetriesFlag = &cli.UintFlag{
Name: "grpc-retries",
Usage: "Number of attempts to retry gRPC requests.",
Value: 5,
}
// GrpcRetryDelayFlag defines the interval to retry a failed gRPC request.
GrpcRetryDelayFlag = &cli.DurationFlag{
// GRPCRetryDelayFlag defines the interval to retry a failed gRPC request.
GRPCRetryDelayFlag = &cli.DurationFlag{
Name: "grpc-retry-delay",
Usage: "Amount of time between gRPC retry requests.",
Value: 1 * time.Second,
}
// GrpcHeadersFlag defines a list of headers to send with all gRPC requests.
GrpcHeadersFlag = &cli.StringFlag{
// GRPCHeadersFlag defines a list of headers to send with all gRPC requests.
GRPCHeadersFlag = &cli.StringFlag{
Name: "grpc-headers",
Usage: `Comma separated list of key value pairs to pass as gRPC headers for all gRPC calls.
Example: --grpc-headers=key=value`,
Expand All @@ -121,8 +121,8 @@ var (
Usage: "Enables gRPC gateway for JSON requests.",
Value: 7500,
}
// GPRCGatewayCorsDomain serves preflight requests when serving gRPC JSON gateway.
GPRCGatewayCorsDomain = &cli.StringFlag{
// GRPCGatewayCorsDomain serves preflight requests when serving gRPC JSON gateway.
GRPCGatewayCorsDomain = &cli.StringFlag{
Name: "grpc-gateway-corsdomain",
Usage: `Comma separated list of domains from which to accept cross origin requests (browser enforced).
This flag has no effect if not used with --grpc-gateway-port.
Expand All @@ -142,7 +142,6 @@ var (
Value: filepath.Join(filepath.Join(DefaultValidatorDir(), WalletDefaultDirName), api.AuthTokenFileName),
Aliases: []string{"validator-api-bearer-file"},
}

// WalletDirFlag defines the path to a wallet directory for Prysm accounts.
WalletDirFlag = &cli.StringFlag{
Name: "wallet-dir",
Expand Down Expand Up @@ -184,7 +183,6 @@ var (
Name: "mnemonic-language",
Usage: "Allows specifying mnemonic language. Supported languages are: english|chinese_traditional|chinese_simplified|czech|french|japanese|korean|italian|spanish.",
}

// ShowPrivateKeysFlag for accounts.
ShowPrivateKeysFlag = &cli.BoolFlag{
Name: "show-private-keys",
Expand Down Expand Up @@ -236,14 +234,15 @@ var (
Name: "force-exit",
Usage: "Exits without displaying the confirmation prompt.",
}
VoluntaryExitJSONOutputPath = &cli.StringFlag{
// VoluntaryExitJSONOutputPathFlag to write voluntary exits as JSON files instead of broadcasting them.
VoluntaryExitJSONOutputPathFlag = &cli.StringFlag{
Name: "exit-json-output-dir",
Usage: "Output directory to write voluntary exits as individual unencrypted JSON " +
"files. If this flag is provided, voluntary exits will be written to the provided " +
"directory and will not be broadcasted.",
}
// BackupPasswordFile for encrypting accounts a user wishes to back up.
BackupPasswordFile = &cli.StringFlag{
// BackupPasswordFileFlag for encrypting accounts a user wishes to back up.
BackupPasswordFileFlag = &cli.StringFlag{
Name: "backup-password-file",
Usage: "Path to a plain-text, .txt file containing the desired password for your backed up accounts.",
Value: "",
Expand All @@ -264,7 +263,6 @@ var (
Name: "keys-dir",
Usage: "Path to a directory where keystores to be imported are stored.",
}

// RemoteSignerCertPathFlag defines the path to a client.crt file for a wallet to connect to
// a secure signer via TLS and gRPC.
RemoteSignerCertPathFlag = &cli.StringFlag{
Expand Down Expand Up @@ -294,7 +292,6 @@ var (
Usage: "URL for consensys' web3signer software to use with the Prysm validator client.",
Value: "",
}

// Web3SignerPublicValidatorKeysFlag defines a comma-separated list of hex string public keys or external url for web3signer to use for validator signing.
// example with external url: --validators-external-signer-public-keys= https://web3signer.com/api/v1/eth2/publicKeys
// example with public key: --validators-external-signer-public-keys=0xa99a...e44c,0xb89b...4a0b
Expand All @@ -303,7 +300,6 @@ var (
Name: "validators-external-signer-public-keys",
Usage: "Comma separated list of public keys OR an external url endpoint for the validator to retrieve public keys from for usage with web3signer.",
}

// KeymanagerKindFlag defines the kind of keymanager desired by a user during wallet creation.
KeymanagerKindFlag = &cli.StringFlag{
Name: "keymanager-kind",
Expand Down Expand Up @@ -348,7 +344,6 @@ var (
fee recipient and gas limit. File format found in docs`,
Value: "",
}

// SuggestedFeeRecipientFlag defines the address of the fee recipient.
SuggestedFeeRecipientFlag = &cli.StringFlag{
Name: "suggested-fee-recipient",
Expand All @@ -358,7 +353,6 @@ var (
--` + ProposerSettingsFlag.Name + " or --" + ProposerSettingsURLFlag.Name + " flags.",
Value: params.BeaconConfig().EthBurnAddressHex,
}

// EnableBuilderFlag enables the periodic validator registration API calls that will update the custom builder with validator settings.
EnableBuilderFlag = &cli.BoolFlag{
Name: "enable-builder",
Expand All @@ -368,21 +362,18 @@ var (
Value: false,
Aliases: []string{"enable-validator-registration"},
}

// BuilderGasLimitFlag defines the gas limit for the builder to use for constructing a payload.
BuilderGasLimitFlag = &cli.StringFlag{
Name: "suggested-gas-limit",
Usage: "Sets gas limit for the builder to use for constructing a payload for all the validators.",
Value: fmt.Sprint(params.BeaconConfig().DefaultBuilderGasLimit),
}

// ValidatorsRegistrationBatchSizeFlag sets the maximum size for one batch of validator registrations. Use a non-positive value to disable batching.
ValidatorsRegistrationBatchSizeFlag = &cli.IntFlag{
Name: "validators-registration-batch-size",
Usage: "Sets the maximum size for one batch of validator registrations. Use a non-positive value to disable batching.",
Value: 0,
}

// EnableDistributed enables the usage of prysm validator client in a Distributed Validator Cluster.
EnableDistributed = &cli.BoolFlag{
Name: "distributed",
Expand Down
8 changes: 4 additions & 4 deletions cmd/validator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ var appFlags = []cli.Flag{
flags.RPCPort,
flags.GRPCGatewayPort,
flags.GRPCGatewayHost,
flags.GrpcRetriesFlag,
flags.GrpcRetryDelayFlag,
flags.GrpcHeadersFlag,
flags.GPRCGatewayCorsDomain,
flags.GRPCRetriesFlag,
flags.GRPCRetryDelayFlag,
flags.GRPCHeadersFlag,
flags.GRPCGatewayCorsDomain,
flags.DisableAccountMetricsFlag,
flags.MonitoringPortFlag,
flags.SlasherRPCProviderFlag,
Expand Down
Loading

0 comments on commit b08e691

Please sign in to comment.