registry

package
v0.2300.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 47 Imported by: 1

Documentation

Overview

Package registry provides a registry of runtimes supported by the running oasis-node. It serves as a central point of runtime configuration.

Index

Constants

View Source
const (
	// MaxRuntimeCount is the maximum number of runtimes that can be supported
	// by a single node.
	MaxRuntimeCount = 64

	// LocalStorageFile is the filename of the worker's local storage database.
	LocalStorageFile = "worker-local-storage.badger.db"
)
View Source
const (
	// CfgDebugMockIDs configures mock runtime IDs for the purpose
	// of testing.
	CfgDebugMockIDs = "runtime.debug.mock_ids"
)
View Source
const (
	// RuntimesDir is the name of the directory located inside the node's data
	// directory which contains the per-runtime state.
	RuntimesDir = "runtimes"
)

Variables

View Source
var ErrRuntimeHostNotConfigured = errors.New("runtime/registry: runtime host not configured")

ErrRuntimeHostNotConfigured is the error returned when the runtime host is not configured for a specified runtime and a request is made to get the runtime host provisioner.

Flags has the configuration flags.

Functions

func EnsureRuntimeStateDir

func EnsureRuntimeStateDir(dataDir string, runtimeID common.Namespace) (string, error)

EnsureRuntimeStateDir ensures a specific per-runtime directory exists and returns its full path.

func GetRuntimeStateDir added in v0.2100.0

func GetRuntimeStateDir(dataDir string, runtimeID common.Namespace) string

func NewRuntimeHostHandler added in v0.2103.0

func NewRuntimeHostHandler(
	env RuntimeHostHandlerEnvironment,
	runtime Runtime,
	consensus consensus.Backend,
) protocol.Handler

NewRuntimeHostHandler returns a protocol handler that provides the required host methods for the runtime to interact with the outside world.

The passed identity may be nil.

func NewRuntimeHostNotifier added in v0.2103.0

func NewRuntimeHostNotifier(
	ctx context.Context,
	runtime Runtime,
	hostRt host.Runtime,
	consensus consensus.Backend,
) protocol.Notifier

NewRuntimeHostNotifier returns a protocol notifier that handles key manager policy updates.

func ParseRuntimeMap

func ParseRuntimeMap(rawItems []string) (map[common.Namespace]string, error)

ParseRuntimeMap parses strings in the format of <runtime-id>[:<value>] and returns them as a map of runtime IDs to value.

Types

type Registry

type Registry interface {
	// GetRuntime returns the per-runtime interface if the runtime is supported.
	GetRuntime(runtimeID common.Namespace) (Runtime, error)

	// Runtimes returns a list of all supported runtimes.
	Runtimes() []Runtime

	// NewUnmanagedRuntime creates a new runtime that is not managed by this
	// registry.
	NewUnmanagedRuntime(ctx context.Context, runtimeID common.Namespace) (Runtime, error)

	// AddRoles adds available node roles to the runtime. Specify nil as the runtimeID
	// to set the role for all runtimes.
	AddRoles(roles node.RolesMask, runtimeID *common.Namespace) error

	// Cleanup performs post-termination cleanup.
	Cleanup()

	// FinishInitialization finalizes setup for all runtimes.
	FinishInitialization() error
}

Registry is the running node's runtime registry interface.

func New

func New(ctx context.Context, dataDir string, commonStore *persistent.CommonStore, consensus consensus.Backend, ias []ias.Endpoint) (Registry, error)

New creates a new runtime registry.

type Runtime

type Runtime interface {
	// ID is the runtime identifier.
	ID() common.Namespace

	// DataDir returns the runtime-specific data directory.
	DataDir() string

	// RegistryDescriptor waits for the runtime to be registered and
	// then returns its registry descriptor.
	RegistryDescriptor(ctx context.Context) (*registry.Runtime, error)

	// WatchRegistryDescriptor subscribes to registry descriptor updates.
	WatchRegistryDescriptor() (<-chan *registry.Runtime, pubsub.ClosableSubscription, error)

	// ActiveDescriptor waits for runtime to be initialized and then returns
	// currently active runtime descriptor.
	ActiveDescriptor(ctx context.Context) (*registry.Runtime, error)

	// WatchActiveDescriptor subscribes to runtime active descriptor updates.
	WatchActiveDescriptor() (<-chan *registry.Runtime, pubsub.ClosableSubscription, error)

	// RegisterStorage sets the given local storage backend for the runtime.
	RegisterStorage(storage storageAPI.Backend)

	// AddRoles adds available node roles to the runtime.
	AddRoles(roles node.RolesMask)

	// HasRoles checks if the node has all of the roles specified for this runtime.
	HasRoles(roles node.RolesMask) bool

	// History returns the history for this runtime.
	History() history.History

	// Storage returns the per-runtime storage backend.
	Storage() storageAPI.Backend

	// LocalStorage returns the per-runtime local storage.
	LocalStorage() localstorage.LocalStorage

	// HasHost checks whether this runtime can be hosted by the current node.
	HasHost() bool

	// Host returns the runtime host configuration and provisioner if configured.
	//
	// If the runtime is not yet registered an error is returned. Use `RegistryDescriptor` to
	// wait for the runtime to be registered.
	Host() (map[version.Version]*runtimeHost.Config, runtimeHost.Provisioner, error)

	// HostVersions returns a list of supported runtime versions.
	HostVersions() []version.Version
}

Runtime is the running node's supported runtime interface.

type RuntimeConfig

type RuntimeConfig struct {
	// Host contains configuration for the runtime host. It may be nil if no runtimes are to be
	// hosted by the current node.
	Host *RuntimeHostConfig

	// History configures the runtime history keeper.
	History history.Config
}

RuntimeConfig is the node runtime configuration.

func (*RuntimeConfig) Runtimes added in v0.2200.0

func (cfg *RuntimeConfig) Runtimes() (runtimes []common.Namespace)

Runtimes returns a list of configured runtimes.

type RuntimeHostConfig added in v0.2100.0

type RuntimeHostConfig struct {
	// Provisioners contains a set of supported runtime provisioners, based on TEE hardware.
	Provisioners map[node.TEEHardware]runtimeHost.Provisioner

	// Runtimes contains per-runtime provisioning configuration. Some fields may be omitted as they
	// are provided when the runtime is provisioned.
	Runtimes map[common.Namespace]map[version.Version]*runtimeHost.Config
}

RuntimeHostConfig is configuration for a node that hosts runtimes.

type RuntimeHostHandlerEnvironment added in v0.2103.0

type RuntimeHostHandlerEnvironment interface {
	// GetKeyManagerClient returns the key manager client for this runtime.
	GetKeyManagerClient() (runtimeKeymanager.Client, error)

	// GetTxPool returns the transaction pool for this runtime.
	GetTxPool() (txpool.TransactionPool, error)

	// GetNodeIdentity returns the identity of a node running this runtime.
	GetNodeIdentity() (*identity.Identity, error)

	// GetLightClient returns the consensus light client.
	GetLightClient() (consensus.LightClient, error)
}

RuntimeHostHandlerEnvironment is the host environment interface.

type RuntimeHostHandlerFactory added in v0.2100.0

type RuntimeHostHandlerFactory interface {
	// GetRuntime returns the registered runtime for which a runtime host handler is to be created.
	GetRuntime() Runtime

	// NewRuntimeHostHandler creates a new runtime host handler.
	NewRuntimeHostHandler() protocol.Handler

	// NewRuntimeHostNotifier creates a new runtime host notifier.
	NewRuntimeHostNotifier(ctx context.Context, host host.Runtime) protocol.Notifier
}

RuntimeHostHandlerFactory is an interface that can be used to create new runtime handlers and notifiers when provisioning hosted runtimes.

type RuntimeHostNode added in v0.2100.0

type RuntimeHostNode struct {
	sync.Mutex
	// contains filtered or unexported fields
}

RuntimeHostNode provides methods for nodes that need to host runtimes.

func NewRuntimeHostNode added in v0.2100.0

func NewRuntimeHostNode(factory RuntimeHostHandlerFactory) (*RuntimeHostNode, error)

NewRuntimeHostNode creates a new runtime host node.

func (*RuntimeHostNode) GetHostedRuntime added in v0.2100.0

func (n *RuntimeHostNode) GetHostedRuntime() host.RichRuntime

GetHostedRuntime returns the provisioned hosted runtime (if any).

func (*RuntimeHostNode) GetHostedRuntimeCapabilityTEE added in v0.2300.0

func (n *RuntimeHostNode) GetHostedRuntimeCapabilityTEE(version version.Version) (*node.CapabilityTEE, error)

GetHostedRuntimeCapabilityTEE returns the CapabilityTEE for a specific runtime version.

func (*RuntimeHostNode) ProvisionHostedRuntime added in v0.2100.0

func (n *RuntimeHostNode) ProvisionHostedRuntime(ctx context.Context) (host.RichRuntime, protocol.Notifier, error)

ProvisionHostedRuntime provisions the configured runtime.

This method may return before the runtime is fully provisioned. The returned runtime will not be started automatically, you must call Start explicitly.

func (*RuntimeHostNode) SetHostedRuntimeVersion added in v0.2200.0

func (n *RuntimeHostNode) SetHostedRuntimeVersion(active version.Version, next *version.Version) error

SetHostedRuntimeVersion sets the currently active and next versions for the hosted runtime.

func (*RuntimeHostNode) WaitHostedRuntime added in v0.2103.0

func (n *RuntimeHostNode) WaitHostedRuntime(ctx context.Context) (host.RichRuntime, error)

WaitHostedRuntime waits for the hosted runtime to be provisioned and returns it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL