Expand description
This crate is intended for use by runtime code (e.g. pallet-contracts) to spawn PolkaVM instances and execute calls into them. Its purpose is to add one layer of abstraction so that it works transparently from the actual runtime (via the host functions defined in this crate) but also from tests (which run natively).
The crate exposes the runtime-side forwarder API and the [#[runtime_interface]] declaration
plus the VirtManagerBackend trait that backs it. The concrete polkavm-driven backend lives
in the sc-virtualization client crate, which registers a VirtManager via VirtManagerExt
before dispatching runtime calls.
Please keep in mind that the interface is kept simple because it has to match the interface of the host function so that the abstraction works. It will never expose the whole PolkaVM interface.
§⚠️ Unstable API — Do Not Use in Production ⚠️
This crate’s API is unstable and subject to breaking changes without notice.
The virtualization host functions exposed by this crate have not been stabilized and are not available on Polkadot (or any other production relay/parachain) until they are. Using them in a production runtime will cause your runtime to break when the API changes.
This crate should only be used for:
- Local testing and development
- Experimentation on test networks
Do not ship runtimes that depend on this crate to any chain you care about. There is no stability guarantee and no deprecation period — the interface may change at any time.
Re-exports§
pub use crate::tests::run as run_tests;
Modules§
- tests
- Shared test driver for the virtualization forwarder API.
Structs§
- Exec
Buffer - Buffer shared between runtime and executor for passing syscall data across the host function boundary.
- Execution
- A prepared or suspended virtualization execution.
- Host
Functions - Aggregate of all host functions exposed by this crate.
- Instance
- An idle virtualization instance.
- Instance
Id - Opaque handle to a virtualization instance.
- Module
- A compiled module handle.
- Module
Id - Opaque handle to a compiled module.
- Syscall
Symbol - A syscall symbol with a maximum length of
MAX_SYSCALL_SYMBOL_LENbytes. - Virt
Manager Ext - Extension wrapping a
VirtManagerBackendso it can be accessed through the externalities by the virtualization host functions.
Enums§
- Compile
Status - Status returned by the
compile_*host functions. - Destroy
Error - Errors that can be emitted when destroying a virtualization instance.
- Exec
Error - Errors that can be emitted when executing a new virtualization instance.
- Exec
Result - The result of running a virtualization instance.
- Exec
Status - Status returned by the
runhost function. - Instantiate
Error - Errors that can be emitted when instantiating a new virtualization instance.
- Memory
Error - Errors that can be emitted when accessing a virtualization instance’s memory.
- Module
Error - Errors that can be emitted when compiling a program into a module.
Constants§
- LOG_
TARGET - The target we use for all logging.
- MAX_
SYSCALL_ SYMBOL_ LEN - Maximum length of a syscall symbol in bytes.
Traits§
- Virt
Manager Backend - The host-side operations driven by the virtualization host functions.