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 issues with dynamic key reload for imported/derived keymanager #8585

Merged
merged 21 commits into from
Mar 12, 2021

Conversation

rkapka
Copy link
Contributor

@rkapka rkapka commented Mar 10, 2021

What type of PR is this?

Bug fix

What does this PR do? Why is it needed?

Makes all scenarios outlined in https://docs.google.com/document/d/1fLdUi6AHQ5-wYOy6DCzW5JlLlq3VuI275-KoyEZ2Pmw/edit#heading=h.m87ybthlvflh work correctly.

High-level overview:

I added a new case in the runner, where I listen to account changes via a channel. After such changes occur, I handle key reload by logging out statuses and returning if any keys are active. If there are no active keys after the reload, I call WaitForActivation passing the channel as a way of reacting to reload inside the function. Note that the call to WaitForActivation, which happens before the main loop, does not need an external channel, so it manages its own when nil is passed in.

I defined a validatorStatus struct abstraction to be able to log out statuses from both WaitForValidation and HandleKeyReload.

The PR also fixes a bug in validator/keymanager/imported/refresh.go. Currently the event publishes old keys instead of new ones.

Which issues(s) does this PR fix?

Part of #8572
Fixes #8577

Other notes for review

N/A

@rkapka rkapka requested a review from a team as a code owner March 10, 2021 13:53
@rkapka
Copy link
Contributor Author

rkapka commented Mar 10, 2021

I would like a review from @prestonvanloon and @rauljordan before merging this.

@rkapka rkapka marked this pull request as draft March 10, 2021 18:34
rkapka added 5 commits March 11, 2021 11:21
# Conflicts:
#	validator/accounts/testutil/mock_validator.go
#	validator/client/BUILD.bazel
#	validator/client/mock_validator.go
#	validator/client/runner.go
#	validator/client/runner_test.go
#	validator/client/testutil/mock_validator.go
#	validator/client/validator.go
# Conflicts:
#	validator/client/BUILD.bazel
#	validator/client/iface/validator.go
#	validator/client/testutil/BUILD.bazel
#	validator/client/testutil/mock_validator.go
@rkapka rkapka marked this pull request as ready for review March 11, 2021 12:11
@@ -75,7 +75,7 @@ func run(ctx context.Context, v iface.Validator) {
if err != nil {
log.Fatalf("Could not determine if beacon node synced: %v", err)
}
err = v.WaitForActivation(ctx)
err = v.WaitForActivation(ctx, nil)
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 a little weird without context, I would recommend a comment like
nil /* something something */

sub := v.GetKeymanager().SubscribeAccountChanges(accountsChangedChan)
defer func() {
sub.Unsubscribe()
close(accountsChangedChan)
Copy link
Contributor

Choose a reason for hiding this comment

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

This defer will close the channel by the time it makes it into v.waitForActivation. Is this intended behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The function will not return until waitForActivation completes, so the channel will not get closed. This PR only adds an if statement, so it wouldn't have worked in the first place.

Copy link
Contributor

Choose a reason for hiding this comment

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

You are totally right

@prylabs-bulldozer prylabs-bulldozer bot merged commit dc6dee3 into develop Mar 12, 2021
@delete-merged-branch delete-merged-branch bot deleted the key-reload-fixes branch March 12, 2021 17:24
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.

Validator client generates errors if it had validators but they all exit
2 participants