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

Dynamic key reload for remote keymanager #8611

Merged
merged 8 commits into from
Mar 16, 2021
Merged

Conversation

rkapka
Copy link
Contributor

@rkapka rkapka commented Mar 16, 2021

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 the case <-accountsChangedChan because there is no external trigger which notifies about key changes, as is the case with other keymanager types.

@rkapka rkapka requested a review from a team as a code owner March 16, 2021 10:31
@@ -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)
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 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)
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 change is required to prevent a deadlock.

Comment on lines +92 to +93
remoteKm, ok := v.keyManager.(remote.RemoteKeymanager)
if ok {
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 diff here looks like a mess, but I basically moved all existing code into the else branch and implemented the if branch.

Copy link
Contributor

@rauljordan rauljordan 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, only change that seems scary was the buffered channel change. However, it seems it should have been buffered in the first place

@rauljordan rauljordan merged commit 1f8171d into develop Mar 16, 2021
@delete-merged-branch delete-merged-branch bot deleted the remote-key-reload branch March 16, 2021 15:00
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.

2 participants