Skip to main content

Crate sp_virtualization

Crate sp_virtualization 

Source
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 to that it works transparently from the actual runtime (via the host functions defined in this crate) but also from tests (which run natively).

Additionally, this crate is also used (by the executor) to implement the host functions that are defined in this crate. This allows us to encapsulate all the logic regarding PolkaVM setup in one place.

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.

Modules§

host_fn
Host functions used to spawn and call into PolkaVM instances.

Structs§

ExecBuffer
Buffer shared between runtime and executor for passing syscall data across the host function boundary.
Virt
Native implementation of VirtT.
VirtManager
Manages virtualization instances and their lifecycle.

Enums§

DestroyError
Errors that can be emitted when destroying a virtualization instance.
ExecAction
Specifies what action to take when running a virtualization instance.
ExecError
Errors that can be emitted when executing a new virtualization instance.
ExecOutcome
The outcome of a single virtualization execution step.
ExecStatus
Status returned by the execute / resume host functions.
InstantiateError
Errors that can be emitted when instantiating a new virtualization instance.
MemoryError
Errors that can be emitted when accessing a virtualization instance’s memory.

Constants§

EXEC_BUFFER_SIZE
The size of ExecBuffer in bytes.
LOG_TARGET
The target we use for all logging.

Traits§

MemoryT
Allows to access the memory of a VirtT.
VirtT
A virtualization instance that can be called into multiple times.

Functions§

run_tests
Run all tests.

Type Aliases§

Memory
The concrete memory type used to access the memory of Virt.