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.

What is the Instrumentation process?

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 wasm-runner and immediately aborts execution.

The first step in the process is called 'Link' and it handles the following tasks to guarantee deterministic execution.

Replace WASI interface

Replace the default WASI interface with the Truebit WASI implementation

Replace Bulk memory instruction

Replace WASM bulk memory extension instructions with basic ones.

Replace FPU Instructions

Replace the hardware floating point number implementation with a deterministic one created by Truebit.

Limit process

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.

Gas Limit

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.

Stack Limit

It limits stack usage by restricting how much stack memory, in bytes, functions can be used at any given time, including their nested calls.

Call Limit

Sets a maximum amount of nested calls, which limits infinite recursion.

Last updated

Was this helpful?