-
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
Dynamic key reload for remote keymanager #8611
Conversation
@@ -24,7 +25,7 @@ import ( | |||
func (v *validator) WaitForActivation(ctx context.Context, accountsChangedChan chan [][48]byte) error { | |||
// Monitor the key manager for updates. | |||
if accountsChangedChan == nil { | |||
accountsChangedChan = make(chan [][48]byte) | |||
accountsChangedChan = make(chan [][48]byte, 1) |
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 change is required to prevent a deadlock.
@@ -100,7 +100,7 @@ func run(ctx context.Context, v iface.Validator) { | |||
handleAssignmentError(err, headSlot) | |||
} | |||
|
|||
accountsChangedChan := make(chan [][48]byte) | |||
accountsChangedChan := make(chan [][48]byte, 1) |
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 change is required to prevent a deadlock.
remoteKm, ok := v.keyManager.(remote.RemoteKeymanager) | ||
if ok { |
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 diff here looks like a mess, but I basically moved all existing code into the else
branch and implemented the if
branch.
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.
Looks good, only change that seems scary was the buffered channel change. However, it seems it should have been buffered in the first place
What type of PR is this?
Feature
What does this PR do? Why is it needed?
Implements all scenarios for the remote keymanager outlined in https://docs.google.com/document/d/1fLdUi6AHQ5-wYOy6DCzW5JlLlq3VuI275-KoyEZ2Pmw/edit#heading=h.m87ybthlvflh. Because the keymanager does not have the ability to notify about key changes in real time, we check for new keys on every slot.
Which issues(s) does this PR fix?
Part of #8572
Other notes for review
I am not too happy about the type assertion and if/else branching inside
waitForActivation
, but I couldn't find a better way of handling the remote keymanager. We can't use thecase <-accountsChangedChan
because there is no external trigger which notifies about key changes, as is the case with other keymanager types.