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, typically chainId = 1337)

  • Connecting to Devnet (L1) (https://rpc-devnet.gravity.xyz, get the chainId via eth_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

The 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

Create bench_config.toml in the gravity_bench root. Choose one of the following templates.

Set chain_id to the value returned by the RPC endpoint (see Useful checks).

5.B) Local node (WSL, chainId 1337)

Rules:

  • accounts.num_accountstarget_tps

  • performance.num_sendersaccounts.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:

  1. Contract compilation & deployment logs.

  2. Startup messages for the Producer/Consumer model.

  3. Periodic tables with RPC and benchmark plan statistics.

7. (Optional) Enable Uniswap swaps

  1. The setup.sh script should have already downloaded the necessary contracts. You can verify they exist:

  2. In your bench_config.toml, change enable_swap_token to true:

  3. 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-config error during build

    • Fix: sudo apt install -y libudev-dev libusb-1.0-0-dev pkg-config

  • python: command not found

    • Fix: sudo apt install -y python-is-python3

  • ModuleNotFoundError: No module named 'web3'

    • The setup.sh script should prevent this. If it occurs, ensure you are in the correct directory (~/code/gravity_bench) and run source setup.sh again.

  • SolcError or missing contract sources (Uniswap, OpenZeppelin)

    • The setup.sh script handles this. If you suspect an issue, you can remove the contracts and node_modules directories and rerun source setup.sh.

  • CRLF (\r) / “smart quotes” in bench_config.toml

    • Fix: Run dos2unix bench_config.toml and ensure you are using plain ASCII quotes (").

  • insufficient funds for gas * price + value

    • On 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_node to get a fresh deployment:

  • assertion failed: accounts.num_accounts >= target_tps

    • In bench_config.toml, increase accounts.num_accounts to be greater than or equal to target_tps.

  • Wrong network / Connection refused

    • Verify the rpc_url in your config is correct and accessible. For local nodes, ensure the gravity_node process is running. Check the chain_id matches what the RPC returns.

10. Stop & exit

Stop the local node:

Deactivate Python venv:

Last updated

Was this helpful?