wasmtime

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: LGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "wasmtime"

Name represents the name of the interpreter

Variables

This section is empty.

Functions

func GetRuntimeImports

func GetRuntimeImports(t *testing.T, targetRuntime string) func(*wasmtime.Store) (*wasmtime.Linker, error)

GetRuntimeImports ...

func ImportHostHandler added in v0.3.0

func ImportHostHandler(store *wasmtime.Store) (*wasmtime.Linker, error)

ImportHostHandler adds the wasmtime imports for host API tester to linker

func ImportLegacyNodeRuntime added in v0.3.0

func ImportLegacyNodeRuntime(store *wasmtime.Store) (*wasmtime.Linker, error)

ImportLegacyNodeRuntime add wasmtime imports to linker

func ImportNodeRuntime added in v0.3.0

func ImportNodeRuntime(store *wasmtime.Store) (*wasmtime.Linker, error)

ImportNodeRuntime adds the imports for the v0.8 runtime to linker

Types

type Config

type Config struct {
	gssmrruntime.InstanceConfig
	Imports func(*wasmtime.Store) (*wasmtime.Linker, error)
}

Config represents a wasmer configuration

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

Instance represents a v0.8 runtime go-wasmtime instance

func NewInstance added in v0.3.0

func NewInstance(code []byte, cfg *Config) (*Instance, error)

NewInstance instantiates a runtime from the given wasm bytecode

func NewInstanceFromFile

func NewInstanceFromFile(fp string, cfg *Config) (*Instance, error)

NewInstanceFromFile instantiates a runtime from a .wasm file

func NewTestInstance

func NewTestInstance(t *testing.T, targetRuntime string) *Instance

NewTestInstance will create a new runtime instance using the given target runtime

func NewTestInstanceWithTrie

func NewTestInstanceWithTrie(t *testing.T, targetRuntime string, tt *trie.Trie, lvl log.Lvl) *Instance

NewTestInstanceWithTrie will create a new runtime (polkadot/test) with the supplied trie as the storage

func (*Instance) ApplyExtrinsic

func (in *Instance) ApplyExtrinsic(data types.Extrinsic) ([]byte, error)

ApplyExtrinsic calls runtime API function BlockBuilder_apply_extrinsic

func (*Instance) BabeConfiguration

func (in *Instance) BabeConfiguration() (*types.BabeConfiguration, error)

BabeConfiguration gets the configuration data for BABE from the runtime

func (*Instance) CheckInherents

func (in *Instance) CheckInherents()

func (*Instance) Exec

func (in *Instance) Exec(function string, data []byte) ([]byte, error)

Exec calls the given function with the given data

func (*Instance) ExecuteBlock

func (in *Instance) ExecuteBlock(block *types.Block) ([]byte, error)

ExecuteBlock calls runtime function Core_execute_block

func (*Instance) FinalizeBlock

func (in *Instance) FinalizeBlock() (*types.Header, error)

FinalizeBlock calls runtime API function BlockBuilder_finalize_block

func (*Instance) GenerateSessionKeys

func (in *Instance) GenerateSessionKeys()

func (*Instance) GrandpaAuthorities

func (in *Instance) GrandpaAuthorities() ([]*types.Authority, error)

GrandpaAuthorities returns the genesis authorities from the runtime

func (*Instance) InherentExtrinsics

func (in *Instance) InherentExtrinsics(data []byte) ([]byte, error)

InherentExtrinsics calls runtime API function BlockBuilder_inherent_extrinsics

func (*Instance) InitializeBlock

func (in *Instance) InitializeBlock(header *types.Header) error

InitializeBlock calls runtime API function Core_initialize_block

func (*Instance) Legacy

func (in *Instance) Legacy() *LegacyInstance

Legacy returns the instance as a LegacyInstance

func (*Instance) Metadata

func (in *Instance) Metadata() ([]byte, error)

Metadata calls runtime function Metadata_metadata

func (*Instance) NetworkService

func (in *Instance) NetworkService() gssmrruntime.BasicNetwork

NetworkService to get referernce to runtime network service

func (*Instance) NodeStorage

func (in *Instance) NodeStorage() gssmrruntime.NodeStorage

NodeStorage to get reference to runtime node service

func (*Instance) OffchainWorker

func (in *Instance) OffchainWorker()

func (*Instance) RandomSeed

func (in *Instance) RandomSeed()

func (*Instance) SetContextStorage added in v0.3.0

func (in *Instance) SetContextStorage(s gssmrruntime.Storage)

SetContextStorage sets the runtime's storage. It should be set before calls to the below functions.

func (*Instance) Stop

func (in *Instance) Stop()

Stop func

func (*Instance) UpdateRuntimeCode added in v0.3.0

func (in *Instance) UpdateRuntimeCode(_ []byte) error

UpdateRuntimeCode ...

func (*Instance) ValidateTransaction

func (in *Instance) ValidateTransaction(e types.Extrinsic) (*transaction.Validity, error)

ValidateTransaction runs the extrinsic through runtime function TaggedTransactionQueue_validate_transaction and returns *Validity

func (*Instance) Version

func (in *Instance) Version() (runtime.Version, error)

Version calls runtime function Core_Version

type LegacyInstance

type LegacyInstance struct {
	// contains filtered or unexported fields
}

LegacyInstance represents a v0.6 runtime go-wasmtime instance

func NewLegacyInstance

func NewLegacyInstance(code []byte, cfg *Config) (*LegacyInstance, error)

NewLegacyInstance instantiates a runtime from the given wasm bytecode

func NewLegacyInstanceFromFile

func NewLegacyInstanceFromFile(fp string, cfg *Config) (*LegacyInstance, error)

NewLegacyInstanceFromFile instantiates a runtime from a .wasm file

func (*LegacyInstance) ApplyExtrinsic

func (in *LegacyInstance) ApplyExtrinsic(data types.Extrinsic) ([]byte, error)

ApplyExtrinsic calls runtime API function BlockBuilder_apply_extrinsic

func (*LegacyInstance) BabeConfiguration

func (in *LegacyInstance) BabeConfiguration() (*types.BabeConfiguration, error)

BabeConfiguration gets the configuration data for BABE from the runtime

func (*LegacyInstance) Exec

func (in *LegacyInstance) Exec(function string, data []byte) ([]byte, error)

Exec calls the given function with the given data

func (*LegacyInstance) ExecuteBlock

func (in *LegacyInstance) ExecuteBlock(block *types.Block) ([]byte, error)

ExecuteBlock calls runtime function Core_execute_block

func (*LegacyInstance) FinalizeBlock

func (in *LegacyInstance) FinalizeBlock() (*types.Header, error)

FinalizeBlock calls runtime API function BlockBuilder_finalize_block

func (*LegacyInstance) GrandpaAuthorities

func (in *LegacyInstance) GrandpaAuthorities() ([]*types.Authority, error)

GrandpaAuthorities returns the genesis authorities from the runtime

func (*LegacyInstance) InherentExtrinsics

func (in *LegacyInstance) InherentExtrinsics(data []byte) ([]byte, error)

InherentExtrinsics calls runtime API function BlockBuilder_inherent_extrinsics

func (*LegacyInstance) InitializeBlock

func (in *LegacyInstance) InitializeBlock(header *types.Header) error

InitializeBlock calls runtime API function Core_initialize_block

func (*LegacyInstance) Metadata

func (in *LegacyInstance) Metadata() ([]byte, error)

Metadata calls runtime function Metadata_metadata

func (*LegacyInstance) NetworkService

func (in *LegacyInstance) NetworkService() gssmrruntime.BasicNetwork

NetworkService returns the context's NetworkService

func (*LegacyInstance) NodeStorage

func (in *LegacyInstance) NodeStorage() gssmrruntime.NodeStorage

NodeStorage returns the context's NodeStorage

func (*LegacyInstance) SetContextStorage added in v0.3.0

func (in *LegacyInstance) SetContextStorage(s gssmrruntime.Storage)

SetContextStorage sets the runtime context's Storage

func (*LegacyInstance) Stop

func (in *LegacyInstance) Stop()

Stop ...

func (*LegacyInstance) ValidateTransaction

func (in *LegacyInstance) ValidateTransaction(e types.Extrinsic) (*transaction.Validity, error)

ValidateTransaction runs the extrinsic through runtime function TaggedTransactionQueue_validate_transaction and returns *Validity

func (*LegacyInstance) Version

func (in *LegacyInstance) Version() (runtime.Version, error)

Version calls runtime function Core_Version

type Memory

type Memory struct {
	// contains filtered or unexported fields
}

Memory is a thin wrapper around wasmtime memory to support Gossamer runtime.Memory interface

func (Memory) Data

func (m Memory) Data() []byte

Data returns the memory's data

func (Memory) Grow added in v0.3.0

func (m Memory) Grow(numPages uint32) error

Grow ...

func (Memory) Length

func (m Memory) Length() uint32

Length returns the memory's length

Jump to

Keyboard shortcuts

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