execute

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Blockless Runtime flag names.
	BLSRuntimeFlagEntry         = "entry"
	BLSRuntimeFlagExecutionTime = "run-time"
	BLSRuntimeFlagDebug         = "debug-info"
	BLSRuntimeFlagFuel          = "limited-fuel"
	BLSRuntimeFlagMemory        = "limited-memory"
	BLSRuntimeFlagFSRoot        = "fs-root-path"
	BLSRuntimeFlagLogger        = "runtime-logger"
	BLSRuntimeFlagPermission    = "permission"
	BLSRuntimeFlagEnv           = "env"
	BLSRuntimeFlagDrivers       = "drivers-root-path"
)
View Source
const (
	BLSDefaultRuntimeEntryPoint = "_start"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AttributeAttestors

type AttributeAttestors struct {
	// Each of the listed attestors should be found.
	Each []peer.ID `json:"each,omitempty"`

	// Any one of these attestors should be found.
	OneOf []peer.ID `json:"one_of,omitempty"`
}

type Attributes

type Attributes struct {
	// Values specify which attributes the node in question should have.
	// At the moment we support strict equality only, so no `if RAM >= 16GB` types of conditions.
	Values []Parameter `json:"values,omitempty"`

	// Should we accept nodes whose attributes are not attested?
	AttestationRequired bool `json:"attestation_required,omitempty"`

	// Explicitly request specific attestors.
	Attestors AttributeAttestors `json:"attestors,omitempty"`
}

type BLSRuntimeConfig

type BLSRuntimeConfig struct {
	Entry           string `json:"entry,omitempty"`
	ExecutionTime   uint64 `json:"run_time,omitempty"`
	DebugInfo       bool   `json:"debug_info,omitempty"`
	Fuel            uint64 `json:"limited_fuel,omitempty"`
	Memory          uint64 `json:"limited_memory,omitempty"`
	Logger          string `json:"runtime_logger,omitempty"`
	DriversRootPath string `json:"drivers_root_path,omitempty"`
	// Fields not allowed to be set in the request.
	Input  string `json:"-"`
	FSRoot string `json:"-"`
}

RuntimeConfig represents the CLI flags supported by the runtime

type Cluster

type Cluster struct {
	Main  peer.ID   `json:"main,omitempty"`
	Peers []peer.ID `json:"peers,omitempty"`
}

Cluster represents the set of peers that executed the request.

type Config

type Config struct {
	Runtime           BLSRuntimeConfig  `json:"runtime,omitempty"`
	Environment       []EnvVar          `json:"env_vars,omitempty"`
	Stdin             *string           `json:"stdin,omitempty"`
	Permissions       []string          `json:"permissions,omitempty"`
	ResultAggregation ResultAggregation `json:"result_aggregation,omitempty"`

	Attributes *Attributes `json:"attributes,omitempty"`

	// NodeCount specifies how many nodes should execute this request.
	NodeCount int `json:"number_of_nodes,omitempty"`

	// When should the execution timeout
	Timeout int `json:"timeout,omitempty"`

	// Consensus algorithm to use. Raft and PBFT are supported at this moment.
	ConsensusAlgorithm string `json:"consensus_algorithm,omitempty"`

	// Threshold (percentage) defines how many nodes should respond with a result to consider this execution successful.
	Threshold float64 `json:"threshold,omitempty"`
}

Config represents the configurable options for an execution request.

type EnvVar

type EnvVar struct {
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
}

EnvVar represents the name and value of the environment variables set for the execution.

type Parameter

type Parameter struct {
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
}

Parameter represents an execution parameter, modeled as a key-value pair.

type ProcessID

type ProcessID struct {
	PID    int     // PID can used to identify a process on all platforms.
	Handle uintptr // windows.Handle value that can be used for Windows-specific operations.
}

ProcessID is used to identify an OS process.

type Request

type Request struct {
	FunctionID string      `json:"function_id"`
	Method     string      `json:"method"`
	Parameters []Parameter `json:"parameters,omitempty"`
	Config     Config      `json:"config"`

	// Optional signature of the request.
	Signature string `json:"signature,omitempty"`
}

Request describes an execution request.

func (*Request) Sign

func (e *Request) Sign(key crypto.PrivKey) error

func (Request) VerifySignature

func (e Request) VerifySignature(key crypto.PubKey) error

type Result

type Result struct {
	Code      codes.Code    `json:"code"`
	Result    RuntimeOutput `json:"result"`
	RequestID string        `json:"request_id"`
	Usage     Usage         `json:"usage,omitempty"`
}

Result describes an execution result.

type ResultAggregation

type ResultAggregation struct {
	Enable     bool        `json:"enable,omitempty"`
	Type       string      `json:"type,omitempty"`
	Parameters []Parameter `json:"parameters,omitempty"`
}

type ResultMap

type ResultMap map[peer.ID]Result

ResultMap contains execution results from multiple peers.

func (ResultMap) MarshalJSON

func (m ResultMap) MarshalJSON() ([]byte, error)

MarshalJSON provides means to correctly handle JSON serialization/deserialization. See:

https://github.com/libp2p/go-libp2p/pull/2156
https://github.com/libp2p/go-libp2p-resource-manager/pull/67#issuecomment-1176820561

type RuntimeOutput

type RuntimeOutput struct {
	Stdout   string `json:"stdout"`
	Stderr   string `json:"stderr"`
	ExitCode int    `json:"exit_code"`
	Log      string `json:"-"`
}

RuntimeOutput describes the output produced by the Blockless Runtime during execution.

type Usage

type Usage struct {
	WallClockTime time.Duration `json:"wall_clock_time,omitempty"`
	CPUUserTime   time.Duration `json:"cpu_user_time,omitempty"`
	CPUSysTime    time.Duration `json:"cpu_sys_time,omitempty"`
	MemoryMaxKB   int64         `json:"memory_max_kb,omitempty"`
}

Usage represents the resource usage information for a particular execution.

Jump to

Keyboard shortcuts

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