Skip to main content

gsc_executor_common/runtime_blob/
mod.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
3
4//! This module allows for inspection and instrumentation, i.e. modifying the module to alter it's
5//! structure or behavior, of a wasm module.
6//!
7//! ## Instrumentation
8//!
9//! In ideal world, there would be no instrumentation. However, in the real world the execution
10//! engines we use are somewhat limited in their APIs or abilities.
11//!
12//! To give you some examples:
13//!
14//!   We need to reset the globals because when we
15//!   execute the Substrate Runtime, we do not drop and create the instance anew, instead
16//!   we restore some selected parts of the state.
17//!
18//! - stack depth metering can be performed via instrumentation or deferred to the engine and say be
19//!   added directly in machine code. Implementing this in machine code is rather cumbersome so
20//!   instrumentation looks like a good solution.
21//!
22//!   Stack depth metering is needed to make a wasm blob
23//!   execution deterministic, which in turn is needed by the Parachain Validation Function in
24//!   Polkadot.
25//!
26//! ## Inspection
27//!
28//! Inspection of a wasm module may be needed to extract some useful information, such as to extract
29//! data segment snapshot, which is helpful for quickly restoring the initial state of instances.
30//! Inspection can be also useful to prove that a wasm module possesses some properties, such as,
31//! is free of any floating point operations, which is a useful step towards making instances
32//! produced from such a module deterministic.
33
34#[allow(clippy::module_inception)]
35mod runtime_blob;
36
37pub use runtime_blob::RuntimeBlob;