Skip to main content

soil_client/executor/
mod.rs

1// This file is part of Soil.
2
3// Copyright (C) Soil contributors.
4// Copyright (C) Parity Technologies (UK) Ltd.
5// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
6
7//! A crate that provides means of executing/dispatching calls into the runtime.
8//!
9//! There are a few responsibilities of this crate at the moment:
10//!
11//! - It provides an implementation of a common entrypoint for calling into the runtime, both
12//! wasm and compiled.
13//! - It defines the environment for the wasm execution, namely the host functions that are to be
14//! provided into the wasm runtime module.
15//! - It also provides the required infrastructure for executing the current wasm runtime (specified
16//! by the current value of `:code` in the provided externalities), i.e. interfacing with
17//! wasm engine used, instance cache.
18
19#![warn(missing_docs)]
20
21pub mod common;
22pub mod polkavm;
23pub mod wasmtime;
24
25#[macro_use]
26mod executor;
27mod wasm_runtime;
28
29#[allow(deprecated)]
30pub use self::executor::NativeElseWasmExecutor;
31pub use self::executor::{with_externalities_safe, NativeExecutionDispatch, WasmExecutor};
32pub use codec::Codec;
33#[doc(hidden)]
34pub use subsoil::core::traits::Externalities;
35pub use subsoil::version::{NativeVersion, RuntimeVersion};
36#[doc(hidden)]
37pub use subsoil::wasm_interface;
38pub use subsoil::wasm_interface::HostFunctions;
39pub use wasm_runtime::{read_embedded_version, WasmExecutionMethod};
40
41pub use self::wasmtime::InstantiationStrategy as WasmtimeInstantiationStrategy;
42pub use common::{
43	error,
44	wasm_runtime::{HeapAllocStrategy, DEFAULT_HEAP_ALLOC_PAGES, DEFAULT_HEAP_ALLOC_STRATEGY},
45};
46
47/// Extracts the runtime version of a given runtime code.
48pub trait RuntimeVersionOf {
49	/// Extract [`RuntimeVersion`] of the given `runtime_code`.
50	fn runtime_version(
51		&self,
52		ext: &mut dyn Externalities,
53		runtime_code: &subsoil::core::traits::RuntimeCode,
54	) -> error::Result<RuntimeVersion>;
55}