How To Benchmark
This document is a step-by-step guide for running and benchmarking gravity_bench using WSL (Ubuntu) on Windows. It covers two scenarios:
Local node (RPC:
http://127.0.0.1:8545, typicallychainId = 1337)Connecting to Devnet (L1) (
https://rpc-devnet.gravity.xyz, get thechainIdviaeth_chainId)
Tip: Store your source code inside the Linux filesystem (e.g., ~/code) rather than /mnt/c — builds will be much faster.
NOTE (Native Ubuntu/Linux): If you already run Ubuntu (or another Linux distro) natively, skip section 0 Install WSL + Ubuntu and execute all commands in your normal shell. Package names/commands are the same (tested on Ubuntu 22.04/24.04).
Table of Contents
0. Install WSL + Ubuntu
Open PowerShell as Administrator:
Reboot, launch Ubuntu, and create your user/password.
(Optional) Enable systemd for broader service compatibility:
Then restart your Ubuntu terminal.
1. Base dependencies (Ubuntu in WSL)
This set prevents common build/runtime errors related to libudev.pc/pkg-config (for hidapi), missing python, and Node.js/NPM for contract dependencies.
2. Install Rust
3. (Optional) Local Gravity node
Build and start a single mock-consensus node:
Create start_dev_node.sh in the gravity-sdk root:
Make it executable and run it:
Verify RPC is running:
4. Install & prepare gravity_bench
gravity_benchThe setup script automates the creation of a Python virtual environment, installation of dependencies (pip, npm), and cloning of required repositories (Uniswap).
5. bench_config.toml examples
bench_config.toml examplesCreate bench_config.toml in the gravity_bench root. Choose one of the following templates.
5.A) Devnet (recommended to start)
Set chain_id to the value returned by the RPC endpoint (see Useful checks).
5.B) Local node (WSL, chainId 1337)
Rules:
accounts.num_accounts≥target_tpsperformance.num_senders≤accounts.num_accounts
6. Run the benchmark
The setup.sh script should have activated the Python virtual environment. If you open a new terminal, activate it manually with source .venv/bin/activate.
You should see:
Contract compilation & deployment logs.
Startup messages for the Producer/Consumer model.
Periodic tables with RPC and benchmark plan statistics.
7. (Optional) Enable Uniswap swaps
The
setup.shscript should have already downloaded the necessary contracts. You can verify they exist:In your
bench_config.toml, changeenable_swap_tokento true:Run the benchmark again. The tool will now deploy Uniswap contracts and include token swaps in its transaction load. Note that you need rerun the gravity_node to get a fresh deployment.
8. Useful checks
Get chainId from an RPC endpoint:
Check an address balance:
If you edit configuration files from Windows, run dos2unix bench_config.toml to remove \r carriage return characters.
9. Common errors & quick fixes
libudev.pc/hidapi/pkg-configerror during buildFix:
sudo apt install -y libudev-dev libusb-1.0-0-dev pkg-config
python: command not foundFix:
sudo apt install -y python-is-python3
ModuleNotFoundError: No module named 'web3'The
setup.shscript should prevent this. If it occurs, ensure you are in the correct directory (~/code/gravity_bench) and runsource setup.shagain.
SolcErroror missing contract sources (Uniswap, OpenZeppelin)The
setup.shscript handles this. If you suspect an issue, you can remove thecontractsandnode_modulesdirectories and rerunsource setup.sh.
CRLF (
\r) / “smart quotes” inbench_config.tomlFix: Run
dos2unix bench_config.tomland ensure you are using plain ASCII quotes (").
insufficient funds for gas * price + valueOn Devnet: Try increasing
faucet.wait_duration_secs.On a local node: This often indicates a stale state (e.g., incorrect nonces or depleted balances from a previous run). The most reliable fix is to completely restart your local
gravity_nodeto get a fresh deployment:
assertion failed: accounts.num_accounts >= target_tpsIn
bench_config.toml, increaseaccounts.num_accountsto be greater than or equal totarget_tps.
Wrong network / Connection refused
Verify the
rpc_urlin your config is correct and accessible. For local nodes, ensure thegravity_nodeprocess is running. Check thechain_idmatches what the RPC returns.
10. Stop & exit
Stop the local node:
Deactivate Python venv:
Last updated
Was this helpful?

