Skip to content

Commit

Permalink
Revert "Revert "Revert "Remove deprecated parameters (#5249)" (#5276)" (
Browse files Browse the repository at this point in the history
#5277)"

This reverts commit e5aef16.
  • Loading branch information
prestonvanloon authored Apr 7, 2020
1 parent 6f262b5 commit 9b28992
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 4 deletions.
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

0 comments on commit 9b28992

Please sign in to comment.