How To Benchmark

To reproduce our benchmark results, you'll need to set up a local node and use the gravity_bench tool for testing.

Step 1: Set up the Gravity Node

  1. Get the Source Code

    First, clone the gravity-sdk repository and check out the branch we recommend for this performance benchmark.

    git clone https://github.com/Galxe/gravity-sdk.git
    cd gravity-sdk
    git checkout reth-v1.4.8
  2. Compile the Node

    Compile the gravity_node binary. Note that the tokio_unstable compile flag is required.

    RUSTFLAGS="--cfg tokio_unstable" make gravity_node
  3. Deploy and Start the Node

    We provide a script to automate the deployment and startup of a single node in mock consensus mode. This script also sets the necessary environment variables for optimal performance.

    You can save this script as start_dev_node.sh and execute it.

    #!/bin/bash
    
    # Add colored log output
    RED='\033[0;31m'
    GREEN='\033[0;32m'
    YELLOW='\033[0;33m'
    BLUE='\033[0;34m'
    NC='\033[0m' # No Color
    
    log_info() {
        echo -e "${GREEN}[INFO]${NC} $1"
    }
    
    log_warn() {
        echo -e "${YELLOW}[WARN]${NC} $1"
    }
    
    log_error() {
        echo -e "${RED}[ERROR]${NC} $1"
    }
    
    # Fixed parameters
    NODE="node1"
    INSTALL_DIR="/tmp"
    
    # Set performance-related environment variables
    export MOCK_CONSENSUS=true
    export RETH_TXPOOL_BATCH_INSERT=1
    export BATCH_INSERT_TIME=50
    export USE_PARALLEL_STATE_ROOT=1
    export USE_STORAGE_CACHE=1
    
    # Terminate any running gravity process
    log_info "Terminating existing gravity processes..."
    pkill -9 "gravity_node" || log_warn "No running gravity_node process found"
    
    # Deploy the node
    log_info "Deploying node $NODE..."
    bash ./deploy_utils/deploy.sh --mode single --install_dir $INSTALL_DIR --node $NODE -v release
    
    # Start the node
    log_info "Starting node $NODE"
    bash $INSTALL_DIR/$NODE/script/start.sh --bin_name gravity_node
    
    log_info "Node started successfully"

    Make the script executable and run it:

    chmod +x start_dev_node.sh
    ./start_dev_node.sh

Step 2: Run the Benchmark Tool

The benchmark tool is available at Galxe/gravity_bench. Clone the project and configure it to connect to your local node.

Configuration

You will need to create a configuration file for the tool (e.g., bench_config.toml) and set the following key parameters:

  • faucet.private_key: The private key of an account to fund the transactions. Ensure this account has a sufficient balance of the native currency. For local testing with Reth's dev genesis.json, you can use the following pre-funded private key:

    ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
  • nodes.rpc_url: The RPC URL of your local node, typically http://127.0.0.1:8545.

  • chain_id: The chain ID for the dev network. When using Reth's dev genesis, this is 1337.

  • target_tps: The target transactions per second for the benchmark, which can be adjusted as needed.

  • enable_swap_token: Set to true to benchmark Uniswap V2 swap transactions, or false for ERC20 transfer transactions.

Once configured, run the benchmark according to the instructions in the gravity_bench repository.

Last updated

Was this helpful?