Documentation ¶
Index ¶
- Constants
- Variables
- func GetRuntimeVersion(code []byte) (version runtime.Version, err error)
- func NewKillStorageResult(deleted uint32, allDeleted bool) scale.VaryingDataType
- 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 NewRuntimeFromGenesis(cfg Config) (instance *Instance, err 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) BabeGenerateKeyOwnershipProof(slot uint64, authorityID [32]byte) (types.OpaqueKeyOwnershipProof, error)
- func (in *Instance) BabeSubmitReportEquivocationUnsignedExtrinsic(equivocationProof types.BabeEquivocationProof, ...) error
- func (*Instance) CheckInherents()
- func (in *Instance) DecodeSessionKeys(enc []byte) ([]byte, error)
- func (i *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 (*Instance) GenerateSessionKeys()
- func (in *Instance) GetCodeHash() common.Hash
- func (in *Instance) GrandpaAuthorities() ([]types.Authority, error)
- func (in *Instance) GrandpaGenerateKeyOwnershipProof(authSetID uint64, authorityID ed25519.PublicKeyBytes) (types.GrandpaOpaqueKeyOwnershipProof, error)
- func (in *Instance) GrandpaSubmitReportEquivocationUnsignedExtrinsic(equivocationProof types.GrandpaEquivocationProof, ...) 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 (*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 (*Instance) RandomSeed()
- func (in *Instance) SetContextStorage(s runtime.Storage)
- func (in *Instance) Stop()
- func (in *Instance) ValidateTransaction(e types.Extrinsic) (*transaction.Validity, error)
- func (in *Instance) Validator() bool
- func (in *Instance) Version() (runtime.Version, error)
Constants ¶
const Name = "wazero"
Name represents the name of the interpreter
Variables ¶
var DefaultTestLogLvl = log.Info
DefaultTestLogLvl is the log level used for test runtime instances
var ErrExportFunctionNotFound = errors.New("export function not found")
Functions ¶
func GetRuntimeVersion ¶
GetRuntimeVersion finds the runtime version by initiating a temporary runtime instance using the WASM code provided, and querying it.
func NewKillStorageResult ¶
func NewKillStorageResult(deleted uint32, allDeleted bool) scale.VaryingDataType
NewDigestItem returns a new VaryingDataType to represent a DigestItem
Types ¶
type Config ¶
type Config struct { Storage runtime.Storage Keystore *keystore.GlobalKeystore LogLvl log.Level Role common.NetworkRole NodeStorage runtime.NodeStorage Network runtime.BasicNetwork Transaction runtime.TransactionState CodeHash common.Hash }
Config is the configuration used to create a Wasmer runtime instance.
type Instance ¶
type Instance struct { Runtime wazero.Runtime Module api.Module Context *runtime.Context sync.Mutex // contains filtered or unexported fields }
Instance backed by wazero.Runtime
func NewInstance ¶
NewInstance instantiates a runtime from raw wasm bytecode
func NewInstanceFromFile ¶
NewInstanceFromFile instantiates a runtime from a .wasm file
func NewInstanceFromTrie ¶
NewInstanceFromTrie returns a new runtime instance with the code provided in the given trie
func NewRuntimeFromGenesis ¶
NewRuntimeFromGenesis creates a runtime instance from the genesis data
func NewTestInstance ¶
NewTestInstance will create a new runtime instance using the given target runtime
func NewTestInstanceWithTrie ¶
NewTestInstanceWithTrie returns an instance based on the target runtime string specified, which can be a file path or a constant from the constants defined in `lib/runtime/constants.go`. The instance uses the trie given as argument for its 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) BabeGenerateKeyOwnershipProof ¶
func (in *Instance) BabeGenerateKeyOwnershipProof(slot uint64, authorityID [32]byte) ( types.OpaqueKeyOwnershipProof, error)
BabeGenerateKeyOwnershipProof returns the babe key ownership proof from the runtime.
func (*Instance) BabeSubmitReportEquivocationUnsignedExtrinsic ¶
func (in *Instance) BabeSubmitReportEquivocationUnsignedExtrinsic( equivocationProof types.BabeEquivocationProof, keyOwnershipProof types.OpaqueKeyOwnershipProof, ) error
BabeSubmitReportEquivocationUnsignedExtrinsic reports equivocation report to the runtime.
func (*Instance) CheckInherents ¶
func (*Instance) CheckInherents()
CheckInherents checks inherents in the block verification process. TODO: use this in block verification process (#1873)
func (*Instance) DecodeSessionKeys ¶
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 (*Instance) GenerateSessionKeys()
func (*Instance) GetCodeHash ¶
GetCodeHash returns the code of the instance
func (*Instance) GrandpaAuthorities ¶
GrandpaAuthorities returns the genesis authorities from the runtime
func (*Instance) GrandpaGenerateKeyOwnershipProof ¶
func (in *Instance) GrandpaGenerateKeyOwnershipProof(authSetID uint64, authorityID ed25519.PublicKeyBytes) ( types.GrandpaOpaqueKeyOwnershipProof, error)
GrandpaGenerateKeyOwnershipProof returns grandpa key ownership proof from the runtime.
func (*Instance) GrandpaSubmitReportEquivocationUnsignedExtrinsic ¶
func (in *Instance) GrandpaSubmitReportEquivocationUnsignedExtrinsic( equivocationProof types.GrandpaEquivocationProof, keyOwnershipProof types.GrandpaOpaqueKeyOwnershipProof, ) error
GrandpaSubmitReportEquivocationUnsignedExtrinsic reports an equivocation report to 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 ¶
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 (*Instance) OffchainWorker()
func (*Instance) PaymentQueryInfo ¶
func (in *Instance) PaymentQueryInfo(ext []byte) (*types.RuntimeDispatchInfo, error)
PaymentQueryInfo returns information of a given extrinsic
func (*Instance) QueryCallFeeDetails ¶
func (in *Instance) QueryCallFeeDetails(ext []byte) (*types.FeeDetails, error)
QueryCallFeeDetails returns call fee details for given call
func (*Instance) QueryCallInfo ¶
func (in *Instance) QueryCallInfo(ext []byte) (*types.RuntimeDispatchInfo, error)
QueryCallInfo returns information of a given extrinsic
func (*Instance) RandomSeed ¶
func (*Instance) RandomSeed()
func (*Instance) SetContextStorage ¶
SetContextStorage sets the runtime's storage.
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) 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