Documentation ¶
Overview ¶
Package protocol implements the Runtime Host Protocol.
Index ¶
- Constants
- Variables
- type Body
- type CheckTxMetadata
- type CheckTxResult
- type ComputedBatch
- type Connection
- type Empty
- type Error
- type Handler
- type HostInfo
- type HostLocalStorageGetRequest
- type HostLocalStorageGetResponse
- type HostLocalStorageSetRequest
- type HostRPCCallRequest
- type HostRPCCallResponse
- type HostStorageEndpoint
- type HostStorageSyncRequest
- type HostStorageSyncResponse
- type Message
- type MessageType
- type NoOpNotifier
- type Notifier
- type RuntimeCapabilityTEERakAvrRequest
- type RuntimeCapabilityTEERakInitRequest
- type RuntimeCapabilityTEERakReportResponse
- type RuntimeCheckTxBatchRequest
- type RuntimeCheckTxBatchResponse
- type RuntimeExecuteTxBatchRequest
- type RuntimeExecuteTxBatchResponse
- type RuntimeInfoRequest
- type RuntimeInfoResponse
- type RuntimeKeyManagerPolicyUpdateRequest
- type RuntimeLocalRPCCallRequest
- type RuntimeLocalRPCCallResponse
- type RuntimeQueryRequest
- type RuntimeQueryResponse
- type RuntimeRPCCallRequest
- type RuntimeRPCCallResponse
Constants ¶
const MethodQueryBatchWeightLimits = "internal.BatchWeightLimits"
MethodQueryBatchWeightLimits is the name of the runtime batch weight limits query method.
Variables ¶
var ( // ErrNotReady is the error reported when the Runtime Host Protocol is not initialized. ErrNotReady = errors.New(moduleName, 1, "rhp: not ready") )
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"` RuntimeQueryRequest *RuntimeQueryRequest `json:",omitempty"` RuntimeQueryResponse *RuntimeQueryResponse `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.
type CheckTxMetadata ¶ added in v0.2102.0
type CheckTxMetadata struct { // Priority is the transaction's priority. Priority uint64 `json:"priority,omitempty"` // Weight are runtime specific transaction weights. Weights map[transaction.Weight]uint64 `json:"weights,omitempty"` }
CheckTxMetadata is the transaction check-tx metadata.
type CheckTxResult ¶ added in v0.2100.0
type CheckTxResult struct { // Error is the error (if any) that resulted from the operation. Error Error `json:"error"` // Meta contains metadata that can be used for scheduling transactions by the scheduler. Meta *CheckTxMetadata `json:"meta,omitempty"` }
CheckTxResult contains the result of a CheckTx operation.
func (*CheckTxResult) IsSuccess ¶ added in v0.2100.0
func (r *CheckTxResult) IsSuccess() bool
IsSuccess returns true if transaction execution was successful.
func (*CheckTxResult) ToCheckedTransaction ¶ added in v0.2102.0
func (r *CheckTxResult) ToCheckedTransaction(rawTx []byte) *transaction.CheckedTransaction
ToCheckedTransaction creates CheckedTransaction from CheckTx result.
Assumes a successful result.
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"` // Messages are the emitted runtime messages. Messages []message.Message `json:"messages"` }
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, hi *HostInfo) (*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 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 HostInfo ¶ added in v0.2100.0
type HostInfo struct { // ConsensusBackend is the name of the consensus backend that is in use for the consensus layer. ConsensusBackend string // ConsensusProtocolVersion is the consensus protocol version that is in use for the consensus // layer. ConsensusProtocolVersion version.Version // ConsensusChainContext is the consensus layer chain domain separation context. ConsensusChainContext string // LocalConfig is the node-local runtime configuration. // // This configuration must not be used in any context which requires determinism across // replicated runtime instances. LocalConfig map[string]interface{} }
HostInfo contains the information about the host environment that is sent to the runtime during connection initialization.
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 ¶
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 HostStorageEndpoint ¶ added in v0.2100.0
type HostStorageEndpoint uint8
HostStorageEndpoint is the host storage endpoint.
const ( // HostStorageEndpointRuntime is the runtime state storage endpoint. HostStorageEndpointRuntime HostStorageEndpoint = 0 // HostStorageEndpointConsensus is the consensus layer state storage endpoint. HostStorageEndpointConsensus HostStorageEndpoint = 1 )
type HostStorageSyncRequest ¶
type HostStorageSyncRequest struct { // Endpoint is the storage endpoint to which this request should be routed. Endpoint HostStorageEndpoint `json:"endpoint,omitempty"` 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.
type Notifier ¶
type Notifier interface { // Start the notifier. Start() error // Stop the notifier. Stop() }
Notifier is a protocol runtime notifier interface.
type RuntimeCapabilityTEERakAvrRequest ¶
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 { // ConsensusBlock is the consensus light block at the last finalized round // height (e.g., corresponding to .Block.Header.Round). ConsensusBlock consensus.LightBlock `json:"consensus_block"` // Batch of runtime inputs to check. Inputs transaction.RawBatch `json:"inputs"` // Block on which the batch check should be based. Block block.Block `json:"block"` // Epoch is the current epoch number. Epoch beacon.EpochTime `json:"epoch"` }
RuntimeCheckTxBatchRequest is a worker check tx batch request message body.
type RuntimeCheckTxBatchResponse ¶
type RuntimeCheckTxBatchResponse struct { // Batch of CheckTx results corresponding to transactions passed on input. Results []CheckTxResult `json:"results"` }
RuntimeCheckTxBatchResponse is a worker check tx batch response message body.
type RuntimeExecuteTxBatchRequest ¶
type RuntimeExecuteTxBatchRequest struct { // ConsensusBlock is the consensus light block at the last finalized round // height (e.g., corresponding to .Block.Header.Round). ConsensusBlock consensus.LightBlock `json:"consensus_block"` // RoundResults are the results of executing the previous successful round. RoundResults *roothash.RoundResults `json:"round_results"` // 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 block.Block `json:"block"` // Epoch is the current epoch number. Epoch beacon.EpochTime `json:"epoch"` // MaxMessages is the maximum number of messages that can be emitted in this // round. Any more messages will be rejected by the consensus layer. MaxMessages uint32 `json:"max_messages"` }
RuntimeExecuteTxBatchRequest is a worker execute tx batch request message body.
type RuntimeExecuteTxBatchResponse ¶
type RuntimeExecuteTxBatchResponse struct { Batch ComputedBatch `json:"batch"` BatchWeightLimits map[transaction.Weight]uint64 `json:"batch_weight_limits"` }
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"` // ConsensusBackend is the name of the consensus backend that is in use for the consensus layer. ConsensusBackend string `json:"consensus_backend"` // ConsensusProtocolVersion is the consensus protocol version that is in use for the consensus // layer. ConsensusProtocolVersion version.Version `json:"consensus_protocol_version"` // ConsensusChainContext is the consensus layer chain domain separation context. ConsensusChainContext string `json:"consensus_chain_context"` // LocalConfig is the node-local runtime configuration. // // This configuration must not be used in any context which requires determinism across // replicated runtime instances. LocalConfig map[string]interface{} `json:"local_config,omitempty"` }
RuntimeInfoRequest is a worker info request message body.
type RuntimeInfoResponse ¶
type RuntimeInfoResponse struct { // ProtocolVersion is the runtime protocol version supported by the worker. ProtocolVersion version.Version `json:"protocol_version"` // RuntimeVersion is the version of the runtime. RuntimeVersion version.Version `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 RuntimeQueryRequest ¶ added in v0.2100.0
type RuntimeQueryRequest struct { // ConsensusBlock is the consensus light block at the last finalized round // height (e.g., corresponding to .Header.Round). ConsensusBlock consensus.LightBlock `json:"consensus_block"` // Header is the current block header. Header block.Header `json:"header"` // Epoch is the current epoch number. Epoch beacon.EpochTime `json:"epoch"` Method string `json:"method"` Args cbor.RawMessage `json:"args,omitempty"` }
RuntimeQueryRequest is a runtime query request message body.
type RuntimeQueryResponse ¶ added in v0.2100.0
type RuntimeQueryResponse struct {
Data cbor.RawMessage `json:"data,omitempty"`
}
RuntimeQueryRequest is a runtime query 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.