I have a question about how pallet-contracts interprets a Wasm contract. Are the following assumptions correct?
- pallet-contracts interprets contracts through the simple wasmi interpreter
- gas metering is not done by extending this interpreter with metering capabilities, but by cleverly analyzing the Wasm code and injecting calls to a metering function as sparingly as possible (through wasm-instrument)
- 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 (as part of the external node), which even does JIT compilation
So if these assumptions are correct, does that mean that every contract is intepreted through wasmi, whereas wasmi itself is executed through Wasmtime, i.e., a double layer of Wasm execution?
If so, is there any chance to remove one layer in the future and execute the contract directly through the node's Wasmtime engine? If not, why not use Wasmtime instead of wasmi in pallet-contracts, I guess that would be more efficient and would also allow for SIMD operations?