Repository: paritytech/substrate
File: client/executor/wasmtime/src/runtime.rs (Rust)

Code before:
	/// Configures wasmtime to use multiple threads for compiling.
	pub parallel_compilation: bool,

	/// The heap allocation strategy to use.
	pub heap_alloc_strategy: HeapAllocStrategy,

	/// Enables WASM Multi-Value proposal
	pub wasm_multi_value: bool,

	/// Enables WASM Bulk Memory Operations proposal
	pub wasm_bulk_memory: bool,

	/// Enables WASM Reference Types proposal
	pub wasm_reference_types: bool,

	/// Enables WASM Fixed-Width SIMD proposal
	pub wasm_simd: bool,

	/// Enables WASM Threads and Atomics proposal
	pub wasm_threads: bool,

	/// Enables WASM Multi-Memory proposal
	pub wasm_multi_memory: bool,

	/// Enables WASM Memory64 proposal
	pub wasm_memory64: bool,
}

#[derive(Clone)]
pub struct Config {
	/// The WebAssembly standard requires all imports of an instantiated module to be resolved,
	/// otherwise, the instantiation fails. If this option is set to `true`, then this behavior is
	/// overriden and imports that are requested by the module and not provided by the host
	/// functions will be resolved using stubs. These stubs will trap upon a call.
	pub allow_missing_func_imports: bool,

	/// A directory in which wasmtime can store its compiled artifacts cache.
	pub cache_path: Option<PathBuf>,

	/// Tuning of various semantics of the wasmtime executor.
	pub semantics: Semantics,
}

enum CodeSupplyMode<'a> {
	/// The runtime is instantiated using the given runtime blob.
	Fresh(RuntimeBlob),

	/// The runtime is instantiated using a precompiled module.
	///
	/// This assumes that the code is already prepared for execution and the same `Config` was
	/// used.

Review comment (suggestion):
I don't think we need all of those, and some of those are pretty much experimental and should never be enabled until the spec for them is finalized.

Please remove `wasm_threads`, `wasm_multi_memory` and `wasm_memory64`.

Code after:
	/// Configures wasmtime to use multiple threads for compiling.
	pub parallel_compilation: bool,

	/// The heap allocation strategy to use.
	pub heap_alloc_strategy: HeapAllocStrategy,

	/// Enables WASM Multi-Value proposal
	pub wasm_multi_value: bool,

	/// Enables WASM Bulk Memory Operations proposal
	pub wasm_bulk_memory: bool,

	/// Enables WASM Reference Types proposal
	pub wasm_reference_types: bool,

	/// Enables WASM Fixed-Width SIMD proposal
	pub wasm_simd: bool,
}

#[derive(Clone)]
pub struct Config {
	/// The WebAssembly standard requires all imports of an instantiated module to be resolved,
	/// otherwise, the instantiation fails. If this option is set to `true`, then this behavior is
	/// overriden and imports that are requested by the module and not provided by the host
	/// functions will be resolved using stubs. These stubs will trap upon a call.
	pub allow_missing_func_imports: bool,

	/// A directory in which wasmtime can store its compiled artifacts cache.
	pub cache_path: Option<PathBuf>,

	/// Tuning of various semantics of the wasmtime executor.
	pub semantics: Semantics,
}

enum CodeSupplyMode<'a> {
	/// The runtime is instantiated using the given runtime blob.
	Fresh(RuntimeBlob),

	/// The runtime is instantiated using a precompiled module.
	///
	/// This assumes that the code is already prepared for execution and the same `Config` was
	/// used.
	///
	/// We use a `Path` here instead of simply passing a byte slice to allow `wasmtime` to
	/// map the runtime's linear memory on supported platforms in a copy-on-write fashion.
	Precompiled(&'a Path),
}

/// Create a new `WasmtimeRuntime` given the code. This function performs translation from Wasm to
/// machine code, which can be computationally heavy.
///