Closed larry0x closed 1 month ago
We realized that the LLVM compiler accesses an external shared object (libllvm-*.so
) through the C API. This means anything involving it will have trouble being SNARK proved using a zkVM.
Provable computation is important for us. Therefore we can't include the LLVM compiler.
Without LLVM compiler, pinning codes is kinda meaningless as well, since privileged contracts like owner, bank, taxman probably will be constantly cached in the LRU cache anyways.
Wasmer provides three compilers that convert WebAssembly bytecodes to native machine codes: Singlepass, Cranelift, and LLVM.
Singlepass is the fastest at compile time but slowest at run time (up to 8x slower than native Rust).
LLVM is the slowest at compile time by a big margin (>150x slower than Singlepass) but fastest at run time (<2x slower than native Rust).
(Benchmark)
For Grug, there is benefit in compiling certain "privileged contracts" (e.g. bank, taxman, some basic accounts, IBC clients) using LLVM, but other contracts are better using Singlepass.
Suggested implementation
Add a
prinned_hashes
field toConfig
:Add a
pinned_modules
field to the Wasm VM cache:When creating the
App<DB, VM>
, theVM
is provided with the list of hashes and codes to be pinned. At this time, it should build the pinned contracts using LLVM compiler at this time: