mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Make voluntary exits release-ready (#7305)
* phrase validation utility * use passphrase from docs portal * enable voluntary exits * Merge branch 'master' into enable-exits * rename 'voluntary-exit' to 'exit' * change passphrase * gazelle * change constant to error variable * Merge branch 'master' into enable-exits * rename error variable * build fix * Merge refs/heads/master into enable-exits * do not remove whitespace in the middle * Merge refs/heads/master into enable-exits * Merge refs/heads/master into enable-exits * Merge refs/heads/master into enable-exits * Merge refs/heads/master into enable-exits * code review changes * Merge refs/heads/master into enable-exits * Merge refs/heads/master into enable-exits
This commit is contained in:
@@ -52,8 +52,6 @@ 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_grpc//codes:go_default_library",
|
||||
"@org_golang_google_grpc//status:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -18,8 +18,6 @@ import (
|
||||
v2 "github.com/prysmaticlabs/prysm/validator/keymanager/v2"
|
||||
"github.com/urfave/cli/v2"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
type performExitCfg struct {
|
||||
@@ -30,6 +28,8 @@ type performExitCfg struct {
|
||||
formattedPubKeys []string
|
||||
}
|
||||
|
||||
const exitPassphrase = "Exit my validator"
|
||||
|
||||
// ExitAccountsCli performs a voluntary exit on one or more accounts.
|
||||
func ExitAccountsCli(cliCtx *cli.Context, r io.Reader) error {
|
||||
validatingPublicKeys, keymanager, err := prepareWallet(cliCtx)
|
||||
@@ -73,11 +73,6 @@ func ExitAccountsCli(cliCtx *cli.Context, r io.Reader) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ExitAccountsUnimplemented is a stub for ExitAccounts until the latter is fully implemented.
|
||||
func ExitAccountsUnimplemented(cliCtx *cli.Context, r io.Reader) error {
|
||||
return status.Errorf(codes.Unimplemented, "method ExitAccounts not implemented")
|
||||
}
|
||||
|
||||
func prepareWallet(cliCtx *cli.Context) ([][48]byte, v2.IKeymanager, error) {
|
||||
w, err := wallet.OpenWalletOrElseCli(cliCtx, func(cliCtx *cli.Context) (*wallet.Wallet, error) {
|
||||
return nil, errors.New(
|
||||
@@ -158,10 +153,12 @@ func interact(cliCtx *cli.Context, r io.Reader, validatingPublicKeys [][48]byte)
|
||||
promptDescription := "Withdrawing funds is not possible in Phase 0 of the system. " +
|
||||
"Please navigate to the following website and make sure you understand the current implications " +
|
||||
"of a voluntary exit before making the final decision:"
|
||||
promptURL := au.Blue("https://docs.prylabs.network/docs/faq/#can-i-get-back-my-testnet-eth-how-can-i-withdraw-my-validator-gains")
|
||||
promptQuestion := "Do you still want to continue with the voluntary exit? Y/N"
|
||||
promptURL := au.Blue("https://docs.prylabs.network/docs/wallet/nondeterministic/exiting-a-validator/#withdrawal-delay-warning")
|
||||
promptQuestion := "If you still want to continue with the voluntary exit, please input the passphrase from the above URL"
|
||||
promptText := fmt.Sprintf("%s\n%s\n%s\n%s", promptHeader, promptDescription, promptURL, promptQuestion)
|
||||
resp, err := promptutil.ValidatePrompt(r, promptText, promptutil.ValidateYesOrNo)
|
||||
resp, err := promptutil.ValidatePrompt(r, promptText, func(input string) error {
|
||||
return promptutil.ValidatePhrase(input, exitPassphrase)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ func TestExitAccountsCli_Ok(t *testing.T) {
|
||||
|
||||
// Prepare user input for final confirmation step
|
||||
var stdin bytes.Buffer
|
||||
stdin.Write([]byte("Y\n"))
|
||||
stdin.Write([]byte(exitPassphrase))
|
||||
rawPubKeys, formattedPubKeys, err := interact(cliCtx, &stdin, validatingPublicKeys)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, rawPubKeys)
|
||||
|
||||
@@ -145,7 +145,7 @@ 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 := ExitAccountsUnimplemented(cliCtx, os.Stdin); err != nil {
|
||||
if err := ExitAccountsCli(cliCtx, os.Stdin); err != nil {
|
||||
log.Fatalf("Could not perform voluntary exit: %v", err)
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user