This LIP provides a technical explanation of the supported and unsupported WebAssembly (WASM) features in the LEA Virtual Machine. It clarifies which features are enabled to ensure deterministic execution and high security, and which are disabled to prevent non-determinism and potential consensus failures. This document serves as a guide for developers building applications on the LEA platform.
The LEA WebAssembly (WASM) Virtual Machine is a specialized runtime designed for environments that demand high security and deterministic execution, LEA VM's feature set is tailored to ensure that every operation produces an identical result across all nodes in a network, which is critical for achieving consensus. A clear specification of supported features is necessary for developers to build compatible and secure smart contracts.
Based on the requirements for determinism and security, the LEA VM supports a core set of stable, deterministic WebAssembly features while actively disabling experimental or non-deterministic ones.
The LEA VM is optimized for safety and predictability. The following WebAssembly features are considered safe and are supported:
-mbulk-memory: This feature is fully supported. It provides highly efficient methods for managing and manipulating large blocks of memory, such as memory.copy
and memory.fill
. These operations are deterministic and significantly improve performance for memory-intensive tasks without compromising consensus.
-msign-ext: Support for sign-extension operations is included. This allows for the correct and predictable conversion between integer types of different sizes (e.g., from an 8-bit integer to a 32-bit integer), which is a fundamental and stable part of the WebAssembly specification.
-mmultivalue: The LEA VM supports returning multiple values from a single function. This is a widely adopted and stable feature that helps developers write cleaner and more efficient code. For example, a function in Rust returning a tuple (i32, i32)
will compile correctly. To ensure this works when compiling with Clang-based tools (like rustc), the compiler must be configured with the appropriate ABI flags (-Xclang -target-abi -Xclang experimental-mv
).
To maintain determinism and security, the LEA VM explicitly avoids features that could introduce unpredictable behavior or security risks. The following are not supported:
-msimd128: SIMD (Single Instruction, Multiple Data) operations are disabled. While powerful for multimedia and scientific computing, their results can vary subtly across different CPU architectures, making them unsuitable for consensus-critical applications.
-matomics: Threading and atomic operations are not supported. Blockchain smart contracts are single-threaded by design. Introducing atomics or shared memory would break this model and introduce significant complexity and consensus risks.
-mnontrapping-fptoint: This feature, which prevents crashes on invalid floating-point to integer conversions, is disabled. In a deterministic system, such invalid operations must be handled as explicit, predictable traps (errors) rather than producing a default value, which could lead to state divergence.
Experimental Proposals: Any features that are still experimental or subject to change are not supported. This includes:
The selection of WASM features is strictly guided by the core requirements of a blockchain environment: determinism, security, and consensus. The enabled features (bulk-memory
, sign-ext
, multivalue
) are all stable, well-defined, and guaranteed to produce identical results on any compliant hardware. Features like SIMD and atomics are disabled because they can introduce implementation-defined behavior or break the single-threaded execution model, which would make it impossible to guarantee consensus. By restricting the VM to a core, stable, and deterministic subset of WebAssembly, the LEA platform ensures a robust and secure foundation for smart contracts.
This LIP is purely informational and defines the capabilities of the LEA VM. It does not introduce any backwards compatibility issues with the LEA protocol itself.
The feature set described in this LIP is fundamental to the security model of the LEA platform. By disabling non-deterministic and experimental features, the VM reduces the attack surface and prevents a class of vulnerabilities related to state divergence and consensus splits. Adherence to this specified feature set is critical for maintaining the security and integrity of all applications running on the LEA network.
This LIP is licensed under the MIT License, in alignment with the main LEA Project License.