How To Tune an Initia Full Node For Performance

In this guide we’ll:

  • Set up an Initia Full node with a custom DB backend

  • Tune configuration parameters

  • Tune system-level settings

Assumptions: You have a VPS / bare metal server running Ubuntu >22.04 at hand. While we won’t go over the steps for provisioning a server, we’ll recommend selecting for the recommended specs:

  • CPU: 16 cores

  • Memory: 32GB RAM

  • Disk: 2 TB NVMe/SSD Storage with Write Throughput > 1000 MiBps

  • Bandwidth: 100 Mbps

If on bare-metal, we recommend a RAID0 disk configuration for optimal performance.

System-level performance tuning

We’ll be using the tuned-adm package to fine-tune kernel-level configurations. tuned-adm is a system tuning daemon for Linux that can be used to optimize performance for certain tasks. We find the throughput-performance profile to be the most effective.

First, install tuned-adm and required packages:​

sudo apt install tuned tuned-utils tuned-utils-systemtap

Adjust the existing throughput-performance profile to decrease the likelihood of moving memory to swap:​

sudo sed -i 's/^vm\.swappiness=10$/vm.swappiness=1/' /usr/lib/tuned/throughput-performance/tuned.conf

Enable the profile:

sudo tuned-adm profile throughput-performance

​Verify that the profile is now active:​

tuned-adm active

Installing Initia w/ PebbleDB

PebbleDB is a fast, RocksDB-inspired key-value store that enhances read/write performance. By efficiently moving more operations into memory and improving caching, PebbleDB can reduce disk requirements. It offers better compression, quicker pruning, and more efficient memory usage, resulting in less I/O overhead. In our tests, pruning operation times decreased by over 75%. Additionally, read and write operations per second significantly decreased due to improved caching.

Here, we’ll be using pebbledb in place of the default leveldb

Install pre-requisites

sudo apt install jq build-essential curl wget

Install go

sudo rm -rf /usr/local/go
curl -Ls https://go.dev/dl/go1.22.2.linux-amd64.tar.gz | sudo tar -C /usr/local -xz
echo "" >> $HOME/.profile
echo 'export GOPATH=$HOME/go' >> $HOME/.profile 
echo 'export GOBIN=$GOPATH/bin' >> $HOME/.profile
echo 'export PATH=$PATH:/usr/local/go/bin:$GOBIN' >> $HOME/.profile 
source $HOME/.profile`

Confirm installation

go version

Clone the repo

cd $HOME
git clone https://github.com/initia-labs/initia.git
git checkout v0.2.21 # <-- remember to check for up to date version

Intall Initia Node (initiad).

Usually, you’d run make install to install the binary. Here though, we’ll make some modifications so that the reuslting binary uses pebbledb as its database backend:

go mod edit -replace github.com/cometbft/cometbft-db=github.com/cometbft/cometbft-db@v0.12.0
go mod tidy

make BUILD_TAGS=pebbledb LDFLAGS="-w -s -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb \
 -X github.com/cosmos/cosmos-sdk/version.Version=v0.2.21 \
 -X github.com/cosmos/cosmos-sdk/version.Commit=$(git log -1 --format='%H') \
 -X github.com/cosmos/cosmos-sdk/version.ServerName=initiad \
 -X github.com/cosmos/cosmos-sdk/version.ClientName=initiad \
 -X github.com/cosmos/cosmos-sdk/version.Name=initia \
 -X github.com/cosmos/cosmos-sdk/version.AppName=initia" build

cp build/initiad $GOBIN/initiad

Verify installation

initiad version --long

Initilatise configurations

initiad init pebblenode --chain-id initiation-1
cd $HOME/.initia/config
rm genesis
wget -O genesis.json https://snapshots.polkachu.com/testnet-genesis/initia/genesis.json

Set seeds (h/t polkachu)

seeds="ade4d8bc8cbe014af6ebdf3cb7b1e9ad36f412c0@testnet-seeds.polkachu.com:25756,86bd5cb6e762f673f1706e5889e039d5406b4b90@seed.initia.testnet.node75.org:20456"
sed -i "s/^seeds *=.*/seeds = \"$seeds\"/" $HOME/.initia/config/config.toml

Set minimum gas prices

min_gas_price="0.002uinit,0.002move\/944f8dd8dc49f96c25fea9849f16436dcfa6d564eec802f3ef7f8b3ea85368ff"
sed -i "s/^minimum-gas-prices *=.*/minimum-gas-prices = \"$min_gas_price\"/" $HOME/.initia/config/app.toml

Set pruning to custom

pruning="custom"
pruning_keep_recent="100"
pruning_interval="10"

sed -i "s/^pruning *=.*/pruning = \"$pruning\"/" $HOME/.initia/config/app.toml
sed -i "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"$pruning_keep_recent\"/" $HOME/.initia/config/app.toml
sed -i "s/^pruning-interval *=.*/pruning-interval = \"$pruning_interval\"/" $HOME/.initia/config/app.toml

sed -i -e "s/^min-retain-blocks *=.*/min-retain-blocks = 3000/" ${HOME}/.initia/config/app.toml

Set PebbleDB backend

db_backend="pebbledb"
sed -i "s/^db_backend *=.*/db_backend = \"$db_backend\"/" $HOME/.initia/config/config.toml
sed -i "s/^app-db-backend *=.*/app-db-backend = \"$db_backend\"/" $HOME/.initia/config/app.toml

Install systemd service

sudo tee /etc/systemd/system/initiad.service > /dev/null <<EOF
[Unit]
Description=Initia node Service
After=network.target
[Service]
Type=simple
User=$USER
ExecStart=$GOBIN/initiad start
Restart=on-failure
RestartSec=10
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF

Statesync: save this as a file statesync.sh and execute it

#!/bin/bash

SNAP_RPC="https://rpc.initiation-1.initia.xyz:443"

curl -s $SNAP_RPC/status > /dev/null

if [ $? -ne 0 ]; then
        echo "failed querying rpc, exiting"
        exit
fi
if [ ! -d $HOME/.initia ]; then
        echo "home .initia does not exist, exiting"
        exit
fi
if [ ! -f /etc/systemd/system/initiad.service ]; then
        echo "servvice initiad does not exist, exiting"
        exit
fi

LATEST_HEIGHT=$(curl -s $SNAP_RPC/block | jq -r .result.block.header.height); \
BLOCK_HEIGHT=$((LATEST_HEIGHT - 7500)); \
TRUST_HASH=$(curl -s "$SNAP_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)

sed -i.bak -E "s|^(enable[[:space:]]+=[[:space:]]+).*$|\1true| ; \
s|^(rpc_servers[[:space:]]+=[[:space:]]+).*$|\1\"$SNAP_RPC,$SNAP_RPC\"| ; \
s|^(trust_height[[:space:]]+=[[:space:]]+).*$|\1$BLOCK_HEIGHT| ; \
s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"|" $HOME/.initia/config/config.toml
sudo systemctl stop initiad
if [ -d $HOME/.initia/data ]; then
    mv $HOME/.initia/data/priv_validator_state.json
    $HOME/.initia/priv_validator_state.json
    rm -rf $HOME/.initia/data* $HOME/.initia/wasm*
    mkdir $HOME/.initia/data
    cp $HOME/.initia/priv_validator_state.json
    $HOME/.initia/data/priv_validator_state.json
fi
sudo systemctl start initiad

Fin

Your node should now be syncing via statesync, using pebbleDB! Make sure to open up your firewall to allow incoming traffic on port 26656 as well to increase your peering.

Subscribe to ValiDAO
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.