wasmi
is a Wasm executor that uses interpretation rather than compilation.
Whenever the node software needs to execute some Wasm binary, it needs to use a Wasm executor like wasmi
or wasmtime
. This can be the Wasm runtime, Wasm smart contracts, or any other Wasm you can think of for your blockchain node (like an offchain worker or in the future SPREE).
Does wasmi only function as an interpreter that changes the rust code to wasm?
No. By the time you use wasmi
, it you already have a compiled WebAssembly blob, so wasmi
does not see Rust at all. It simply changes Wasm into actual machine code.
Wasmi is not related to the function of Polkadot, such as scale codec (encode, decode extrinsics) or signing and signature etc..?
The Wasm executor is obviously an important part of Substrate and Polkadot, but no, it is not directly related to things like SCALE codec, signing, or anything like that. The project is built independent of a specific blockchain purpose, and is simply a general Wasm executor. You could include this into other projects like a web browser if you wanted.