mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Allow dynamic key reloading when having inactive keys (imported & derived) (#8119)
* restart waiting for activation on key change * test fixes * wiat for activation comments * regression test * log fatal when validator cast fails * derived keymanager * review comments * add buffer to channel * simplify key refetch logic * reload keys into empty wallet * removed warning on wallet creation * add empty line * export AccountsKeystoreRepresentation type * unit test for handleAccountsChanged * test ctx cancellation * add missing mockRemoteKeymanager interface function * gazelle * gzl * fix panic inside goroutine during runner tests * rename error message variables * Update validator/accounts/accounts_list_test.go * reorder imports Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
This commit is contained in:
@@ -75,6 +75,7 @@ go_test(
|
||||
"//proto/validator/accounts/v2:go_default_library",
|
||||
"//shared/bls:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
"//shared/event:go_default_library",
|
||||
"//shared/fileutil:go_default_library",
|
||||
"//shared/mock:go_default_library",
|
||||
"//shared/params:go_default_library",
|
||||
|
||||
@@ -5,10 +5,9 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/validator/keymanager"
|
||||
)
|
||||
|
||||
var msgKeymanagerNotSupported = "keymanager kind not supported: %s"
|
||||
|
||||
var (
|
||||
// ErrCouldNotInitializeKeymanager informs about failed keymanager initialization
|
||||
errKeymanagerNotSupported = "keymanager kind not supported: %s"
|
||||
// MsgCouldNotInitializeKeymanager informs about failed keymanager initialization
|
||||
ErrCouldNotInitializeKeymanager = "could not initialize keymanager"
|
||||
)
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ func BackupAccountsCli(cliCtx *cli.Context) error {
|
||||
case keymanager.Remote:
|
||||
return errors.New("backing up keys is not supported for a remote keymanager")
|
||||
default:
|
||||
return fmt.Errorf(msgKeymanagerNotSupported, w.KeymanagerKind())
|
||||
return fmt.Errorf(errKeymanagerNotSupported, w.KeymanagerKind())
|
||||
}
|
||||
return zipKeystoresToOutputDir(keystoresToBackup, backupDir)
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ func DeleteAccount(ctx context.Context, cfg *AccountsConfig) error {
|
||||
return errors.Wrap(err, "could not delete accounts")
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf(msgKeymanagerNotSupported, cfg.Wallet.KeymanagerKind())
|
||||
return fmt.Errorf(errKeymanagerNotSupported, cfg.Wallet.KeymanagerKind())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ func ListAccountsCli(cliCtx *cli.Context) error {
|
||||
return errors.Wrap(err, "could not list validator accounts with remote keymanager")
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf(msgKeymanagerNotSupported, w.KeymanagerKind().String())
|
||||
return fmt.Errorf(errKeymanagerNotSupported, w.KeymanagerKind().String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
validatorpb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/event"
|
||||
"github.com/prysmaticlabs/prysm/shared/petnames"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
@@ -41,6 +42,10 @@ func (m *mockRemoteKeymanager) Sign(context.Context, *validatorpb.SignRequest) (
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *mockRemoteKeymanager) SubscribeAccountChanges(_ chan [][48]byte) event.Subscription {
|
||||
return nil
|
||||
}
|
||||
|
||||
func createRandomKeystore(t testing.TB, password string) *keymanager.Keystore {
|
||||
encryptor := keystorev4.New()
|
||||
id, err := uuid.NewRandom()
|
||||
|
||||
@@ -116,7 +116,7 @@ func CreateWalletWithKeymanager(ctx context.Context, cfg *CreateWalletConfig) (*
|
||||
"Successfully created wallet with remote keymanager configuration",
|
||||
)
|
||||
default:
|
||||
return nil, errors.Wrapf(err, msgKeymanagerNotSupported, w.KeymanagerKind())
|
||||
return nil, errors.Wrapf(err, errKeymanagerNotSupported, w.KeymanagerKind())
|
||||
}
|
||||
return w, nil
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func EditWalletConfigurationCli(cliCtx *cli.Context) error {
|
||||
return errors.Wrap(err, "could not write config to disk")
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf(msgKeymanagerNotSupported, w.KeymanagerKind())
|
||||
return fmt.Errorf(errKeymanagerNotSupported, w.KeymanagerKind())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user