Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Remove deprecated validator parameters" #5343

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion validator/flags/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["flags.go"],
srcs = [
"flags.go",
"interop.go",
],
importpath = "github.com/prysmaticlabs/prysm/validator/flags",
visibility = ["//validator:__subpackages__"],
deps = ["@in_gopkg_urfave_cli_v2//:go_default_library"],
Expand Down
7 changes: 7 additions & 0 deletions validator/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ var (
Name: "tls-cert",
Usage: "Certificate for secure gRPC. Pass this and the tls-key flag in order to use gRPC securely.",
}
// UnencryptedKeysFlag specifies a file path of a JSON file of unencrypted validator keys; this should only
// be used for test networks.
UnencryptedKeysFlag = &cli.StringFlag{
Name: "unencrypted-keys",
Usage: "Filepath to a JSON file of unencrypted validator keys for launching the validator client on test networks",
Value: "",
}
// KeyManager specifies the key manager to use.
KeyManager = &cli.StringFlag{
Name: "keymanager",
Expand Down
21 changes: 21 additions & 0 deletions validator/flags/interop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package flags

import (
"gopkg.in/urfave/cli.v2"
)

// Flags defined for interoperability testing.
var (
InteropStartIndex = &cli.Uint64Flag{
Name: "interop-start-index",
Usage: "The start index to deterministically generate validator keys when used in combination with " +
"--interop-num-validators. Example: --interop-start-index=5 --interop-num-validators=3 would generate " +
"keys from index 5 to 7.",
}
InteropNumValidators = &cli.Uint64Flag{
Name: "interop-num-validators",
Usage: "The number of validators to deterministically generate when used in combination with " +
"--interop-num-validators. Example: --interop-start-index=5 --interop-num-validators=3 would generate " +
"keys from index 5 to 7.",
}
)
3 changes: 3 additions & 0 deletions validator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ var appFlags = []cli.Flag{
flags.CertFlag,
flags.GraffitiFlag,
flags.DisablePenaltyRewardLogFlag,
flags.UnencryptedKeysFlag,
flags.InteropStartIndex,
flags.InteropNumValidators,
flags.GrpcMaxCallRecvMsgSizeFlag,
flags.GrpcRetriesFlag,
flags.GrpcHeadersFlag,
Expand Down
20 changes: 17 additions & 3 deletions validator/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,6 @@ func (s *ValidatorClient) registerClientService(ctx *cli.Context, keyManager key
// selectKeyManager selects the key manager depending on the options provided by the user.
func selectKeyManager(ctx *cli.Context) (keymanager.KeyManager, error) {
manager := strings.ToLower(ctx.String(flags.KeyManager.Name))
if manager == "" {
return nil, fmt.Errorf("please supply a keymanager with --keymanager")
}
opts := ctx.String(flags.KeyManagerOpts.Name)
if opts == "" {
opts = "{}"
Expand All @@ -212,6 +209,23 @@ func selectKeyManager(ctx *cli.Context) (keymanager.KeyManager, error) {
opts = string(fileopts)
}

if manager == "" {
// Attempt to work out keymanager from deprecated vars.
if unencryptedKeys := ctx.String(flags.UnencryptedKeysFlag.Name); unencryptedKeys != "" {
manager = "unencrypted"
opts = fmt.Sprintf(`{"path":%q}`, unencryptedKeys)
log.Warn(fmt.Sprintf("--unencrypted-keys flag is deprecated. Please use --keymanager=unencrypted --keymanageropts='%s'", opts))
} else if numValidatorKeys := ctx.Uint64(flags.InteropNumValidators.Name); numValidatorKeys > 0 {
manager = "interop"
opts = fmt.Sprintf(`{"keys":%d,"offset":%d}`, numValidatorKeys, ctx.Uint64(flags.InteropStartIndex.Name))
log.Warn(fmt.Sprintf("--interop-num-validators and --interop-start-index flags are deprecated. Please use --keymanager=interop --keymanageropts='%s'", opts))
}
}

if manager == "" {
return nil, fmt.Errorf("please supply a keymanager with --keymanager")
}

var km keymanager.KeyManager
var help string
var err error
Expand Down
8 changes: 8 additions & 0 deletions validator/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ var appHelpFlagGroups = []flagGroup{
flags.KeyManager,
flags.KeyManagerOpts,
flags.DisablePenaltyRewardLogFlag,
flags.UnencryptedKeysFlag,
flags.GraffitiFlag,
flags.GrpcMaxCallRecvMsgSizeFlag,
flags.GrpcRetriesFlag,
Expand All @@ -89,6 +90,13 @@ var appHelpFlagGroups = []flagGroup{
Name: "features",
Flags: featureconfig.ActiveFlags(featureconfig.ValidatorFlags),
},
{
Name: "interop",
Flags: []cli.Flag{
flags.InteropNumValidators,
flags.InteropStartIndex,
},
},
}

func init() {
Expand Down