A guide to configuring an RPC node for Sei in a performance-optimized way to maximize the efficiency of your hardware.
In this guide, we’ll explore how to run an RPC node on Sei.
Sei is the fastest Layer-1 blockchain with its quick finality and short block times (clocking in at ~400ms). For those same reasons, a good hardware setup is crucial for running a performant node.
In this specific guide, we’re considering Sei’s unique features and specifically configuring an RPC node in a performance-optimized way to maximize the efficiency of your hardware.
We will deviate from standard Cosmos SDK/Tendermint node setup guides in the following ways:
- Configure the machine with RAID 0
- Build the Sei binary with support for
pebbleDBas the backend database
- Tune system-level settings using
Selecting a Server
Before you can get started, you must order a server from a hosting provider or use your own hardware. We recommend bare-metal, i.e., an isolated server with no virtualization. Some typical providers include:
The minimum recommended specs are:
Next, you will need to configure your disks with RAID 0. RAID 0, also known as striping, improves performance by splitting data across two or more disks, allowing for parallel read/write operations, which can significantly speed up data access times. Some providers offer this configuration option at the time of ordering; with others, you will need to do so manually once your server is provided. Here are sample procedures for OVH Cloud and Hetzner.
Lastly, this guide assumes that you are installing Ubuntu as the operating system, preferably the latest LTS release,
You will need the following:
First, update repositories and upgrade packages:
sudo apt update && sudo apt upgrade
sudo apt install jq build-essential tree curl wget
sudo rm -rf /usr/local/go sudo curl -Ls https://go.dev/dl/go1.20.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`
The output should indicate Go
1.20 is installed successfully.
1. Building the Binary
Now that your server has been provisioned and prerequisites are installed, we can proceed to install Sei.
First, clone the Sei GitHub repository:
git -C $HOME clone https://github.com/sei-protocol/sei-chain
cd into it and check out the release currently in use by the Pacific-1 mainnet:
cd $HOME/sei-chain release=$(curl -s https://chains.cosmos.directory/sei | jq -r '.chain.codebase.recommended_version') git checkout $release
At this point, normally, you might install the binary. In this case, we’ll make a change first: build the binary with support for PebbleDB. PebbleDB is a fast, RocksDB-inspired key-value store that provides improved read/write performance, which is crucial for Sei. PebbleDB offers better compression, quicker pruning, and more efficient memory usage, resulting in less I/O overhead. In our tests, pruning operations decreased in time by > 75%. Reads and writes per second also significantly decreased due to better caching.
go mod edit -replace github.com/tendermint/tm-db=github.com/baabeetaa/tm-db@pebble go mod tidy
Finally, install the
seid binary to your
make BUILD_TAGS=pebbledb LDFLAGS="-w -s -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb" install
Confirm the installation:
seid version --long | head
You should see output similar to the below:
name: sei server_name: <appd> version: xxxxxxxxxxxxxxxxxx commit: xxxxxxxxxxxxxxxxxxxx build_tags: netgo ledger pebbledb, go: go version go1.20 linux/amd64
2. Initialise Sei
Now it’s time to initialize a home directory for Sei. The home directory is where configuration files, databases, and any key materials will be stored.
seid init <node_moniker> --chain-id=pacific-1
This will create a directory structure similar to:
.sei ├── config │ ├── app.toml │ ├── client.toml │ ├── config.toml │ ├── genesis.json │ ├── node_key.json │ └── priv_validator_key.json └── data └── priv_validator_state.json └── wasm └── wasm
3. Preparing Configurations
Now, we need to retrieve the correct genesis.json file of the mainnet (chain-id: pacific-1); this is the initial configuration file for the chain and includes parameters such as initial validators and balances, chain-id, and other network-level parameters. It’s essentially the “genesis block” of the chain.
To do so:
wget -O $HOME/.sei/config/genesis.json https://raw.githubusercontent.com/sei-protocol/testnet/main/pacific-1/genesis.json
Depending on your specific use case, you may wish to turn transaction indexing off. Transaction indexing is a feature that enables users of the RPC to query transactions based on tags, which is beneficial for applications requiring transaction search capabilities. However, it increases storage and resource usage. Validator nodes, for example, do not need this, but it is often necessary for various applications.
Consider your specific use case and whether you want to turn transaction indexing off; the default is ON.
If you choose to disable it:
sed -i 's/indexer = \["kv"\]/indexer = ["null"]/g' $HOME/.sei/config/config.toml
4. Installing Systemd Service
Finally, we will use
systemd as a process manager for Sei. It will be responsible for starting, stopping, and restarting it in case of failures.
Copy and paste the following into your terminal:
cat << EOF | sudo tee /etc/systemd/system/test.service [Unit] Description=Sei Daemon (cosmovisor) After=network-online.target [Service] User=$USER ExecStart=$HOME/go/bin/seid start --db-backend=pebbledb --home $HOME/.sei Restart=on-failure RestartSec=3 LimitNOFILE=infinity [Install] WantedBy=multi-user.target EOF
Verify the systemd unit:
The output should look like this:
[Unit] Description=Sei Daemon After=network-online.target [Service] User=<your_user> ExecStart=<your_user_home>/go/bin/seid start --db-backend=pebbledb -home /home/ubuntu/.sei Restart=on-failure RestartSec=3 LimitNOFILE=infinity [Install] WantedBy=multi-user.target
System-Level Performance Tuning
Once you’ve selected your server and successfully installed Sei we will use the
tuned-adm package to fine-tune kernel-level configurations.
tuned-adm is a system tuning daemon for Linux that can modify system settings to achieve better performance. It has several pre-built tuning models; 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:
Syncing Sei and Starting the Service
Finally, we’re ready to start the Sei node!
We’ll use the
state-sync feature to fetch a recent snapshot from a peer on the network, allowing us to quickly catch up to the chain head.
state-sync operates by querying peers for any snapshots taken within a certain time frame, then downloading one for bootstrapping.
First, we need to define a trusted height, which is a delimiter, after which block we consider snapshots trusted and acceptable for downloading:
Then modify the
$HOME/.sei/config.toml file to reflect this, and enable statesync:
sed -i.bak -e "s|^enable *=.*|enable = true|" $HOME/.sei/config/config.toml sed -i.bak -e "s|^use-p2p *=.*|use-p2p = true|" $HOME/.sei/config/config.toml sed -i.bak -e "s|^trust-height *=.*|trust-height = $trusted_height|" $HOME/.sei/config/config.toml sed -i.bak -e "s|^trust-hash *=.*|trust-hash = \"$trusted_hash\"|" $HOME/.sei/config/config.toml sed -i.bak -e "s|^bootstrap-peers *=.*|bootstrap-peers = \"$peers_stateSync\"|" $HOME/.sei/config/config.toml
Start your node and observe logs:
sudo systemctl daemon-reload sudo systemctl start seid && journalctl -fu seid -o cat
Occasionally, state-sync can fail. If you’re not finding any snapshots or experiencing errors otherwise, you can retry:
cd $HOME/.sei/data sudo systemctl stop seid rm -rf application.db cs.wal snapshots blockstore.db evidence.db state.db ../wasm sudo systemctl start seid && journalctl -fu seid -o cat
Congrats! You’re now running your very own Sei RPC.
DISCLAIMER: This is not financial advice. Staking, delegation, and cryptocurrencies involve a high degree of risk, and there is always the possibility of loss, including the failure of all staked digital assets. Additionally, delegators are at risk of slashing in case of security or liveness faults on some protocols. We advise you to do your due diligence before choosing a validator.