Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous Keystore Fixes #7756

Merged
merged 7 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion validator/accounts/accounts_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ func DeleteAccountCli(cliCtx *cli.Context) error {
}); err != nil {
return err
}
log.WithField("publicKeys", allAccountStr).Info("Accounts deleted")
log.WithField("publicKeys", allAccountStr).Warn(
rauljordan marked this conversation as resolved.
Show resolved Hide resolved
"Attempted to delete accounts. IMPORTANT: please run `validator accounts list` to ensure " +
"the public keys are indeed deleted. If they are still there, please file an issue at " +
"https://github.com/prysmaticlabs/prysm/issues/new")
rauljordan marked this conversation as resolved.
Show resolved Hide resolved
return nil
}

Expand Down
21 changes: 0 additions & 21 deletions validator/keymanager/imported/keymanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ func NewKeymanager(ctx context.Context, cfg *SetupConfig) (*Keymanager, error) {
if err := k.initializeAccountKeystore(ctx); err != nil {
return nil, errors.Wrap(err, "failed to initialize account store")
}
if k.opts.Version != "2" {
if err := k.rewriteAccountsKeystore(ctx); err != nil {
return nil, errors.Wrap(err, "failed to write accounts keystore")
}
}

// We begin a goroutine to listen for file changes to our
// all-accounts.keystore.json file in the wallet directory.
Expand Down Expand Up @@ -311,22 +306,6 @@ func (dr *Keymanager) Sign(ctx context.Context, req *validatorpb.SignRequest) (b
return secretKey.Sign(req.SigningRoot), nil
}

func (dr *Keymanager) rewriteAccountsKeystore(ctx context.Context) error {
newStore, err := dr.createAccountsKeystore(ctx, dr.accountsStore.PrivateKeys, dr.accountsStore.PublicKeys)
if err != nil {
return err
}
// Write the encoded keystore.
encoded, err := json.MarshalIndent(newStore, "", "\t")
if err != nil {
return err
}
if err := dr.wallet.WriteFileAtPath(ctx, AccountsPath, accountsKeystoreFileName, encoded); err != nil {
return errors.Wrap(err, "could not write keystore file for accounts")
}
return nil
}

func (dr *Keymanager) initializeAccountKeystore(ctx context.Context) error {
encoded, err := dr.wallet.ReadFileAtPath(ctx, AccountsPath, accountsKeystoreFileName)
if err != nil && strings.Contains(err.Error(), "no files found") {
Expand Down