2020-04-29 21:32:39 +00:00
|
|
|
// Package flags contains all configuration runtime flags for
|
|
|
|
// the validator service.
|
2019-07-23 13:58:20 +00:00
|
|
|
package flags
|
2015-07-28 22:16:16 +00:00
|
|
|
|
|
|
|
import (
|
2020-07-01 21:30:01 +00:00
|
|
|
"path/filepath"
|
|
|
|
"runtime"
|
2020-07-22 03:45:52 +00:00
|
|
|
"time"
|
2020-07-01 21:30:01 +00:00
|
|
|
|
2020-08-10 18:54:40 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
2020-05-31 06:44:34 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
2018-01-13 22:31:28 +00:00
|
|
|
)
|
|
|
|
|
2020-07-29 01:20:13 +00:00
|
|
|
const (
|
|
|
|
// WalletDefaultDirName for accounts-v2.
|
|
|
|
WalletDefaultDirName = "prysm-wallet-v2"
|
|
|
|
)
|
|
|
|
|
2015-07-28 22:16:16 +00:00
|
|
|
var (
|
2020-05-19 13:44:54 +00:00
|
|
|
// DisableAccountMetricsFlag defines the graffiti value included in proposed blocks, default false.
|
|
|
|
DisableAccountMetricsFlag = &cli.BoolFlag{
|
2020-05-20 15:23:22 +00:00
|
|
|
Name: "disable-account-metrics",
|
2020-05-19 13:44:54 +00:00
|
|
|
Usage: "Disable prometheus metrics for validator accounts. Operators with high volumes " +
|
|
|
|
"of validating keys may wish to disable granular prometheus metrics as it increases " +
|
|
|
|
"the data cardinality.",
|
2020-04-19 08:36:19 +00:00
|
|
|
}
|
2018-08-01 22:08:44 +00:00
|
|
|
// BeaconRPCProviderFlag defines a beacon node RPC endpoint.
|
2020-03-19 21:46:44 +00:00
|
|
|
BeaconRPCProviderFlag = &cli.StringFlag{
|
2018-08-01 22:08:44 +00:00
|
|
|
Name: "beacon-rpc-provider",
|
|
|
|
Usage: "Beacon node RPC provider endpoint",
|
2020-06-15 16:52:15 +00:00
|
|
|
Value: "127.0.0.1:4000",
|
2018-08-01 22:08:44 +00:00
|
|
|
}
|
2020-09-04 19:03:18 +00:00
|
|
|
// BeaconRPCGatewayProviderFlag defines a beacon node JSON-RPC endpoint.
|
|
|
|
BeaconRPCGatewayProviderFlag = &cli.StringFlag{
|
|
|
|
Name: "beacon-rpc-gateway-provider",
|
|
|
|
Usage: "Beacon node RPC gateway provider endpoint",
|
|
|
|
Value: "127.0.0.1:3500",
|
|
|
|
}
|
2018-08-08 22:43:25 +00:00
|
|
|
// CertFlag defines a flag for the node's TLS certificate.
|
2020-03-19 21:46:44 +00:00
|
|
|
CertFlag = &cli.StringFlag{
|
2018-08-08 22:43:25 +00:00
|
|
|
Name: "tls-cert",
|
|
|
|
Usage: "Certificate for secure gRPC. Pass this and the tls-key flag in order to use gRPC securely.",
|
|
|
|
}
|
2020-09-30 20:55:56 +00:00
|
|
|
// EnableRPCFlag enables controlling the validator client via gRPC (without web UI).
|
|
|
|
EnableRPCFlag = &cli.BoolFlag{
|
|
|
|
Name: "rpc",
|
|
|
|
Usage: "Enables the RPC server for the validator client (without Web UI)",
|
|
|
|
Value: false,
|
|
|
|
}
|
2020-08-14 02:49:57 +00:00
|
|
|
// RPCHost defines the host on which the RPC server should listen.
|
|
|
|
RPCHost = &cli.StringFlag{
|
|
|
|
Name: "rpc-host",
|
|
|
|
Usage: "Host on which the RPC server should listen",
|
|
|
|
Value: "127.0.0.1",
|
|
|
|
}
|
|
|
|
// RPCPort defines a validator client RPC port to open.
|
|
|
|
RPCPort = &cli.IntFlag{
|
|
|
|
Name: "rpc-port",
|
|
|
|
Usage: "RPC port exposed by a validator client",
|
|
|
|
Value: 7000,
|
|
|
|
}
|
2020-05-20 15:23:22 +00:00
|
|
|
// SlasherRPCProviderFlag defines a slasher node RPC endpoint.
|
|
|
|
SlasherRPCProviderFlag = &cli.StringFlag{
|
|
|
|
Name: "slasher-rpc-provider",
|
|
|
|
Usage: "Slasher node RPC provider endpoint",
|
2020-06-15 16:52:15 +00:00
|
|
|
Value: "127.0.0.1:4002",
|
2020-05-20 15:23:22 +00:00
|
|
|
}
|
|
|
|
// SlasherCertFlag defines a flag for the slasher node's TLS certificate.
|
|
|
|
SlasherCertFlag = &cli.StringFlag{
|
|
|
|
Name: "slasher-tls-cert",
|
|
|
|
Usage: "Certificate for secure slasher gRPC. Pass this and the tls-key flag in order to use gRPC securely.",
|
|
|
|
}
|
2019-04-27 03:56:11 +00:00
|
|
|
// DisablePenaltyRewardLogFlag defines the ability to not log reward/penalty information during deployment
|
2020-03-19 21:46:44 +00:00
|
|
|
DisablePenaltyRewardLogFlag = &cli.BoolFlag{
|
2019-04-27 03:56:11 +00:00
|
|
|
Name: "disable-rewards-penalties-logging",
|
|
|
|
Usage: "Disable reward/penalty logging during cluster deployment",
|
|
|
|
}
|
2019-12-07 19:13:56 +00:00
|
|
|
// GraffitiFlag defines the graffiti value included in proposed blocks
|
2020-03-19 21:46:44 +00:00
|
|
|
GraffitiFlag = &cli.StringFlag{
|
2019-12-09 14:31:53 +00:00
|
|
|
Name: "graffiti",
|
2019-12-07 19:13:56 +00:00
|
|
|
Usage: "String to include in proposed blocks",
|
|
|
|
}
|
2020-02-24 18:00:22 +00:00
|
|
|
// GrpcRetriesFlag defines the number of times to retry a failed gRPC request.
|
2020-03-19 21:46:44 +00:00
|
|
|
GrpcRetriesFlag = &cli.UintFlag{
|
2020-02-24 18:00:22 +00:00
|
|
|
Name: "grpc-retries",
|
|
|
|
Usage: "Number of attempts to retry gRPC requests",
|
|
|
|
Value: 5,
|
|
|
|
}
|
2020-07-22 03:45:52 +00:00
|
|
|
// GrpcRetryDelayFlag defines the interval to retry a failed gRPC request.
|
|
|
|
GrpcRetryDelayFlag = &cli.DurationFlag{
|
|
|
|
Name: "grpc-retry-delay",
|
|
|
|
Usage: "The amount of time between gRPC retry requests.",
|
|
|
|
Value: 1 * time.Second,
|
|
|
|
}
|
2020-03-25 16:29:04 +00:00
|
|
|
// GrpcHeadersFlag defines a list of headers to send with all gRPC requests.
|
|
|
|
GrpcHeadersFlag = &cli.StringFlag{
|
|
|
|
Name: "grpc-headers",
|
|
|
|
Usage: "A comma separated list of key value pairs to pass as gRPC headers for all gRPC " +
|
|
|
|
"calls. Example: --grpc-headers=key=value",
|
|
|
|
}
|
2020-08-14 02:49:57 +00:00
|
|
|
// GRPCGatewayHost specifies a gRPC gateway host for the validator client.
|
|
|
|
GRPCGatewayHost = &cli.StringFlag{
|
|
|
|
Name: "grpc-gateway-host",
|
|
|
|
Usage: "The host on which the gateway server runs on",
|
|
|
|
Value: "127.0.0.1",
|
|
|
|
}
|
|
|
|
// GRPCGatewayPort enables a gRPC gateway to be exposed for the validator client.
|
|
|
|
GRPCGatewayPort = &cli.IntFlag{
|
|
|
|
Name: "grpc-gateway-port",
|
|
|
|
Usage: "Enable gRPC gateway for JSON requests",
|
|
|
|
Value: 7500,
|
|
|
|
}
|
2020-09-04 19:03:18 +00:00
|
|
|
// GPRCGatewayCorsDomain serves preflight requests when serving gRPC JSON gateway.
|
|
|
|
GPRCGatewayCorsDomain = &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.",
|
2020-10-10 02:07:28 +00:00
|
|
|
Value: "http://localhost:4242,http://127.0.0.1:4242,http://localhost:4200",
|
2020-09-04 19:03:18 +00:00
|
|
|
}
|
2020-04-19 08:36:19 +00:00
|
|
|
// MonitoringPortFlag defines the http port used to serve prometheus metrics.
|
2020-07-08 08:21:06 +00:00
|
|
|
MonitoringPortFlag = &cli.IntFlag{
|
2020-04-19 08:36:19 +00:00
|
|
|
Name: "monitoring-port",
|
|
|
|
Usage: "Port used to listening and respond metrics for prometheus.",
|
|
|
|
Value: 8081,
|
|
|
|
}
|
2020-07-01 21:30:01 +00:00
|
|
|
// WalletDirFlag defines the path to a wallet directory for Prysm accounts-v2.
|
|
|
|
WalletDirFlag = &cli.StringFlag{
|
|
|
|
Name: "wallet-dir",
|
|
|
|
Usage: "Path to a wallet directory on-disk for Prysm validator accounts",
|
2020-07-29 01:20:13 +00:00
|
|
|
Value: filepath.Join(DefaultValidatorDir(), WalletDefaultDirName),
|
2020-07-01 21:30:01 +00:00
|
|
|
}
|
2020-08-20 19:14:03 +00:00
|
|
|
// AccountPasswordFileFlag is path to a file containing a password for a validator account.
|
2020-07-29 01:20:13 +00:00
|
|
|
AccountPasswordFileFlag = &cli.StringFlag{
|
|
|
|
Name: "account-password-file",
|
2020-08-20 19:14:03 +00:00
|
|
|
Usage: "Path to a plain-text, .txt file containing a password for a validator account",
|
2020-07-01 21:30:01 +00:00
|
|
|
}
|
2020-07-29 01:20:13 +00:00
|
|
|
// WalletPasswordFileFlag is the path to a file containing your wallet password.
|
|
|
|
WalletPasswordFileFlag = &cli.StringFlag{
|
|
|
|
Name: "wallet-password-file",
|
|
|
|
Usage: "Path to a plain-text, .txt file containing your wallet password",
|
2020-07-14 23:00:58 +00:00
|
|
|
}
|
2020-08-11 16:32:05 +00:00
|
|
|
// ImportPrivateKeyFileFlag allows for directly importing a private key hex string as an account.
|
|
|
|
ImportPrivateKeyFileFlag = &cli.StringFlag{
|
|
|
|
Name: "import-private-key-file",
|
|
|
|
Usage: "Path to a plain-text, .txt file containing a hex string representation of a private key to import",
|
|
|
|
}
|
2020-07-22 02:41:39 +00:00
|
|
|
// MnemonicFileFlag is used to enter a file to mnemonic phrase for new wallet creation, non-interactively.
|
|
|
|
MnemonicFileFlag = &cli.StringFlag{
|
|
|
|
Name: "mnemonic-file",
|
|
|
|
Usage: "File to retrieve mnemonic for non-interactively passing a mnemonic phrase into wallet recover.",
|
|
|
|
}
|
2020-07-08 19:21:54 +00:00
|
|
|
// ShowDepositDataFlag for accounts-v2.
|
|
|
|
ShowDepositDataFlag = &cli.BoolFlag{
|
|
|
|
Name: "show-deposit-data",
|
|
|
|
Usage: "Display raw eth1 tx deposit data for validator accounts-v2",
|
2020-10-15 16:08:52 +00:00
|
|
|
Value: false,
|
|
|
|
}
|
|
|
|
// ShowPrivateKeysFlag for accounts-v2.
|
|
|
|
ShowPrivateKeysFlag = &cli.BoolFlag{
|
|
|
|
Name: "show-private-keys",
|
|
|
|
Usage: "Display the private keys for validator accounts-v2",
|
2020-07-08 19:21:54 +00:00
|
|
|
Value: false,
|
|
|
|
}
|
2020-07-27 14:03:30 +00:00
|
|
|
// NumAccountsFlag defines the amount of accounts to generate for derived wallets.
|
2020-10-11 15:26:59 +00:00
|
|
|
NumAccountsFlag = &cli.IntFlag{
|
2020-07-27 14:03:30 +00:00
|
|
|
Name: "num-accounts",
|
|
|
|
Usage: "Number of accounts to generate for derived wallets",
|
|
|
|
Value: 1,
|
|
|
|
}
|
2020-08-11 23:15:06 +00:00
|
|
|
// DeletePublicKeysFlag defines a comma-separated list of hex string public keys
|
|
|
|
// for accounts which a user desires to delete from their wallet.
|
|
|
|
DeletePublicKeysFlag = &cli.StringFlag{
|
|
|
|
Name: "delete-public-keys",
|
|
|
|
Usage: "Comma-separated list of public key hex strings to specify which validator accounts to delete",
|
|
|
|
Value: "",
|
|
|
|
}
|
|
|
|
// BackupPublicKeysFlag defines a comma-separated list of hex string public keys
|
|
|
|
// for accounts which a user desires to backup from their wallet.
|
|
|
|
BackupPublicKeysFlag = &cli.StringFlag{
|
|
|
|
Name: "backup-public-keys",
|
|
|
|
Usage: "Comma-separated list of public key hex strings to specify which validator accounts to backup",
|
|
|
|
Value: "",
|
|
|
|
}
|
2020-08-20 17:53:09 +00:00
|
|
|
// VoluntaryExitPublicKeysFlag defines a comma-separated list of hex string public keys
|
|
|
|
// for accounts on which a user wants to perform a voluntary exit.
|
|
|
|
VoluntaryExitPublicKeysFlag = &cli.StringFlag{
|
2020-09-09 18:29:17 +00:00
|
|
|
Name: "public-keys",
|
2020-08-20 17:53:09 +00:00
|
|
|
Usage: "Comma-separated list of public key hex strings to specify on which validator accounts to perform " +
|
|
|
|
"a voluntary exit",
|
|
|
|
Value: "",
|
|
|
|
}
|
2020-08-11 23:15:06 +00:00
|
|
|
// BackupPasswordFile for encrypting accounts a user wishes to back up.
|
|
|
|
BackupPasswordFile = &cli.StringFlag{
|
|
|
|
Name: "backup-password-file",
|
|
|
|
Usage: "Path to a plain-text, .txt file containing the desired password for your backed up accounts",
|
|
|
|
Value: "",
|
|
|
|
}
|
2020-07-23 03:10:23 +00:00
|
|
|
// BackupDirFlag defines the path for the zip backup of the wallet will be created.
|
|
|
|
BackupDirFlag = &cli.StringFlag{
|
|
|
|
Name: "backup-dir",
|
2020-08-11 23:15:06 +00:00
|
|
|
Usage: "Path to a directory where accounts will be backed up into a zip file",
|
2020-07-13 21:37:18 +00:00
|
|
|
Value: DefaultValidatorDir(),
|
|
|
|
}
|
2020-07-28 14:18:22 +00:00
|
|
|
// KeysDirFlag defines the path for a directory where keystores to be imported at stored.
|
|
|
|
KeysDirFlag = &cli.StringFlag{
|
|
|
|
Name: "keys-dir",
|
|
|
|
Usage: "Path to a directory where keystores to be imported are stored",
|
|
|
|
}
|
2020-07-16 05:08:16 +00:00
|
|
|
// GrpcRemoteAddressFlag defines the host:port address for a remote keymanager to connect to.
|
|
|
|
GrpcRemoteAddressFlag = &cli.StringFlag{
|
|
|
|
Name: "grpc-remote-address",
|
|
|
|
Usage: "Host:port of a gRPC server for a remote keymanager",
|
|
|
|
Value: "",
|
|
|
|
}
|
|
|
|
// 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{
|
|
|
|
Name: "remote-signer-crt-path",
|
|
|
|
Usage: "/path/to/client.crt for establishing a secure, TLS gRPC connection to a remote signer server",
|
|
|
|
Value: "",
|
|
|
|
}
|
|
|
|
// RemoteSignerKeyPathFlag defines the path to a client.key file for a wallet to connect to
|
|
|
|
// a secure signer via TLS and gRPC.
|
|
|
|
RemoteSignerKeyPathFlag = &cli.StringFlag{
|
|
|
|
Name: "remote-signer-key-path",
|
|
|
|
Usage: "/path/to/client.key for establishing a secure, TLS gRPC connection to a remote signer server",
|
|
|
|
Value: "",
|
|
|
|
}
|
|
|
|
// RemoteSignerCACertPathFlag defines the path to a ca.crt file for a wallet to connect to
|
|
|
|
// a secure signer via TLS and gRPC.
|
|
|
|
RemoteSignerCACertPathFlag = &cli.StringFlag{
|
|
|
|
Name: "remote-signer-ca-crt-path",
|
|
|
|
Usage: "/path/to/ca.crt for establishing a secure, TLS gRPC connection to a remote signer server",
|
|
|
|
Value: "",
|
|
|
|
}
|
2020-07-17 08:21:16 +00:00
|
|
|
// KeymanagerKindFlag defines the kind of keymanager desired by a user during wallet creation.
|
|
|
|
KeymanagerKindFlag = &cli.StringFlag{
|
|
|
|
Name: "keymanager-kind",
|
|
|
|
Usage: "Kind of keymanager, either direct, derived, or remote, specified during wallet creation",
|
|
|
|
Value: "",
|
|
|
|
}
|
2020-08-24 19:19:21 +00:00
|
|
|
// SkipDepositConfirmationFlag skips the y/n confirmation prompt for sending a deposit to the deposit contract.
|
|
|
|
SkipDepositConfirmationFlag = &cli.BoolFlag{
|
|
|
|
Name: "skip-deposit-confirmation",
|
|
|
|
Usage: "Skips the y/n confirmation prompt for sending a deposit to the deposit contract",
|
|
|
|
Value: false,
|
|
|
|
}
|
2020-09-03 15:11:17 +00:00
|
|
|
// EnableWebFlag enables controlling the validator client via the Prysm web ui. This is a work in progress.
|
|
|
|
EnableWebFlag = &cli.BoolFlag{
|
|
|
|
Name: "web",
|
|
|
|
Usage: "Enables the web portal for the validator client (work in progress)",
|
|
|
|
Value: false,
|
|
|
|
}
|
2020-10-09 14:58:30 +00:00
|
|
|
// WebHostFlag specifies the host name to bind the Prysm web UI server.
|
|
|
|
WebHostFlag = &cli.StringFlag{
|
|
|
|
Name: "web-host",
|
|
|
|
Usage: "The host address which to serve the Prysm web UI",
|
|
|
|
Value: "127.0.0.1",
|
|
|
|
}
|
|
|
|
// WebPortFlag specifies the port number to bind the Prysm web UI server.
|
|
|
|
WebPortFlag = &cli.Uint64Flag{
|
|
|
|
Name: "web-port",
|
|
|
|
Usage: "The host port which to serve the Prysm web UI",
|
|
|
|
Value: 4242,
|
|
|
|
}
|
2015-07-28 22:16:16 +00:00
|
|
|
)
|
2020-07-01 21:30:01 +00:00
|
|
|
|
|
|
|
// DefaultValidatorDir returns OS-specific default validator directory.
|
|
|
|
func DefaultValidatorDir() string {
|
|
|
|
// Try to place the data folder in the user's home dir
|
2020-08-10 18:54:40 +00:00
|
|
|
home := fileutil.HomeDir()
|
2020-07-01 21:30:01 +00:00
|
|
|
if home != "" {
|
|
|
|
if runtime.GOOS == "darwin" {
|
|
|
|
return filepath.Join(home, "Library", "Eth2Validators")
|
|
|
|
} else if runtime.GOOS == "windows" {
|
|
|
|
return filepath.Join(home, "AppData", "Roaming", "Eth2Validators")
|
|
|
|
} else {
|
|
|
|
return filepath.Join(home, ".eth2validators")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// As we cannot guess a stable location, return empty and handle later
|
|
|
|
return ""
|
|
|
|
}
|