common

package
v0.2011.3 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RuntimeProvisionerMock is the name of the mock runtime provisioner.
	//
	// Use of this provisioner is only allowed if DebugDontBlameOasis flag is set.
	RuntimeProvisionerMock = "mock"
	// RuntimeProvisionerUnconfined is the name of the unconfined runtime provisioner that executes
	// runtimes as regular processes without any sandboxing.
	//
	// Use of this provisioner is only allowed if DebugDontBlameOasis flag is set.
	RuntimeProvisionerUnconfined = "unconfined"
	// RuntimeProvisionerSandboxed is the name of the sandboxed runtime provisioner that executes
	// runtimes as regular processes in a Linux namespaces/cgroups/SECCOMP sandbox.
	RuntimeProvisionerSandboxed = "sandboxed"
)

Variables

View Source
var (
	// CfgClientPort configures the worker client port.
	CfgClientPort = "worker.client.port"

	// CfgSentryAddresses configures addresses and public keys of sentry nodes the worker should
	// connect to.
	CfgSentryAddresses = "worker.sentry.address"

	// CfgRuntimeProvisioner configures the runtime provisioner.
	CfgRuntimeProvisioner = "worker.runtime.provisioner"
	// CfgRuntimeSGXLoader configures the runtime loader binary required for SGX runtimes. A single
	// loader is used for all runtimes.
	CfgRuntimeSGXLoader = "worker.runtime.sgx.loader"
	// CfgRuntimePaths confgures the paths for supported runtimes. The value should be a map of
	// runtime IDs to corresponding resource paths (type of the resource depends on the
	// provisioner).
	CfgRuntimePaths = "worker.runtime.paths"
	// CfgRuntimeSGXSignatures configures signatures for supported runtimes.
	// The value should be a map of runtime IDs to corresponding resource
	// paths.
	CfgRuntimeSGXSignatures = "worker.runtime.sgx.signatures"

	// Flags has the configuration flags.
	Flags = flag.NewFlagSet("", flag.ContinueOnError)
)

Functions

This section is empty.

Types

type Config

type Config struct {
	ClientPort      uint16
	ClientAddresses []node.Address
	SentryAddresses []node.TLSAddress

	// RuntimeHost contains configuration for a worker that hosts runtimes. It may be nil if the
	// worker is not configured to host runtimes.
	RuntimeHost *RuntimeHostConfig

	StorageCommitTimeout time.Duration
	// contains filtered or unexported fields
}

Config contains common worker config.

func NewConfig

func NewConfig(ias ias.Endpoint) (*Config, error)

NewConfig creates a new worker config.

func (*Config) GetNodeAddresses

func (c *Config) GetNodeAddresses() ([]node.Address, error)

GetNodeAddresses returns worker node addresses.

type RuntimeHostConfig

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]runtimeHost.Config
}

RuntimeHostConfig is configuration for a worker that hosts runtimes.

type RuntimeHostHandlerFactory

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

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

	// NewNotifier creates a new runtime host notifier.
	NewNotifier(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

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

RuntimeHostNode provides methods for nodes that need to host runtimes.

func NewRuntimeHostNode

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

NewRuntimeHostNode creates a new runtime host node.

func (*RuntimeHostNode) GetHostedRuntime

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

GetHostedRuntime returns the provisioned hosted runtime (if any).

func (*RuntimeHostNode) ProvisionHostedRuntime

func (n *RuntimeHostNode) ProvisionHostedRuntime(ctx context.Context) (host.Runtime, 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.

type Worker

type Worker struct {
	Identity          *identity.Identity
	Consensus         consensus.Backend
	Grpc              *grpc.Server
	GrpcPolicyWatcher policyAPI.PolicyWatcher
	P2P               *p2p.P2P
	IAS               ias.Endpoint
	KeyManager        keymanagerApi.Backend
	RuntimeRegistry   runtimeRegistry.Registry
	GenesisDoc        *genesis.Document
	// contains filtered or unexported fields
}

Worker is a garbage bag with lower level services and common runtime objects.

func New

func New(
	dataDir string,
	enabled bool,
	identity *identity.Identity,
	consensus consensus.Backend,
	p2p *p2p.P2P,
	ias ias.Endpoint,
	keyManager keymanagerApi.Backend,
	runtimeRegistry runtimeRegistry.Registry,
	genesisDoc *genesis.Document,
) (*Worker, error)

New creates a new worker.

func (*Worker) Cleanup

func (w *Worker) Cleanup()

Cleanup performs the service specific post-termination cleanup.

func (*Worker) Enabled

func (w *Worker) Enabled() bool

Enabled returns if worker is enabled.

func (*Worker) GetConfig

func (w *Worker) GetConfig() Config

GetConfig returns the worker's configuration.

func (*Worker) GetRuntime

func (w *Worker) GetRuntime(id common.Namespace) *committee.Node

GetRuntime returns a common committee node for the given runtime (if available).

In case the runtime with the specified id was not configured for this node it returns nil.

func (*Worker) GetRuntimes

func (w *Worker) GetRuntimes() map[common.Namespace]*committee.Node

GetRuntimes returns a map of configured runtimes.

func (*Worker) Initialized

func (w *Worker) Initialized() <-chan struct{}

Initialized returns a channel that will be closed when the transaction scheduler is initialized and ready to service requests.

func (*Worker) Name

func (w *Worker) Name() string

Name returns the service name.

func (*Worker) NewUnmanagedCommitteeNode

func (w *Worker) NewUnmanagedCommitteeNode(runtime runtimeRegistry.Runtime, enableP2P bool) (*committee.Node, error)

NewUnmanagedCommitteeNode creates a new common committee node that is not managed by this worker.

Since the node is unmanaged the caller needs to ensure that the node will be properly terminated once started.

Note that this does not instruct the storage backend to watch the given runtime.

func (*Worker) Quit

func (w *Worker) Quit() <-chan struct{}

Quit returns a channel that will be closed when the service terminates.

func (*Worker) Start

func (w *Worker) Start() error

Start starts the service.

func (*Worker) Stop

func (w *Worker) Stop()

Stop halts the service.

Directories

Path Synopsis
p2p
Package p2p implements the worker committee gossip network.
Package p2p implements the worker committee gossip network.
error
Package error exists only to break an import loop.
Package error exists only to break an import loop.

Jump to

Keyboard shortcuts

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