protocol

package
v0.2012.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package protocol implements the Runtime Host Protocol.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotReady = errors.New(moduleName, 1, "rhp: not ready")
)

ErrNotReady is the error reported when the Runtime Host Protocol is not initialized.

Functions

This section is empty.

Types

type Body

type Body struct {
	Empty *Empty `json:",omitempty"`
	Error *Error `json:",omitempty"`

	// Runtime interface.
	RuntimeInfoRequest                    *RuntimeInfoRequest                    `json:",omitempty"`
	RuntimeInfoResponse                   *RuntimeInfoResponse                   `json:",omitempty"`
	RuntimePingRequest                    *Empty                                 `json:",omitempty"`
	RuntimeShutdownRequest                *Empty                                 `json:",omitempty"`
	RuntimeCapabilityTEERakInitRequest    *RuntimeCapabilityTEERakInitRequest    `json:",omitempty"`
	RuntimeCapabilityTEERakInitResponse   *Empty                                 `json:",omitempty"`
	RuntimeCapabilityTEERakReportRequest  *Empty                                 `json:",omitempty"`
	RuntimeCapabilityTEERakReportResponse *RuntimeCapabilityTEERakReportResponse `json:",omitempty"`
	RuntimeCapabilityTEERakAvrRequest     *RuntimeCapabilityTEERakAvrRequest     `json:",omitempty"`
	RuntimeCapabilityTEERakAvrResponse    *Empty                                 `json:",omitempty"`
	RuntimeRPCCallRequest                 *RuntimeRPCCallRequest                 `json:",omitempty"`
	RuntimeRPCCallResponse                *RuntimeRPCCallResponse                `json:",omitempty"`
	RuntimeLocalRPCCallRequest            *RuntimeLocalRPCCallRequest            `json:",omitempty"`
	RuntimeLocalRPCCallResponse           *RuntimeLocalRPCCallResponse           `json:",omitempty"`
	RuntimeCheckTxBatchRequest            *RuntimeCheckTxBatchRequest            `json:",omitempty"`
	RuntimeCheckTxBatchResponse           *RuntimeCheckTxBatchResponse           `json:",omitempty"`
	RuntimeExecuteTxBatchRequest          *RuntimeExecuteTxBatchRequest          `json:",omitempty"`
	RuntimeExecuteTxBatchResponse         *RuntimeExecuteTxBatchResponse         `json:",omitempty"`
	RuntimeAbortRequest                   *Empty                                 `json:",omitempty"`
	RuntimeAbortResponse                  *Empty                                 `json:",omitempty"`
	RuntimeKeyManagerPolicyUpdateRequest  *RuntimeKeyManagerPolicyUpdateRequest  `json:",omitempty"`
	RuntimeKeyManagerPolicyUpdateResponse *Empty                                 `json:",omitempty"`

	// Host interface.
	HostRPCCallRequest          *HostRPCCallRequest          `json:",omitempty"`
	HostRPCCallResponse         *HostRPCCallResponse         `json:",omitempty"`
	HostStorageSyncRequest      *HostStorageSyncRequest      `json:",omitempty"`
	HostStorageSyncResponse     *HostStorageSyncResponse     `json:",omitempty"`
	HostLocalStorageGetRequest  *HostLocalStorageGetRequest  `json:",omitempty"`
	HostLocalStorageGetResponse *HostLocalStorageGetResponse `json:",omitempty"`
	HostLocalStorageSetRequest  *HostLocalStorageSetRequest  `json:",omitempty"`
	HostLocalStorageSetResponse *Empty                       `json:",omitempty"`
}

Body is a protocol message body.

func (Body) Type

func (body Body) Type() string

Type returns the message type by determining the name of the first non-nil member.

type ComputedBatch

type ComputedBatch struct {
	// Header is the compute results header.
	Header commitment.ComputeResultsHeader `json:"header"`
	// Log that generates the I/O tree.
	IOWriteLog storage.WriteLog `json:"io_write_log"`
	// Batch of storage write operations.
	StateWriteLog storage.WriteLog `json:"state_write_log"`
	// If this runtime uses a TEE, then this is the signature of Header with
	// node's RAK for this runtime.
	RakSig signature.RawSignature `json:"rak_sig"`
}

ComputedBatch is a computed batch.

func (*ComputedBatch) String

func (b *ComputedBatch) String() string

String returns a string representation of a computed batch.

type Connection

type Connection interface {
	// Close closes the connection.
	Close()

	// Call sends a request to the other side and returns the response or error.
	Call(ctx context.Context, body *Body) (*Body, error)

	// InitHost performs initialization in host mode and transitions the connection to Ready state.
	//
	// This method must be called before the host will answer requests.
	//
	// Only one of InitHost/InitGuest can be called otherwise the method may panic.
	//
	// Returns the self-reported runtime version.
	InitHost(ctx context.Context, conn net.Conn) (*version.Version, error)

	// InitGuest performs initialization in guest mode and transitions the connection to Ready
	// state.
	//
	// Only one of InitHost/InitGuest can be called otherwise the method may panic.
	InitGuest(ctx context.Context, conn net.Conn) error
}

Connection is a Runtime Host Protocol connection interface.

func NewConnection

func NewConnection(logger *logging.Logger, runtimeID common.Namespace, handler Handler) (Connection, error)

NewConnection creates a new uninitialized RHP connection.

type Empty

type Empty struct {
}

Empty is an empty message body.

type Error

type Error struct {
	Module  string `json:"module,omitempty"`
	Code    uint32 `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

Error is a message body representing an error.

type Handler

type Handler interface {
	// Handle given request and return a response.
	Handle(ctx context.Context, body *Body) (*Body, error)
}

Handler is a protocol message handler interface.

type HostLocalStorageGetRequest

type HostLocalStorageGetRequest struct {
	Key []byte `json:"key"`
}

HostLocalStorageGetRequest is a host local storage get request message body.

type HostLocalStorageGetResponse

type HostLocalStorageGetResponse struct {
	Value []byte `json:"value"`
}

HostLocalStorageGetResponse is a host local storage get response message body.

type HostLocalStorageSetRequest

type HostLocalStorageSetRequest struct {
	Key   []byte `json:"key"`
	Value []byte `json:"value"`
}

HostLocalStorageSetRequest is a host local storage set request message body.

type HostRPCCallRequest

type HostRPCCallRequest struct {
	Endpoint string `json:"endpoint"`
	Request  []byte `json:"request"`
}

HostRPCCallRequest is a host RPC call request message body.

type HostRPCCallResponse

type HostRPCCallResponse struct {
	Response []byte `json:"response"`
}

HostRPCCallResponse is a host RPC call response message body.

type HostStorageSyncRequest

type HostStorageSyncRequest struct {
	SyncGet         *storage.GetRequest         `json:",omitempty"`
	SyncGetPrefixes *storage.GetPrefixesRequest `json:",omitempty"`
	SyncIterate     *storage.IterateRequest     `json:",omitempty"`
}

HostStorageSyncRequest is a host storage read syncer request message body.

type HostStorageSyncResponse

type HostStorageSyncResponse struct {
	ProofResponse *storage.ProofResponse `json:",omitempty"`
}

HostStorageSyncResponse is a host storage read syncer response body.

type Message

type Message struct {
	ID          uint64      `json:"id"`
	MessageType MessageType `json:"message_type"`
	Body        Body        `json:"body"`
	SpanContext []byte      `json:"span_context"`
}

Message is a protocol message.

type MessageType

type MessageType uint8

MessageType is a message type.

const (
	// Invalid message (should never be seen on the wire).
	MessageInvalid MessageType = 0

	// Request message.
	MessageRequest MessageType = 1

	// Response message.
	MessageResponse MessageType = 2
)

func (MessageType) String

func (m MessageType) String() string

String returns a string representation of a message type.

type NoOpNotifier

type NoOpNotifier struct {
}

NoOpNotifier is the default no-op runtime notifier implementation.

func (*NoOpNotifier) Start

func (n *NoOpNotifier) Start() error

Start the no-op notifier.

func (*NoOpNotifier) Stop

func (n *NoOpNotifier) Stop()

Stop the no-op notifier.

type Notifier

type Notifier interface {
	// Start the notifier.
	Start() error

	// Stop the notifier.
	Stop()
}

Notifier is a protocol runtime notifier interface.

type RuntimeCapabilityTEERakAvrRequest

type RuntimeCapabilityTEERakAvrRequest struct {
	AVR ias.AVRBundle `json:"avr"`
}

RuntimeCapabilityTEERakAvrRequest is a worker RFC 0009 CapabilityTEE RAK AVR setup request message body.

type RuntimeCapabilityTEERakInitRequest

type RuntimeCapabilityTEERakInitRequest struct {
	TargetInfo []byte `json:"target_info"`
}

RuntimeCapabilityTEERakInitRequest is a worker RFC 0009 CapabilityTEE initialization request message body.

type RuntimeCapabilityTEERakReportResponse

type RuntimeCapabilityTEERakReportResponse struct {
	RakPub signature.PublicKey `json:"rak_pub"`
	Report []byte              `json:"report"`
	Nonce  string              `json:"nonce"`
}

RuntimeCapabilityTEERakReportResponse is a worker RFC 0009 CapabilityTEE RAK response message body.

type RuntimeCheckTxBatchRequest

type RuntimeCheckTxBatchRequest struct {
	// Batch of runtime inputs to check.
	Inputs transaction.RawBatch `json:"inputs"`
	// Block on which the batch check should be based.
	Block roothash.Block `json:"block"`
}

RuntimeCheckTxBatchRequest is a worker check tx batch request message body.

type RuntimeCheckTxBatchResponse

type RuntimeCheckTxBatchResponse struct {
	// Batch of runtime check results.
	Results transaction.RawBatch `json:"results"`
}

RuntimeCheckTxBatchResponse is a worker check tx batch response message body.

type RuntimeExecuteTxBatchRequest

type RuntimeExecuteTxBatchRequest struct {
	// IORoot is the I/O root containing the inputs (transactions) that
	// the compute node should use. It must match what is passed in "inputs".
	IORoot hash.Hash `json:"io_root"`
	// Batch of inputs (transactions).
	Inputs transaction.RawBatch `json:"inputs"`
	// Block on which the batch computation should be based.
	Block roothash.Block `json:"block"`
}

RuntimeExecuteTxBatchRequest is a worker execute tx batch request message body.

type RuntimeExecuteTxBatchResponse

type RuntimeExecuteTxBatchResponse struct {
	Batch ComputedBatch `json:"batch"`
}

RuntimeExecuteTxBatchResponse is a worker execute tx batch response message body.

type RuntimeInfoRequest

type RuntimeInfoRequest struct {
	// RuntimeID is the assigned runtime ID of the loaded runtime.
	RuntimeID common.Namespace `json:"runtime_id"`
}

RuntimeInfoRequest is a worker info request message body.

type RuntimeInfoResponse

type RuntimeInfoResponse struct {
	// ProtocolVersion is the runtime protocol version supported by the worker.
	ProtocolVersion uint64 `json:"protocol_version"`

	// RuntimeVersion is the version of the runtime.
	RuntimeVersion uint64 `json:"runtime_version"`
}

RuntimeInfoResponse is a worker info response message body.

type RuntimeKeyManagerPolicyUpdateRequest

type RuntimeKeyManagerPolicyUpdateRequest struct {
	SignedPolicyRaw []byte `json:"signed_policy_raw"`
}

RuntimeKeyManagerPolicyUpdateRequest is a runtime key manager policy request message body.

type RuntimeLocalRPCCallRequest

type RuntimeLocalRPCCallRequest struct {
	// Request.
	Request []byte `json:"request"`
}

RuntimeLocalRPCCallRequest is a worker local RPC call request message body.

type RuntimeLocalRPCCallResponse

type RuntimeLocalRPCCallResponse struct {
	// Response.
	Response []byte `json:"response"`
}

RuntimeLocalRPCCallResponse is a worker local RPC call response message body.

type RuntimeRPCCallRequest

type RuntimeRPCCallRequest struct {
	// Request.
	Request []byte `json:"request"`
}

RuntimeRPCCallRequest is a worker RPC call request message body.

type RuntimeRPCCallResponse

type RuntimeRPCCallResponse struct {
	// Response.
	Response []byte `json:"response"`
}

RuntimeRPCCallResponse is a worker RPC call response message body.

Jump to

Keyboard shortcuts

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