I found wasmi is a dependency in multiple substrate crates, but there's one crate that also uses wasmtime. How is wasmi
different from wasmtime
?
2 Answers
Wasmi is a WASM Interpreter used by the pallet-contracts. Like every pallet also pallet-contracts is compiled to WASM itself as part of the WASM runtime. The WASM runtime is executed through the more powerful Wasmtime WASM engine (ref).
- Wasmi is a wasm interpreter. This means that it interprets the wasm binary as it executes it.
- Wasmtime is a wasm compiler. This means that it compiles the wasm binary to the current native platform before executing it.
Substrate supports both of them to run the runtime. However, wasmi is the legacy engine as it is slower than wasmtime.