From 71d55d1cffeb4b9161f9bf77a37ad99b26765fe9 Mon Sep 17 00:00:00 2001 From: Potuz Date: Tue, 30 Nov 2021 07:40:59 -0300 Subject: [PATCH] Check for syncstatus before performing a voluntary exit (#9951) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Radosław Kapka --- validator/accounts/BUILD.bazel | 1 + validator/accounts/accounts_exit.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/validator/accounts/BUILD.bazel b/validator/accounts/BUILD.bazel index 4da748bce..c4be46150 100644 --- a/validator/accounts/BUILD.bazel +++ b/validator/accounts/BUILD.bazel @@ -54,6 +54,7 @@ go_library( "@com_github_urfave_cli_v2//:go_default_library", "@com_github_wealdtech_go_eth2_wallet_encryptor_keystorev4//:go_default_library", "@org_golang_google_grpc//:go_default_library", + "@org_golang_google_protobuf//types/known/emptypb:go_default_library", ], ) diff --git a/validator/accounts/accounts_exit.go b/validator/accounts/accounts_exit.go index 8b6e1217f..f20c4d1b7 100644 --- a/validator/accounts/accounts_exit.go +++ b/validator/accounts/accounts_exit.go @@ -24,6 +24,7 @@ import ( "github.com/prysmaticlabs/prysm/validator/keymanager" "github.com/urfave/cli/v2" "google.golang.org/grpc" + "google.golang.org/protobuf/types/known/emptypb" ) // PerformExitCfg for account voluntary exits. @@ -57,6 +58,20 @@ func ExitAccountsCli(cliCtx *cli.Context, r io.Reader) error { if err != nil { return err } + if nodeClient == nil { + return errors.New("Could not prepare beacon node client") + } + syncStatus, err := (*nodeClient).GetSyncStatus(cliCtx.Context, &emptypb.Empty{}) + if err != nil { + return err + } + if syncStatus == nil { + return errors.New("Could not get sync status") + } + + if (*syncStatus).Syncing { + return errors.New("Could not perform exit: beacon node is syncing.") + } cfg := PerformExitCfg{ *validatorClient,