Documentation ¶
Index ¶
- Constants
- Variables
- func GetRuntimeVersion(code []byte) (version runtime.Version, err error)
- func NewRuntimeFromGenesis(cfg Config) (instance runtime.Instance, err error)
- func NewTrieFromGenesis(gen genesis.Genesis) (tr trie.Trie, err error)
- type Config
- type Instance
- func NewInstance(code []byte, cfg Config) (instance *Instance, err error)
- func NewInstanceFromFile(fp string, cfg Config) (*Instance, error)
- func NewInstanceFromTrie(t *trie.Trie, cfg Config) (*Instance, error)
- func NewTestInstance(t *testing.T, targetRuntime string) *Instance
- func NewTestInstanceWithTrie(t *testing.T, targetRuntime string, tt *trie.Trie) *Instance
- func (in *Instance) ApplyExtrinsic(data types.Extrinsic) ([]byte, error)
- func (in *Instance) BabeConfiguration() (*types.BabeConfiguration, error)
- func (in *Instance) CheckInherents()
- func (in *Instance) DecodeSessionKeys(enc []byte) ([]byte, error)
- func (in *Instance) Exec(function string, data []byte) (result []byte, err error)
- func (in *Instance) ExecuteBlock(block *types.Block) ([]byte, error)
- func (in *Instance) FinalizeBlock() (*types.Header, error)
- func (in *Instance) GenerateSessionKeys()
- func (in *Instance) GetCodeHash() common.Hash
- func (in *Instance) GetContext() *runtime.Context
- func (in *Instance) GrandpaAuthorities() ([]types.Authority, error)
- func (in *Instance) InherentExtrinsics(data []byte) ([]byte, error)
- func (in *Instance) InitializeBlock(header *types.Header) error
- func (in *Instance) Keystore() *keystore.GlobalKeystore
- func (in *Instance) Metadata() ([]byte, error)
- func (in *Instance) NetworkService() runtime.BasicNetwork
- func (in *Instance) NodeStorage() runtime.NodeStorage
- func (in *Instance) OffchainWorker()
- func (in *Instance) PaymentQueryInfo(ext []byte) (*types.RuntimeDispatchInfo, error)
- func (in *Instance) QueryCallFeeDetails(ext []byte) (*types.FeeDetails, error)
- func (in *Instance) QueryCallInfo(ext []byte) (*types.RuntimeDispatchInfo, error)
- func (in *Instance) RandomSeed()
- func (in *Instance) SetContextStorage(s runtime.Storage)
- func (in *Instance) Stop()
- func (in *Instance) UpdateRuntimeCode(code []byte) (err error)
- func (in *Instance) ValidateTransaction(e types.Extrinsic) (*transaction.Validity, error)
- func (in *Instance) Validator() bool
- func (in *Instance) Version() (version runtime.Version)
Constants ¶
const Name = "wasmer"
Name represents the name of the interpreter
Variables ¶
var ( ErrCodeEmpty = errors.New("code is empty") ErrWASMDecompress = errors.New("wasm decompression failed") )
var ( ErrInstanceIsStopped = errors.New("instance is stopped") ErrExportFunctionNotFound = errors.New("export function not found") )
var DefaultTestLogLvl = log.Info
DefaultTestLogLvl is the log level used for test runtime instances
var (
ErrGenesisTopNotFound = errors.New("genesis top not found")
)
Functions ¶
func GetRuntimeVersion ¶ added in v0.7.0
GetRuntimeVersion finds the runtime version by initiating a temporary runtime instance using the WASM code provided, and querying it.
func NewRuntimeFromGenesis ¶ added in v0.3.0
NewRuntimeFromGenesis creates a runtime instance from the genesis data
Types ¶
type Config ¶
type Config struct { Storage runtime.Storage Keystore *keystore.GlobalKeystore LogLvl log.Level Role common.Roles NodeStorage runtime.NodeStorage Network runtime.BasicNetwork Transaction runtime.TransactionState CodeHash common.Hash // contains filtered or unexported fields }
Config is the configuration used to create a Wasmer runtime instance.
func (*Config) SetTestVersion ¶ added in v0.7.0
SetTestVersion sets the test version for the runtime. WARNING: This should only be used for testing purposes. The *testing.T argument is only required to enforce this function to be used in tests only.
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance represents a v0.8 runtime go-wasmer instance
func NewInstance ¶
NewInstance instantiates a runtime from raw wasm bytecode
func NewInstanceFromFile ¶
NewInstanceFromFile instantiates a runtime from a .wasm file
func NewInstanceFromTrie ¶ added in v0.3.0
NewInstanceFromTrie returns a new runtime instance with the code provided in the given trie
func NewTestInstance ¶
NewTestInstance will create a new runtime instance using the given target runtime
func NewTestInstanceWithTrie ¶
NewTestInstanceWithTrie will create a new runtime (polkadot/test) with the supplied trie as the storage
func (*Instance) ApplyExtrinsic ¶
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) DecodeSessionKeys ¶ added in v0.7.0
DecodeSessionKeys decodes the given public session keys. Returns a list of raw public keys including their key type.
func (*Instance) ExecuteBlock ¶
ExecuteBlock calls runtime function Core_execute_block
func (*Instance) FinalizeBlock ¶
FinalizeBlock calls runtime API function BlockBuilder_finalize_block
func (*Instance) GenerateSessionKeys ¶
func (in *Instance) GenerateSessionKeys()
func (*Instance) GetCodeHash ¶ added in v0.7.0
GetCodeHash returns the code of the instance
func (*Instance) GetContext ¶ added in v0.7.0
GetContext returns the context of the instance
func (*Instance) GrandpaAuthorities ¶
GrandpaAuthorities returns the genesis authorities from the runtime
func (*Instance) InherentExtrinsics ¶
InherentExtrinsics calls runtime API function BlockBuilder_inherent_extrinsics
func (*Instance) InitializeBlock ¶
InitializeBlock calls runtime API function Core_initialise_block
func (*Instance) Keystore ¶ added in v0.7.0
func (in *Instance) Keystore() *keystore.GlobalKeystore
Keystore to get reference to runtime keystore
func (*Instance) NetworkService ¶
func (in *Instance) NetworkService() runtime.BasicNetwork
NetworkService to get referernce to runtime network service
func (*Instance) NodeStorage ¶
func (in *Instance) NodeStorage() runtime.NodeStorage
NodeStorage to get reference to runtime node service
func (*Instance) OffchainWorker ¶
func (in *Instance) OffchainWorker()
func (*Instance) PaymentQueryInfo ¶ added in v0.7.0
func (in *Instance) PaymentQueryInfo(ext []byte) (*types.RuntimeDispatchInfo, error)
PaymentQueryInfo returns information of a given extrinsic
func (*Instance) QueryCallFeeDetails ¶ added in v0.7.0
func (in *Instance) QueryCallFeeDetails(ext []byte) (*types.FeeDetails, error)
QueryCallFeeDetails returns call fee details for given call
func (*Instance) QueryCallInfo ¶ added in v0.7.0
func (in *Instance) QueryCallInfo(ext []byte) (*types.RuntimeDispatchInfo, error)
QueryCallInfo returns information of a given extrinsic
func (*Instance) RandomSeed ¶
func (in *Instance) RandomSeed()
func (*Instance) SetContextStorage ¶ added in v0.3.0
SetContextStorage sets the runtime's storage. It should be set before calls to the below functions.
func (*Instance) Stop ¶
func (in *Instance) Stop()
Stop closes the WASM instance, its imports and clears the context allocator in a thread-safe way.
func (*Instance) UpdateRuntimeCode ¶ added in v0.3.0
UpdateRuntimeCode updates the runtime instance to run the given code
func (*Instance) ValidateTransaction ¶
ValidateTransaction runs the extrinsic through the runtime function TaggedTransactionQueue_validate_transaction and returns *transaction.Validity. The error can be a VDT of either transaction.InvalidTransaction or transaction.UnknownTransaction, or can represent a normal error i.e. unmarshalling error