diff --git a/beacon-chain/core/blocks/BUILD.bazel b/beacon-chain/core/blocks/BUILD.bazel index 6cb631bac4..f671ed8923 100644 --- a/beacon-chain/core/blocks/BUILD.bazel +++ b/beacon-chain/core/blocks/BUILD.bazel @@ -21,6 +21,7 @@ go_library( "//beacon-chain:__subpackages__", "//fuzz:__pkg__", "//shared/testutil:__pkg__", + "//validator/accounts:__pkg__", ], deps = [ "//beacon-chain/core/helpers:go_default_library", diff --git a/beacon-chain/core/blocks/exit.go b/beacon-chain/core/blocks/exit.go index e826138e89..3722bc1df0 100644 --- a/beacon-chain/core/blocks/exit.go +++ b/beacon-chain/core/blocks/exit.go @@ -13,6 +13,13 @@ import ( "github.com/prysmaticlabs/prysm/shared/params" ) +// ValidatorAlreadyExitedMsg defines a message saying that a validator has already exited. +var ValidatorAlreadyExitedMsg = "validator has already submitted an exit, which will take place at epoch" + +// ValidatorCannotExitYetMsg defines a message saying that a validator cannot exit +// because it has not been active long enough. +var ValidatorCannotExitYetMsg = "validator has not been active long enough to exit" + // ProcessVoluntaryExits is one of the operations performed // on each processed beacon block to determine which validators // should exit the state's validator registry. @@ -162,9 +169,7 @@ func verifyExitConditions(validator *stateTrie.ReadOnlyValidator, currentSlot ui } // Verify the validator has not yet submitted an exit. if validator.ExitEpoch() != params.BeaconConfig().FarFutureEpoch { - return fmt.Errorf( - "validator has already submitted an exit, which will take place at epoch: %v", - validator.ExitEpoch()) + return fmt.Errorf("%s: %v", ValidatorAlreadyExitedMsg, validator.ExitEpoch()) } // Exits must specify an epoch when they become valid; they are not valid before then. if currentEpoch < exit.Epoch { @@ -173,7 +178,8 @@ func verifyExitConditions(validator *stateTrie.ReadOnlyValidator, currentSlot ui // Verify the validator has been active long enough. if currentEpoch < validator.ActivationEpoch()+params.BeaconConfig().ShardCommitteePeriod { return fmt.Errorf( - "validator has not been active long enough to exit: %d epochs vs required %d epochs", + "%s: %d epochs vs required %d epochs", + ValidatorCannotExitYetMsg, currentEpoch, validator.ActivationEpoch()+params.BeaconConfig().ShardCommitteePeriod, ) diff --git a/validator/accounts/BUILD.bazel b/validator/accounts/BUILD.bazel index d70374f4d1..08369fc2ad 100644 --- a/validator/accounts/BUILD.bazel +++ b/validator/accounts/BUILD.bazel @@ -24,6 +24,7 @@ go_library( "//validator:__subpackages__", ], deps = [ + "//beacon-chain/core/blocks:go_default_library", "//proto/validator/accounts/v2:go_default_library", "//shared/bls:go_default_library", "//shared/bytesutil:go_default_library", diff --git a/validator/accounts/cmd_accounts.go b/validator/accounts/cmd_accounts.go index 4fb35eee60..938f8078ed 100644 --- a/validator/accounts/cmd_accounts.go +++ b/validator/accounts/cmd_accounts.go @@ -2,7 +2,9 @@ package accounts import ( "os" + "strings" + "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" "github.com/prysmaticlabs/prysm/shared/cmd" "github.com/prysmaticlabs/prysm/shared/featureconfig" "github.com/prysmaticlabs/prysm/validator/flags" @@ -171,6 +173,11 @@ this command outputs a deposit data string which is required to become a validat Action: func(cliCtx *cli.Context) error { featureconfig.ConfigureValidator(cliCtx) if err := ExitAccountsCli(cliCtx, os.Stdin); err != nil { + msg := err.Error() + if strings.Contains(msg, blocks.ValidatorAlreadyExitedMsg) || + strings.Contains(msg, blocks.ValidatorCannotExitYetMsg) { + log.Errorf("Could not perform voluntary exit: %s", msg) + } log.Fatalf("Could not perform voluntary exit: %v", err) } return nil