Documentation
¶
Index ¶
- Constants
- Variables
- func RegisterModuleFactory(name string, factory ModuleFactory)
- func WithContext(ctx context.Context, call *Call) context.Context
- type Argument
- type BaseArgument
- type Call
- func (c *Call) AppendLog(message string)
- func (c *Call) CanSkipOutput() bool
- func (c *Call) DoAddBigDecimal(ord uint64, key string, value string)
- func (c *Call) DoAddBigInt(ord uint64, key string, value string)
- func (c *Call) DoAddFloat64(ord uint64, key string, value float64)
- func (c *Call) DoAddInt64(ord uint64, key string, value int64)
- func (c *Call) DoAppend(ord uint64, key string, value []byte)
- func (c *Call) DoDeletePrefix(ord uint64, prefix string)
- func (c *Call) DoFoundationalStoreGet(index uint32, keys *pbmodel.Keys) *pbmodel.QueriedEntries
- func (c *Call) DoFoundationalStoreGetFirst(index uint32, keys *pbmodel.Keys) *pbmodel.QueriedEntries
- func (c *Call) DoGetAt(storeIndex int, ord uint64, key string) (value []byte, found bool)
- func (c *Call) DoGetFirst(storeIndex int, key string) (value []byte, found bool)
- func (c *Call) DoGetLast(storeIndex int, key string) (value []byte, found bool)
- func (c *Call) DoHasAt(storeIndex int, ord uint64, key string) (found bool)
- func (c *Call) DoHasFirst(storeIndex int, key string) (found bool)
- func (c *Call) DoHasLast(storeIndex int, key string) (found bool)
- func (c *Call) DoSet(ord uint64, key string, value []byte)
- func (c *Call) DoSetIfNotExists(ord uint64, key string, value []byte)
- func (c *Call) DoSetMaxBigDecimal(ord uint64, key string, value string)
- func (c *Call) DoSetMaxBigInt(ord uint64, key string, value string)
- func (c *Call) DoSetMaxFloat64(ord uint64, key string, value float64)
- func (c *Call) DoSetMaxInt64(ord uint64, key string, value int64)
- func (c *Call) DoSetMinBigDecimal(ord uint64, key string, value string)
- func (c *Call) DoSetMinBigInt(ord uint64, key string, value string)
- func (c *Call) DoSetMinFloat64(ord uint64, key string, value float64)
- func (c *Call) DoSetMinInt64(ord uint64, key string, value int64)
- func (c *Call) DoSetSumBigDecimal(ord uint64, key string, value string)
- func (c *Call) DoSetSumBigInt(ord uint64, key string, value string)
- func (c *Call) DoSetSumFloat64(ord uint64, key string, value string)
- func (c *Call) DoSetSumInt64(ord uint64, key string, value string)
- func (c *Call) Err() error
- func (c *Call) Output() []byte
- func (c *Call) PanicDeterministicError(format string, args ...any)
- func (c *Call) PanicNonDeterministicError(err error)
- func (c *Call) ReachedLogsMaxByteCount() bool
- func (c *Call) SetOutputStore(store store.Store)
- func (c *Call) SetPanicError(message string, filename string, lineNo int, colNo int)
- func (c *Call) SetReturnValue(msg []byte)
- func (c *Call) SkipEmptyOutput()
- type FoundationalStoreInput
- type InputType
- type Instance
- type MapInput
- type Module
- type ModuleFactory
- type ModuleFactoryFunc
- type PanicError
- type ParamsInput
- type ProtoScopeValueArgument
- type Registry
- type RuntimeExtension
- type RuntimeExtensionID
- type RuntimeExtensions
- type SourceInput
- type StoreDeltaInput
- type StoreReaderInput
- type StoreWriterOutput
- type WASMExtension
- type WASMExtensioner
Constants ¶
const ( WASM_BINDGEN_PLACEHOLDER_MODULE = "__wbindgen_placeholder__" WASM_BINDGEN_EXTERNREF_XFORM_MODULE = "__wbindgen_externref_xform__" )
const ClockType = "sf.substreams.v1.Clock"
const MaxLogByteCount = 128 * 1024 // 128 KiB
Variables ¶
var ErrFoundationalStoreCanceled = errors.New("foundational store request canceled")
var ErrUnknownRuntimeExtension = errors.New("unknown wasm runtime extension")
var ErrWasmDeterministicExec = errors.New("wasm execution failed deterministically")
var WASMBindgenModules = map[string]struct{}{ WASM_BINDGEN_PLACEHOLDER_MODULE: {}, WASM_BINDGEN_EXTERNREF_XFORM_MODULE: {}, }
Functions ¶
func RegisterModuleFactory ¶ added in v1.1.5
func RegisterModuleFactory(name string, factory ModuleFactory)
Types ¶
type BaseArgument ¶ added in v0.0.21
type BaseArgument struct {
// contains filtered or unexported fields
}
func (*BaseArgument) Name ¶ added in v0.0.21
func (b *BaseArgument) Name() string
type Call ¶ added in v1.1.1
type Call struct {
Clock *pbsubstreams.Clock // Used by WASM extensions
ModuleName string
Entrypoint string
PanicError *PanicError
Logs []string
LogsByteCount uint64
ExecutionStack []string
// contains filtered or unexported fields
}
func FromContext ¶ added in v1.1.5
func (*Call) CanSkipOutput ¶ added in v1.9.0
func (*Call) DoAddBigDecimal ¶ added in v1.1.5
func (*Call) DoAddBigInt ¶ added in v1.1.5
func (*Call) DoAddFloat64 ¶ added in v1.1.5
func (*Call) DoAddInt64 ¶ added in v1.1.5
func (*Call) DoDeletePrefix ¶ added in v1.1.5
func (*Call) DoFoundationalStoreGet ¶ added in v1.16.6
func (*Call) DoFoundationalStoreGetFirst ¶ added in v1.17.2
func (*Call) DoGetFirst ¶ added in v1.1.5
func (*Call) DoHasFirst ¶ added in v1.1.5
func (*Call) DoSetIfNotExists ¶ added in v1.1.5
func (*Call) DoSetMaxBigDecimal ¶ added in v1.1.5
func (*Call) DoSetMaxBigInt ¶ added in v1.1.5
func (*Call) DoSetMaxFloat64 ¶ added in v1.1.5
func (*Call) DoSetMaxInt64 ¶ added in v1.1.5
func (*Call) DoSetMinBigDecimal ¶ added in v1.1.5
func (*Call) DoSetMinBigInt ¶ added in v1.1.5
func (*Call) DoSetMinFloat64 ¶ added in v1.1.5
func (*Call) DoSetMinInt64 ¶ added in v1.1.5
func (*Call) DoSetSumBigDecimal ¶ added in v1.7.0
func (*Call) DoSetSumBigInt ¶ added in v1.7.0
func (*Call) DoSetSumFloat64 ¶ added in v1.7.0
func (*Call) DoSetSumInt64 ¶ added in v1.7.0
func (*Call) PanicDeterministicError ¶ added in v1.17.0
PanicDeterministicError panics with a wrapped error indicating a deterministic execution error and include the module name and the actual error.
func (*Call) PanicNonDeterministicError ¶ added in v1.17.0
PanicNonDeterministicError panics with a wrapped error indicating a non-deterministic execution error and include the module name and the actual error. To determine if the error is deterministic, one will need to inspect [err] itself.
So it is the caller responsibility to decide if the error is deterministic or not.
func (*Call) ReachedLogsMaxByteCount ¶ added in v1.1.1
func (*Call) SetOutputStore ¶ added in v1.1.1
func (*Call) SetPanicError ¶ added in v1.1.5
func (*Call) SetReturnValue ¶ added in v1.1.5
func (*Call) SkipEmptyOutput ¶ added in v1.9.0
func (c *Call) SkipEmptyOutput()
type FoundationalStoreInput ¶ added in v1.16.6
type FoundationalStoreInput struct {
BaseArgument
Clients []pbservice.StoreClient
}
func NewFoundationalStoreInput ¶ added in v1.16.6
func NewFoundationalStoreInput(name string, clients []pbservice.StoreClient) *FoundationalStoreInput
func (*FoundationalStoreInput) Name ¶ added in v1.16.6
func (f *FoundationalStoreInput) Name() string
func (*FoundationalStoreInput) ProtoScopeValue ¶ added in v1.16.6
func (f *FoundationalStoreInput) ProtoScopeValue(value []byte) string
type Instance ¶
type Instance interface {
// Cleanup is called between each calls, for lightweight clean-up (remove allocation)
// in case we're not using a fully deterministic execution strategy.
Cleanup(ctx context.Context) error
// Close is called once we know we won't be reusing this instance, and it can be
// freed from memory. When using cached instances, this won't be called between
// each execution, but only at the end of a user's request.
Close(ctx context.Context) error
}
An Instance lives for the duration of an execution (with instance caching disabled) // or a series of execution (when instance caching is enabled).
type MapInput ¶ added in v0.0.21
type MapInput struct {
BaseArgument
}
func NewMapInput ¶ added in v0.0.21
func (*MapInput) ProtoScopeValue ¶ added in v1.6.0
type Module ¶
type Module interface {
// NewInstance can be used to create up-front a new instance, which will be
// cached and reused for the duration execution of ExecuteNewCall.
NewInstance(ctx context.Context) (instance Instance, err error)
// ExecuteNewCall is called once per module execution for each block.
// If caching is enabled, the returned Instance will be saved and passed in
// as the `cachedInstance` argument upon the next call. In which case, the runtime
// would benefit from using it back. It is the runtime's responsibility to determine
// whether this caching entails risks to determinism (leaking of global state for instance).
ExecuteNewCall(ctx context.Context, call *Call, cachedInstance Instance, arguments []Argument, argValues map[string][]byte) (instance Instance, err error)
// Close gets called when the module can be unloaded at the end of a user's request.
Close(ctx context.Context) error
}
A Module is a cached or pre-compiled version able to generate new isolated instances, and execute calls on them. It lives for the duration of a stream.
type ModuleFactory ¶ added in v1.1.5
type ModuleFactory interface {
NewModule(ctx context.Context, wasmCode []byte, wasmCodeType string, registry *Registry) (module Module, err error)
}
WASM VM specific implementation to create a new Module, which is an abstraction around a runtime and pre-compiled WASM modules.
type ModuleFactoryFunc ¶ added in v1.1.5
type PanicError ¶
type PanicError struct {
// contains filtered or unexported fields
}
func NewPanicError ¶ added in v1.1.5
func NewPanicError(message, filename string, lineNumber, columnNumber int) *PanicError
func (*PanicError) Error ¶
func (e *PanicError) Error() string
type ParamsInput ¶ added in v1.0.0
type ParamsInput struct {
BaseArgument
// contains filtered or unexported fields
}
func NewParamsInput ¶ added in v1.0.0
func NewParamsInput(value string) *ParamsInput
func (*ParamsInput) ProtoScopeValue ¶ added in v1.6.0
func (i *ParamsInput) ProtoScopeValue(value []byte) string
func (*ParamsInput) Value ¶ added in v1.10.1
func (i *ParamsInput) Value() []byte
type ProtoScopeValueArgument ¶ added in v1.6.0
type Registry ¶ added in v1.1.5
type Registry struct {
Extensions map[string]map[string]WASMExtension
// contains filtered or unexported fields
}
Registry from Substreams's perspective is a singleton that is reused across requests, from which we instantiate Modules (wasm code provided by the users) and from which we instantiate Instances (one for each executions within each blocks).
func NewRegistry ¶ added in v1.1.5
func NewRegistry(extensions map[string]map[string]WASMExtension) *Registry
func (*Registry) InstanceCacheEnabled ¶ added in v1.1.5
func (*Registry) RuntimeStack ¶ added in v1.14.0
func (r *Registry) RuntimeStack(wasmCodeType string) ModuleFactory
type RuntimeExtension ¶ added in v1.7.1
type RuntimeExtension struct {
ID RuntimeExtensionID
Value *string
}
type RuntimeExtensionID ¶ added in v1.7.1
type RuntimeExtensionID string
const (
RuntimeExtensionIDWASMBindgenShims RuntimeExtensionID = "wasm-bindgen-shims"
)
type RuntimeExtensions ¶ added in v1.7.1
type RuntimeExtensions []RuntimeExtension
func ParseRuntimeExtensions ¶ added in v1.7.1
func ParseRuntimeExtensions(expressions string) (extensions RuntimeExtensions, err error)
func ParseWASMCodeType ¶ added in v1.7.1
func ParseWASMCodeType(wasmCodeType string) (string, RuntimeExtensions, error)
func (RuntimeExtensions) Has ¶ added in v1.7.1
func (extensions RuntimeExtensions) Has(id RuntimeExtensionID) bool
type SourceInput ¶ added in v0.0.21
type SourceInput struct {
BaseArgument
}
func NewSourceInput ¶ added in v0.0.21
func NewSourceInput(name string, initialBlock uint64) *SourceInput
func (*SourceInput) ProtoScopeValue ¶ added in v1.6.0
func (i *SourceInput) ProtoScopeValue(value []byte) string
type StoreDeltaInput ¶ added in v0.0.21
type StoreDeltaInput struct {
BaseArgument
}
func NewStoreDeltaInput ¶ added in v0.0.21
func NewStoreDeltaInput(name string, initialBlock uint64) *StoreDeltaInput
func (*StoreDeltaInput) ProtoScopeValue ¶ added in v1.6.0
func (i *StoreDeltaInput) ProtoScopeValue(value []byte) string
type StoreReaderInput ¶ added in v0.0.21
type StoreReaderInput struct {
BaseArgument
Store store.Store
}
func NewStoreReaderInput ¶ added in v0.0.21
func NewStoreReaderInput(name string, store store.Store, initialBlock uint64) *StoreReaderInput
type StoreWriterOutput ¶ added in v0.0.21
type StoreWriterOutput struct {
BaseArgument
Store store.Store
UpdatePolicy pbsubstreams.Module_KindStore_UpdatePolicy
ValueType string
}
func NewStoreWriterOutput ¶ added in v0.0.21
func NewStoreWriterOutput(name string, store store.Store, updatePolicy pbsubstreams.Module_KindStore_UpdatePolicy, valueType string) *StoreWriterOutput
type WASMExtension ¶
type WASMExtension func(ctx context.Context, requestID string, clock *pbsubstreams.Clock, in []byte) (out []byte, err error)
WASMExtension defines the implementation of a function that will be exposed as wasm imports; therefore, exposed to the host language like Rust.
For example, this can be an RPC call, taking a structured request in `in` and outputting a structured response in `out`, both serialized as protobuf messages.
Such a function needs to be registered through RegisterRuntime.
type WASMExtensioner ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd/wasigo
command
|
|
|
substreams_wasi_go
command
|
|
|
substreams_wasi_go/pb/google/protobuf
Package timestamppb contains generated types for google/protobuf/timestamp.proto.
|
Package timestamppb contains generated types for google/protobuf/timestamp.proto. |