Determinism
WebAssembly (WASM) is deterministic - it guarantees that the execution of a given module with the same input values will always produce the same output values, regardless of the platform or implementation used to run the module. This means that the execution of a WebAssembly module is predictable and reproducible.
Wasmbox includes a checkbox on the importer which configures the importer pipeline (optimiser and compiler) to allow non-deterministic code.
By default the output of the importer pipeline will be deterministic. Non-determinism must be deliberately enabled.
WASI
WASI provides WebAssembly code with access to a large set of features, some of which may introduce non-determinism. For example the realtime clock provides access to the actual time, which changes every time it is read, this is non-deterministic. All Wasmbox WASI implementations can be made to act deterministically:
- IVirtualRandomSource:
CryptoRandomSourceis truly random (non-deterministic).FastRandomSourceis seeded pseudo-random (deterministic).
- IVirtualClock:
RealtimeClockprovides the real time (non-deterministic).ManualClockonly "ticks" when specifically instructed to (deterministic).
- IVirtualEnvironment:
VirtualEnvironmentis deterministic if the real environment variables are not exposed (PassthroughEnvironmentVariables()).
- IVirtualFileSystem:
VirtualFileSystemis deterministic if the real filesystem is not exposed.
- IVirtualEventPoll:
VirtualEventPolldepends on the clock and the file system, it is deterministic if they are.
- IVirtualProcess:
VirtualProcessis always deterministic.
- IVirtualSocket:
NonFunctionalSocketis always deterministic.
Threads
wasm-threads is a proposed extension to WASM which adds support for multiple execution threads. It is not currently supported within Wasmbox.