-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
# Conflicts: # validator/keymanager/imported/enable_disable_test.go
I would like a review from @prestonvanloon and @rauljordan before merging this. |
# 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
validator/client/runner.go
Outdated
@@ -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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are totally right
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 toWaitForActivation
, which happens before the main loop, does not need an external channel, so it manages its own whennil
is passed in.I defined a
validatorStatus
struct abstraction to be able to log out statuses from bothWaitForValidation
andHandleKeyReload
.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