sc_executor_common/runtime_blob/
mod.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19//! This module allows for inspection and instrumentation, i.e. modifying the module to alter it's
20//! structure or behavior, of a wasm module.
21//!
22//! ## Instrumentation
23//!
24//! In ideal world, there would be no instrumentation. However, in the real world the execution
25//! engines we use are somewhat limited in their APIs or abilities.
26//!
27//! To give you some examples:
28//!
29//!   We need to reset the globals because when we
30//!   execute the Substrate Runtime, we do not drop and create the instance anew, instead
31//!   we restore some selected parts of the state.
32//!
33//! - stack depth metering can be performed via instrumentation or deferred to the engine and say be
34//!   added directly in machine code. Implementing this in machine code is rather cumbersome so
35//!   instrumentation looks like a good solution.
36//!
37//!   Stack depth metering is needed to make a wasm blob
38//!   execution deterministic, which in turn is needed by the Parachain Validation Function in
39//! Polkadot.
40//!
41//! ## Inspection
42//!
43//! Inspection of a wasm module may be needed to extract some useful information, such as to extract
44//! data segment snapshot, which is helpful for quickly restoring the initial state of instances.
45//! Inspection can be also useful to prove that a wasm module possesses some properties, such as,
46//! is free of any floating point operations, which is a useful step towards making instances
47//! produced from such a module deterministic.
48
49mod runtime_blob;
50
51pub use runtime_blob::RuntimeBlob;