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

[Feature] enable/disable validator accounts #7746

Merged

Conversation

fabdarice
Copy link
Contributor

@fabdarice fabdarice commented Nov 8, 2020

What type of PR is this?
Feature

What does this PR do? Why is it needed?
This PR adds CLI commands to enable and disable accounts.
Disabled accounts won't be able to be used as validator credentials to attest to the network.
A user can re-enable previously disabled accounts making them valid again in the validator set.

This feature can facilitate moving validator keys from/to other clients or servers without having to use the current delete.

CLI example
validator accounts enable --enable-public-keys=0xdeafbeef,0xdeadbeef2
validator accounts disable --disable-public-keys=0xdeafbeef,0xdeadbeef2

Which issues(s) does this PR fix?

Fixes #7485

Other notes for review
Manual Tests:

  • accounts list still display all accounts
  • accounts delete still display all accounts
  • accounts disable only displays active accounts + will correctly disable accounts selected
  • accounts enable only displays disabled accounts + will correctly enable accounts selected
  • accounts backup still display all accounts
  • accounts enable --enable-public-keys
  • accounts disable --disable-public-keys
  • accounts disable on a Medalla validators and making sure that it doesn't attest anymore
  • accounts enable on a Medalla validators and making sure that it will re-attest again
  • Test /v2/validator/wallet in WebUI

)

// AccountConfig specifies parameters to run to delete, enable, disable accounts.
type AccountConfig struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be overkill.

Happy to create an ActivationAccountConfig if we want to keep each config distinct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is OK, just concerned what the PublicKeys [][]byte are for, as it is not clear what to use them for. Could we specify DeletePublicKeys and EnablePublicKeys and DisablePublicKeys ? Better to repeat ourselves and be more explicit with these config structs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also rename to AccountsConfig

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be clear @rauljordan, are you suggesting:

type AccountsConfig struct {
        Wallet     *wallet.Wallet
	Keymanager keymanager.IKeymanager
	DeletePublicKeys [][]byte
        EnablePublicKeys [][]byte
        DisablePublicKeys [][]byte
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep

validator/keymanager/imported/keymanager.go Outdated Show resolved Hide resolved
@@ -0,0 +1,289 @@
package accounts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename this file to accounts_enable_disable.go to align with the other files in the package

)

// AccountConfig specifies parameters to run to delete, enable, disable accounts.
type AccountConfig struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is OK, just concerned what the PublicKeys [][]byte are for, as it is not clear what to use them for. Could we specify DeletePublicKeys and EnablePublicKeys and DisablePublicKeys ? Better to repeat ourselves and be more explicit with these config structs

validator/accounts/accounts_activation.go Outdated Show resolved Hide resolved
"github.com/urfave/cli/v2"
)

func DisableAccountCli(cliCtx *cli.Context) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func DisableAccountCli(cliCtx *cli.Context) error {
func DisableAccountsCli(cliCtx *cli.Context) error {

)

// AccountConfig specifies parameters to run to delete, enable, disable accounts.
type AccountConfig struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also rename to AccountsConfig

validator/keymanager/imported/keymanager.go Outdated Show resolved Hide resolved
validator/keymanager/imported/keymanager.go Outdated Show resolved Hide resolved
@fabdarice fabdarice marked this pull request as ready for review November 11, 2020 19:39
@fabdarice fabdarice mentioned this pull request Nov 12, 2020
6 tasks
@@ -111,6 +113,7 @@ func NewKeymanager(ctx context.Context, cfg *SetupConfig) (*Keymanager, error) {
func NewInteropKeymanager(_ context.Context, offset, numValidatorKeys uint64) (*Keymanager, error) {
k := &Keymanager{
accountsChangedFeed: new(event.Feed),
opts: DefaultKeymanagerOpts(),
Copy link
Contributor Author

@fabdarice fabdarice Nov 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rauljordan this was the fix for E2E

@codecov
Copy link

codecov bot commented Nov 13, 2020

Codecov Report

Merging #7746 (1c2077d) into master (5fdb916) will decrease coverage by 0.14%.
The diff coverage is 45.81%.

@@            Coverage Diff             @@
##           master    #7746      +/-   ##
==========================================
- Coverage   62.09%   61.95%   -0.15%     
==========================================
  Files         431      432       +1     
  Lines       30451    30683     +232     
==========================================
+ Hits        18909    19010     +101     
- Misses       8601     8707     +106     
- Partials     2941     2966      +25     

formattedPubKeys[i] = fmt.Sprintf("%#x", bytesutil.Trunc(pubKeyBytes))
}
allAccountStr := strings.Join(formattedPubKeys, ", ")
if !cliCtx.IsSet(flags.DisablePublicKeysFlag.Name) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch.. strange, I did manually test with the flag too lol.

rauljordan
rauljordan previously approved these changes Nov 13, 2020
"github.com/urfave/cli/v2"
)

func DisableAccountsCli(cliCtx *cli.Context) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Godoc happy with these exported functions w/o functional comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added docstring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable/Disable Validator Keys
3 participants