Abstract
Quai Network should utilize a Wasm VM in in order to conform to a public standard of computing. Wasm has generally been adopted and maintained by the larger software community. Wasm also aligns with our general goals of security, portability, and toolchain compatibility.
Copyright
This QIP licensed under the BSD 2-clause license.
Definitions
- Quai environment interface (QEI): a set of methods available to wasm contracts
- metering: the act of measuring execution cost in a deterministic way
- metering injector: a transformation tool inserting metering code to an wasm contract
Motivations
WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable compilation target for programming languages, enabling deployment on the web for client and server applications.
Objectives of WebAssembly include:
Efficient and fast
The Wasm stack machine is designed to be encoded in a size- and load-time-efficient binary format. WebAssembly aims to execute at native speed by taking advantage of common hardware capabilities available on a wide range of platforms.
Safe
WebAssembly describes a memory-safe, sandboxed execution environment that may even be implemented inside existing JavaScript virtual machines. When embedded in the web, WebAssembly will enforce the same-origin and permissions security policies of the browser.
Open and debuggable
WebAssembly is designed to be pretty-printed in a textual format for debugging, testing, experimenting, optimizing, learning, teaching, and writing programs by hand. The textual format will be used when viewing the source of Wasm modules on the web.
Part of the open web platform
WebAssembly is designed to maintain the versionless, feature-tested, and backwards-compatible nature of the web. WebAssembly modules will be able to call into and out of the JavaScript context and access browser functionality through the same Web APIs accessible from JavaScript. WebAssembly also supports non-web embeddings.
Specification
- To provide a specification of the Quai node interface and subsequent host function capabilities
- To provide an solidity transcompiler
- To provide a VM implementation for executing Wasm contracts
- To provide a metering injector if needed
- To provide a library and instructions for writing contracts in Rust/C/Go/AssemblyScript
An initial draft PR utilizing the wazero
Wasm engine has been created here: