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

go/runtime/host/multi: Support adding runtimes on the fly #5944

Merged
merged 5 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .changelog/5944.trivial.md
Empty file.
369 changes: 215 additions & 154 deletions go/runtime/host/multi/multi.go

Large diffs are not rendered by default.

433 changes: 433 additions & 0 deletions go/runtime/registry/handler.go

Large diffs are not rendered by default.

897 changes: 23 additions & 874 deletions go/runtime/registry/host.go

Large diffs are not rendered by default.

431 changes: 431 additions & 0 deletions go/runtime/registry/notifier.go

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions go/worker/common/committee/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,10 @@ func (n *Node) updateHostedRuntimeVersionLocked() {

// Update the runtime version based on the currently active deployment.
activeDeploy := n.CurrentDescriptor.ActiveDeployment(epoch)
// NOTE: If there is no active deployment this will activate the all-zero version which may
// result in the runtime stopping.
var activeVersion version.Version
var activeVersion *version.Version
if activeDeploy != nil {
activeVersion = activeDeploy.Version
activeVersion = new(version.Version)
*activeVersion = activeDeploy.Version
}

// For compute nodes, determine if there is a next version and activate it early.
Expand All @@ -444,7 +443,9 @@ func (n *Node) updateHostedRuntimeVersionLocked() {
}
}

if err := n.SetHostedRuntimeVersion(activeVersion, nextVersion); err != nil {
_ = n.SetHostedRuntimeVersion(activeVersion, nextVersion)

if _, err := n.GetHostedRuntimeActiveVersion(); err != nil {
n.logger.Error("failed to activate runtime version(s)",
"err", err,
"version", activeVersion,
Expand Down Expand Up @@ -680,7 +681,7 @@ func (n *Node) worker() {
defer blocksSub.Close()

// Provision the hosted runtime.
hrt, hrtNotifier, err := n.ProvisionHostedRuntime(n.ctx)
hrt, hrtNotifier, err := n.ProvisionHostedRuntime()
if err != nil {
n.logger.Error("failed to provision hosted runtime",
"err", err,
Expand Down
5 changes: 2 additions & 3 deletions go/worker/common/committee/runtime_host.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package committee

import (
"context"
"fmt"

"github.com/oasisprotocol/oasis-core/go/common/identity"
Expand All @@ -19,8 +18,8 @@ func (n *Node) GetRuntime() runtimeRegistry.Runtime {
}

// NewRuntimeHostNotifier implements RuntimeHostHandlerFactory.
func (n *Node) NewRuntimeHostNotifier(ctx context.Context, host host.Runtime) protocol.Notifier {
return runtimeRegistry.NewRuntimeHostNotifier(ctx, n.Runtime, host, n.Consensus)
func (n *Node) NewRuntimeHostNotifier(host host.Runtime) protocol.Notifier {
return runtimeRegistry.NewRuntimeHostNotifier(n.Runtime, host, n.Consensus)
}

type nodeEnvironment struct {
Expand Down
5 changes: 2 additions & 3 deletions go/worker/keymanager/handler.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package keymanager

import (
"context"
"fmt"

"github.com/oasisprotocol/oasis-core/go/common/identity"
Expand All @@ -20,8 +19,8 @@ func (w *Worker) GetRuntime() runtimeRegistry.Runtime {
}

// NewRuntimeHostNotifier implements workerCommon.RuntimeHostHandlerFactory.
func (w *Worker) NewRuntimeHostNotifier(ctx context.Context, host host.Runtime) protocol.Notifier {
return runtimeRegistry.NewRuntimeHostNotifier(ctx, w.runtime, host, w.commonWorker.Consensus)
func (w *Worker) NewRuntimeHostNotifier(host host.Runtime) protocol.Notifier {
return runtimeRegistry.NewRuntimeHostNotifier(w.runtime, host, w.commonWorker.Consensus)
}

type workerEnvironment struct {
Expand Down
6 changes: 4 additions & 2 deletions go/worker/keymanager/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func (w *Worker) worker() {
// Provision the hosted runtime.
w.logger.Info("provisioning key manager runtime")

hrt, hrtNotifier, err := w.ProvisionHostedRuntime(w.ctx)
hrt, hrtNotifier, err := w.ProvisionHostedRuntime()
if err != nil {
w.logger.Error("failed to provision key manager runtime",
"err", err,
Expand All @@ -406,7 +406,9 @@ func (w *Worker) worker() {
// Key managers always need to use the enclave version given to them in the bundle
// as they need to make sure that replication is possible during upgrades.
activeVersion := w.runtime.HostVersions()[0] // Init made sure we have exactly one.
if err = w.SetHostedRuntimeVersion(activeVersion, nil); err != nil {
_ = w.SetHostedRuntimeVersion(&activeVersion, nil)

if _, err := w.GetHostedRuntimeActiveVersion(); err != nil {
w.logger.Error("failed to activate key manager runtime version",
"err", err,
"version", activeVersion,
Expand Down
Loading