github.com/prysmaticlabs/prysm@v1.4.4/cmd/validator/flags/flags.go (about)

     1  // Package flags contains all configuration runtime flags for
     2  // the validator service.
     3  package flags
     4  
     5  import (
     6  	"path/filepath"
     7  	"runtime"
     8  	"time"
     9  
    10  	"github.com/prysmaticlabs/prysm/shared/fileutil"
    11  	"github.com/urfave/cli/v2"
    12  )
    13  
    14  const (
    15  	// WalletDefaultDirName for accounts.
    16  	WalletDefaultDirName = "prysm-wallet-v2"
    17  	// DefaultGatewayHost for the validator client.
    18  	DefaultGatewayHost = "127.0.0.1"
    19  )
    20  
    21  var (
    22  	// DisableAccountMetricsFlag disables the prometheus metrics for validator accounts, default false.
    23  	DisableAccountMetricsFlag = &cli.BoolFlag{
    24  		Name: "disable-account-metrics",
    25  		Usage: "Disable prometheus metrics for validator accounts. Operators with high volumes " +
    26  			"of validating keys may wish to disable granular prometheus metrics as it increases " +
    27  			"the data cardinality.",
    28  	}
    29  	// BeaconRPCProviderFlag defines a beacon node RPC endpoint.
    30  	BeaconRPCProviderFlag = &cli.StringFlag{
    31  		Name:  "beacon-rpc-provider",
    32  		Usage: "Beacon node RPC provider endpoint",
    33  		Value: "127.0.0.1:4000",
    34  	}
    35  	// BeaconRPCGatewayProviderFlag defines a beacon node JSON-RPC endpoint.
    36  	BeaconRPCGatewayProviderFlag = &cli.StringFlag{
    37  		Name:  "beacon-rpc-gateway-provider",
    38  		Usage: "Beacon node RPC gateway provider endpoint",
    39  		Value: "127.0.0.1:3500",
    40  	}
    41  	// CertFlag defines a flag for the node's TLS certificate.
    42  	CertFlag = &cli.StringFlag{
    43  		Name:  "tls-cert",
    44  		Usage: "Certificate for secure gRPC. Pass this and the tls-key flag in order to use gRPC securely.",
    45  	}
    46  	// EnableRPCFlag enables controlling the validator client via gRPC (without web UI).
    47  	EnableRPCFlag = &cli.BoolFlag{
    48  		Name:  "rpc",
    49  		Usage: "Enables the RPC server for the validator client (without Web UI)",
    50  		Value: false,
    51  	}
    52  	// RPCHost defines the host on which the RPC server should listen.
    53  	RPCHost = &cli.StringFlag{
    54  		Name:  "rpc-host",
    55  		Usage: "Host on which the RPC server should listen",
    56  		Value: "127.0.0.1",
    57  	}
    58  	// RPCPort defines a validator client RPC port to open.
    59  	RPCPort = &cli.IntFlag{
    60  		Name:  "rpc-port",
    61  		Usage: "RPC port exposed by a validator client",
    62  		Value: 7000,
    63  	}
    64  	// SlasherRPCProviderFlag defines a slasher node RPC endpoint.
    65  	SlasherRPCProviderFlag = &cli.StringFlag{
    66  		Name:  "slasher-rpc-provider",
    67  		Usage: "Slasher node RPC provider endpoint",
    68  		Value: "127.0.0.1:4002",
    69  	}
    70  	// SlasherCertFlag defines a flag for the slasher node's TLS certificate.
    71  	SlasherCertFlag = &cli.StringFlag{
    72  		Name:  "slasher-tls-cert",
    73  		Usage: "Certificate for secure slasher gRPC. Pass this and the tls-key flag in order to use gRPC securely.",
    74  	}
    75  	// DisablePenaltyRewardLogFlag defines the ability to not log reward/penalty information during deployment
    76  	DisablePenaltyRewardLogFlag = &cli.BoolFlag{
    77  		Name:  "disable-rewards-penalties-logging",
    78  		Usage: "Disable reward/penalty logging during cluster deployment",
    79  	}
    80  	// GraffitiFlag defines the graffiti value included in proposed blocks
    81  	GraffitiFlag = &cli.StringFlag{
    82  		Name:  "graffiti",
    83  		Usage: "String to include in proposed blocks",
    84  	}
    85  	// GrpcRetriesFlag defines the number of times to retry a failed gRPC request.
    86  	GrpcRetriesFlag = &cli.UintFlag{
    87  		Name:  "grpc-retries",
    88  		Usage: "Number of attempts to retry gRPC requests",
    89  		Value: 5,
    90  	}
    91  	// GrpcRetryDelayFlag defines the interval to retry a failed gRPC request.
    92  	GrpcRetryDelayFlag = &cli.DurationFlag{
    93  		Name:  "grpc-retry-delay",
    94  		Usage: "The amount of time between gRPC retry requests.",
    95  		Value: 1 * time.Second,
    96  	}
    97  	// GrpcHeadersFlag defines a list of headers to send with all gRPC requests.
    98  	GrpcHeadersFlag = &cli.StringFlag{
    99  		Name: "grpc-headers",
   100  		Usage: "A comma separated list of key value pairs to pass as gRPC headers for all gRPC " +
   101  			"calls. Example: --grpc-headers=key=value",
   102  	}
   103  	// GRPCGatewayHost specifies a gRPC gateway host for the validator client.
   104  	GRPCGatewayHost = &cli.StringFlag{
   105  		Name:  "grpc-gateway-host",
   106  		Usage: "The host on which the gateway server runs on",
   107  		Value: DefaultGatewayHost,
   108  	}
   109  	// GRPCGatewayPort enables a gRPC gateway to be exposed for the validator client.
   110  	GRPCGatewayPort = &cli.IntFlag{
   111  		Name:  "grpc-gateway-port",
   112  		Usage: "Enable gRPC gateway for JSON requests",
   113  		Value: 7500,
   114  	}
   115  	// GPRCGatewayCorsDomain serves preflight requests when serving gRPC JSON gateway.
   116  	GPRCGatewayCorsDomain = &cli.StringFlag{
   117  		Name: "grpc-gateway-corsdomain",
   118  		Usage: "Comma separated list of domains from which to accept cross origin requests " +
   119  			"(browser enforced). This flag has no effect if not used with --grpc-gateway-port.",
   120  		Value: "http://localhost:4242,http://127.0.0.1:4242,http://localhost:4200,http://0.0.0.0:4242,http://0.0.0.0:4200"}
   121  	// MonitoringPortFlag defines the http port used to serve prometheus metrics.
   122  	MonitoringPortFlag = &cli.IntFlag{
   123  		Name:  "monitoring-port",
   124  		Usage: "Port used to listening and respond metrics for prometheus.",
   125  		Value: 8081,
   126  	}
   127  	// WalletDirFlag defines the path to a wallet directory for Prysm accounts.
   128  	WalletDirFlag = &cli.StringFlag{
   129  		Name:  "wallet-dir",
   130  		Usage: "Path to a wallet directory on-disk for Prysm validator accounts",
   131  		Value: filepath.Join(DefaultValidatorDir(), WalletDefaultDirName),
   132  	}
   133  	// AccountPasswordFileFlag is path to a file containing a password for a validator account.
   134  	AccountPasswordFileFlag = &cli.StringFlag{
   135  		Name:  "account-password-file",
   136  		Usage: "Path to a plain-text, .txt file containing a password for a validator account",
   137  	}
   138  	// WalletPasswordFileFlag is the path to a file containing your wallet password.
   139  	WalletPasswordFileFlag = &cli.StringFlag{
   140  		Name:  "wallet-password-file",
   141  		Usage: "Path to a plain-text, .txt file containing your wallet password",
   142  	}
   143  	// Mnemonic25thWordFileFlag defines a path to a file containing a "25th" word mnemonic passphrase for advanced users.
   144  	Mnemonic25thWordFileFlag = &cli.StringFlag{
   145  		Name:  "mnemonic-25th-word-file",
   146  		Usage: "(Advanced) Path to a plain-text, .txt file containing a 25th word passphrase for your mnemonic for HD wallets",
   147  	}
   148  	// SkipMnemonic25thWordCheckFlag allows for skipping a check for mnemonic 25th word passphrases for HD wallets.
   149  	SkipMnemonic25thWordCheckFlag = &cli.StringFlag{
   150  		Name:  "skip-mnemonic-25th-word-check",
   151  		Usage: "Allows for skipping the check for a mnemonic 25th word passphrase for HD wallets",
   152  	}
   153  	// ImportPrivateKeyFileFlag allows for directly importing a private key hex string as an account.
   154  	ImportPrivateKeyFileFlag = &cli.StringFlag{
   155  		Name:  "import-private-key-file",
   156  		Usage: "Path to a plain-text, .txt file containing a hex string representation of a private key to import",
   157  	}
   158  	// MnemonicFileFlag is used to enter a file to mnemonic phrase for new wallet creation, non-interactively.
   159  	MnemonicFileFlag = &cli.StringFlag{
   160  		Name:  "mnemonic-file",
   161  		Usage: "File to retrieve mnemonic for non-interactively passing a mnemonic phrase into wallet recover.",
   162  	}
   163  	// ShowDepositDataFlag for accounts.
   164  	ShowDepositDataFlag = &cli.BoolFlag{
   165  		Name:  "show-deposit-data",
   166  		Usage: "Display raw eth1 tx deposit data for validator accounts",
   167  		Value: false,
   168  	}
   169  	// ShowPrivateKeysFlag for accounts.
   170  	ShowPrivateKeysFlag = &cli.BoolFlag{
   171  		Name:  "show-private-keys",
   172  		Usage: "Display the private keys for validator accounts",
   173  		Value: false,
   174  	}
   175  	// ListValidatorIndices for accounts.
   176  	ListValidatorIndices = &cli.BoolFlag{
   177  		Name:  "list-validator-indices",
   178  		Usage: "List validator indices",
   179  		Value: false,
   180  	}
   181  	// NumAccountsFlag defines the amount of accounts to generate for derived wallets.
   182  	NumAccountsFlag = &cli.IntFlag{
   183  		Name:  "num-accounts",
   184  		Usage: "Number of accounts to generate for derived wallets",
   185  		Value: 1,
   186  	}
   187  	// DeletePublicKeysFlag defines a comma-separated list of hex string public keys
   188  	// for accounts which a user desires to delete from their wallet.
   189  	DeletePublicKeysFlag = &cli.StringFlag{
   190  		Name:  "delete-public-keys",
   191  		Usage: "Comma-separated list of public key hex strings to specify which validator accounts to delete",
   192  		Value: "",
   193  	}
   194  	// BackupPublicKeysFlag defines a comma-separated list of hex string public keys
   195  	// for accounts which a user desires to backup from their wallet.
   196  	BackupPublicKeysFlag = &cli.StringFlag{
   197  		Name:  "backup-public-keys",
   198  		Usage: "Comma-separated list of public key hex strings to specify which validator accounts to backup",
   199  		Value: "",
   200  	}
   201  	// VoluntaryExitPublicKeysFlag defines a comma-separated list of hex string public keys
   202  	// for accounts on which a user wants to perform a voluntary exit.
   203  	VoluntaryExitPublicKeysFlag = &cli.StringFlag{
   204  		Name: "public-keys",
   205  		Usage: "Comma-separated list of public key hex strings to specify on which validator accounts to perform " +
   206  			"a voluntary exit",
   207  		Value: "",
   208  	}
   209  	// ExitAllFlag allows stakers to select all validating keys for exit. This will still require the staker
   210  	// to confirm a prompt for this action given it is a dangerous one.
   211  	ExitAllFlag = &cli.BoolFlag{
   212  		Name:  "exit-all",
   213  		Usage: "Exit all validators. This will still require the staker to confirm a prompt for the action",
   214  	}
   215  	// BackupPasswordFile for encrypting accounts a user wishes to back up.
   216  	BackupPasswordFile = &cli.StringFlag{
   217  		Name:  "backup-password-file",
   218  		Usage: "Path to a plain-text, .txt file containing the desired password for your backed up accounts",
   219  		Value: "",
   220  	}
   221  	// BackupDirFlag defines the path for the zip backup of the wallet will be created.
   222  	BackupDirFlag = &cli.StringFlag{
   223  		Name:  "backup-dir",
   224  		Usage: "Path to a directory where accounts will be backed up into a zip file",
   225  		Value: DefaultValidatorDir(),
   226  	}
   227  	// SlashingProtectionJSONFileFlag is used to enter the file path of the slashing protection JSON.
   228  	SlashingProtectionJSONFileFlag = &cli.StringFlag{
   229  		Name:  "slashing-protection-json-file",
   230  		Usage: "Path to an EIP-3076 compliant JSON file containing a user's slashing protection history",
   231  	}
   232  	// KeysDirFlag defines the path for a directory where keystores to be imported at stored.
   233  	KeysDirFlag = &cli.StringFlag{
   234  		Name:  "keys-dir",
   235  		Usage: "Path to a directory where keystores to be imported are stored",
   236  	}
   237  	// GrpcRemoteAddressFlag defines the host:port address for a remote keymanager to connect to.
   238  	GrpcRemoteAddressFlag = &cli.StringFlag{
   239  		Name:  "grpc-remote-address",
   240  		Usage: "Host:port of a gRPC server for a remote keymanager",
   241  		Value: "",
   242  	}
   243  	// DisableRemoteSignerTlsFlag disables TLS when connecting to a remote signer.
   244  	DisableRemoteSignerTlsFlag = &cli.BoolFlag{
   245  		Name:  "disable-remote-signer-tls",
   246  		Usage: "Disables TLS when connecting to a remote signer. (WARNING! This will result in insecure requests!)",
   247  		Value: false,
   248  	}
   249  	// RemoteSignerCertPathFlag defines the path to a client.crt file for a wallet to connect to
   250  	// a secure signer via TLS and gRPC.
   251  	RemoteSignerCertPathFlag = &cli.StringFlag{
   252  		Name:  "remote-signer-crt-path",
   253  		Usage: "/path/to/client.crt for establishing a secure, TLS gRPC connection to a remote signer server",
   254  		Value: "",
   255  	}
   256  	// RemoteSignerKeyPathFlag defines the path to a client.key file for a wallet to connect to
   257  	// a secure signer via TLS and gRPC.
   258  	RemoteSignerKeyPathFlag = &cli.StringFlag{
   259  		Name:  "remote-signer-key-path",
   260  		Usage: "/path/to/client.key for establishing a secure, TLS gRPC connection to a remote signer server",
   261  		Value: "",
   262  	}
   263  	// RemoteSignerCACertPathFlag defines the path to a ca.crt file for a wallet to connect to
   264  	// a secure signer via TLS and gRPC.
   265  	RemoteSignerCACertPathFlag = &cli.StringFlag{
   266  		Name:  "remote-signer-ca-crt-path",
   267  		Usage: "/path/to/ca.crt for establishing a secure, TLS gRPC connection to a remote signer server",
   268  		Value: "",
   269  	}
   270  	// KeymanagerKindFlag defines the kind of keymanager desired by a user during wallet creation.
   271  	KeymanagerKindFlag = &cli.StringFlag{
   272  		Name:  "keymanager-kind",
   273  		Usage: "Kind of keymanager, either imported, derived, or remote, specified during wallet creation",
   274  		Value: "",
   275  	}
   276  	// SkipDepositConfirmationFlag skips the y/n confirmation prompt for sending a deposit to the deposit contract.
   277  	SkipDepositConfirmationFlag = &cli.BoolFlag{
   278  		Name:  "skip-deposit-confirmation",
   279  		Usage: "Skips the y/n confirmation prompt for sending a deposit to the deposit contract",
   280  		Value: false,
   281  	}
   282  	// EnableWebFlag enables controlling the validator client via the Prysm web ui. This is a work in progress.
   283  	EnableWebFlag = &cli.BoolFlag{
   284  		Name:  "web",
   285  		Usage: "Enables the web portal for the validator client (work in progress)",
   286  		Value: false,
   287  	}
   288  	// SlashingProtectionExportDirFlag allows specifying the outpt directory
   289  	// for a validator's slashing protection history.
   290  	SlashingProtectionExportDirFlag = &cli.StringFlag{
   291  		Name:  "slashing-protection-export-dir",
   292  		Usage: "Allows users to specify the output directory to export their slashing protection EIP-3076 standard JSON File",
   293  		Value: "",
   294  	}
   295  	// GraffitiFileFlag specifies the file path to load graffiti values.
   296  	GraffitiFileFlag = &cli.StringFlag{
   297  		Name:  "graffiti-file",
   298  		Usage: "The path to a YAML file with graffiti values",
   299  	}
   300  	// EnableDutyCountDown enables more verbose logging for counting down to duty.
   301  	EnableDutyCountDown = &cli.BoolFlag{
   302  		Name:  "enable-duty-count-down",
   303  		Usage: "Enables more verbose logging for counting down to duty",
   304  		Value: false,
   305  	}
   306  )
   307  
   308  // DefaultValidatorDir returns OS-specific default validator directory.
   309  func DefaultValidatorDir() string {
   310  	// Try to place the data folder in the user's home dir
   311  	home := fileutil.HomeDir()
   312  	if home != "" {
   313  		if runtime.GOOS == "darwin" {
   314  			return filepath.Join(home, "Library", "Eth2Validators")
   315  		} else if runtime.GOOS == "windows" {
   316  			return filepath.Join(home, "AppData", "Local", "Eth2Validators")
   317  		} else {
   318  			return filepath.Join(home, ".eth2validators")
   319  		}
   320  	}
   321  	// As we cannot guess a stable location, return empty and handle later
   322  	return ""
   323  }