Task instrumentation
In order to guarantee a deterministic execution and also to abort execution wherever it exceeds a set amount of resources, Truebit instruments the WebAssembly file to add capabilities.
Last updated
Was this helpful?
In order to guarantee a deterministic execution and also to abort execution wherever it exceeds a set amount of resources, Truebit instruments the WebAssembly file to add capabilities.
Last updated
Was this helpful?
The instrumentation process injects WebAssembly code through the program to watch for resource usage. When the program exceeds a set amount of resources, it signals that error to the and immediately aborts execution.
The first step in the process is called 'Link' and it handles the following tasks to guarantee deterministic execution.
Replace the default WASI interface with the Truebit WASI implementation
Replace WASM bulk memory extension instructions with basic ones.
Replace the hardware floating point number implementation with a deterministic one created by Truebit.
The second step in the process is called 'Limit' and it handles the following tasks to detect resource usage and abort execution wherever it exceeds a set amount.
It limits program execution to a given number of WebAssembly instructions. It allows paying nodes for the execution of up to a maximum number of instructions (the gas). The program won't execute past a given instruction count, even when executing an infinite loop.
It limits stack usage by restricting how much stack memory, in bytes, functions can be used at any given time, including their nested calls.
Sets a maximum amount of nested calls, which limits infinite recursion.