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

Fix validator activation monitoring with inactive keys #8558

Merged
merged 11 commits into from
Mar 5, 2021

Conversation

prestonvanloon
Copy link
Member

@prestonvanloon prestonvanloon commented Mar 4, 2021

What type of PR is this?

Bug fix

What does this PR do? Why is it needed?

When starting a Prysm validator, the client would monitor the beacon chain for activations of its public keys. If none of the keys are active, it will continue to monitor until one of the keys has been activated. One of the features of the validator is that the key manager is monitoring for new key additions. The bug was that the new key additions were not being included in the activation monitoring routine and would require a restart to pick up the changes.

Tested in pyrmont and saw the keys reloaded.

[2021-03-04 20:18:58]  INFO validator: Waiting for deposit to be observed by beacon node pubKey=0xb2511b2557bc status=UNKNOWN_STATUS
[2021-03-04 20:19:10]  INFO validator: Waiting for deposit to be observed by beacon node pubKey=0xb2511b2557bc status=UNKNOWN_STATUS
[2021-03-04 20:19:16]  INFO imported-keymanager: Reloaded validator keys into keymanager
[2021-03-04 20:19:22]  INFO validator: Waiting for deposit to be observed by beacon node pubKey=0xb2511b2557bc status=UNKNOWN_STATUS
[2021-03-04 20:19:22]  INFO validator: Waiting for deposit to be observed by beacon node pubKey=0x87f88acc6982 status=UNKNOWN_STATUS

Which issues(s) does this PR fix?

Fixes #8546

Other notes for review

Relevant doc: https://docs.google.com/document/d/1fLdUi6AHQ5-wYOy6DCzW5JlLlq3VuI275-KoyEZ2Pmw/edit#
This PR solves the following issues:

  • Inactive Add Active
  • Inactive Add Inactive

Some unrelated files are included due to goimports changes.

This PR also properly stops the SubscribeAccountChanges goroutine.

@prestonvanloon prestonvanloon requested review from rkapka and rauljordan and removed request for rkapka March 5, 2021 02:21
@prestonvanloon prestonvanloon marked this pull request as ready for review March 5, 2021 02:21
@prestonvanloon prestonvanloon requested a review from a team as a code owner March 5, 2021 02:21
@@ -129,3 +148,24 @@ func incrementRetries(ctx context.Context) context.Context {
attempts := streamAttempts(ctx)
return context.WithValue(ctx, waitForActivationAttemptsContextKey, attempts+1)
}

func handleAccountsChanged(ctx context.Context, v Validator, accountsChangedChan chan<- struct{}) {
Copy link
Member

Choose a reason for hiding this comment

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

This method seems redundant, its basically creates a channel to relay account changes to the accountsChangedChan . How about changing the accountsChangedChan type to a chan<- [][48]byte and then subscribe account changes to it directly ? You could skip this additional routine and channel being created here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Excellent feedback! Doing this now.

rkapka
rkapka previously approved these changes Mar 5, 2021
validator/client/wait_for_activation.go Outdated Show resolved Hide resolved
validator/client/wait_for_activation.go Outdated Show resolved Hide resolved
@rkapka rkapka self-requested a review March 5, 2021 08:21
@rkapka rkapka dismissed their stale review March 5, 2021 08:22

Doesn't make sense to approve and suggest changes.

rkapka
rkapka previously approved these changes Mar 5, 2021
@prestonvanloon prestonvanloon added Bug Something isn't working Priority: High High priority item labels Mar 5, 2021
@prestonvanloon prestonvanloon added this to the 1.3.x milestone Mar 5, 2021
rkapka
rkapka previously approved these changes Mar 5, 2021
@rkapka rkapka dismissed their stale review March 5, 2021 15:41

new insight

Copy link
Contributor

@rkapka rkapka left a comment

Choose a reason for hiding this comment

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

looks good

@prestonvanloon
Copy link
Member Author

Some feedback from @rkapka in discord is that we could refactor this further to remove the recursive functionality.
A stream could be restarted in the same method, without adding another recursive call to the stack.

This feature / refactoring will come in a future PR. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Priority: High High priority item
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Importing validators still requires restart to pick up newly-imported
3 participants