WARK
WebAssembly RunKit, also known as WARK, is a highly efficient tool designed to execute WebAssembly (w/ WASI) modules within a secure sandboxed environment. It can meticulously calculate and report the precise resource usage of the module, including instruction cost and memory utilization.
You can use WARK as a Command-Line Interface (CLI) tool or as a web service, depending on your needs.
Table of Contents
Installation
Docker
If you have Docker installed, you can use the following command to run WARK:
# Run the web service
Cargo
To install WARK using Cargo, use the following command:
Usage
CLI
To run a WebAssembly module using the CLI, use the following command:
Options
You can customize the execution with the following options:
IO
- You can use the
--inputoption to specify the input file path for the program. If you want to use stdin as the input, use-as the input file path. - The stdout of the module will be printed to the stdout of the CLI.
- The stderr of the module will not be printed to the stderr of the CLI. Instead, use the
--stderroption to redirect it to a file. - Unless suppressed with the
--no-reportoption, the resource usage of the module will be printed to the stderr of the CLI.
Web Service
To start the WARK server, use the following command:
You can use the
PORTenvironment variable to specify the port number. The default port number is33000.
To run a WebAssembly module, send a POST request with a JSON object in the body containing the following fields:
The server will respond with a JSON object containing the following fields:
{
}
Cost Table
You can find the cost of each instruction in the src/cost.rs.
If you see
Penalty Instruction [Instruction Name], it means that the specific instruction was not included in the cost table. Therefore, its cost defaults to 1000 points.
Feel free to contribute to this project by submitting pull requests or reporting issues. Your help is always welcomed and appreciated!