Check for syncstatus before performing a voluntary exit (#9951)

Co-authored-by: Radosław Kapka <rkapka@wp.pl>
This commit is contained in:
Potuz 2021-11-30 07:40:59 -03:00 committed by GitHub
parent d8aa0f8827
commit 71d55d1cff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -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",
],
)

View File

@ -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,