Osmosis Full Node

Deploy a full node for Osmosis chain

Document Last Update: 13/09/23

Osmosis is a Cosmos-based chain for decentralized exchange of IBC integrated assets it’s the largest DEX in the Cosmos ecosystem.

Hardware requirements

4vCPU / 32 GB RAM (or equivalent swap file set up) / 1 TB of storage space (min)

To setup Swap space see here:

Setup device

Install ubuntu 20.04 LTS

Update packages and upgrade device

sudo apt update && sudo apt upgrade -y

1. Install Osmosis Binary

Method 1: Install Script (easy)

The script automates the install process

Install script:

This is my own version to automate the steps for ‘Method 2: Manual build’, the steps outlined in this guide.

Install Script by Osmosis Labs:

(Note this currently is not working (but will be updated soon) 20/6/23)

curl -sL https://get.osmosis.zone/install > i.py && python3 i.py

Method 2: Manual build

Install dependencies

sudo apt install git build-essential ufw curl jq snapd make jq tar clang pkg-config libssl-dev –y

Install Go

Install go latest version, if there are issues with the build it may be an older go version is needed for the corresponding osmosis binary, see the command to remove installation for this.

wget -q -O - https://git.io/vQhTU | bash -s -- --version 1.20.5

This script is made by osmosis-labs and installs PATH variables to .bashrc and sets up in a way compatible with the rest of the build. Go binary installs to $HOME/.go

Run source /home/<user>/.bashrc to take effect, the confirm installed with

go version

To remove installation

wget -q -O - https://git.io/vQhTU | bash -s -- --remove

Install Osmosis Binary

Check Osmosis releases here:

cd $HOME
git clone https://github.com/osmosis-labs/osmosis
cd osmosis
git checkout v19.0.0

make install

This installs a working folder .osmosisd with configuration files in .osmosisd/config

Test Binary with osmosisd version this should return the version just installed.

'make' may take a while, it will be successful if version can be returned
'make' may take a while, it will be successful if version can be returned

2. Osmosis CLI

This covers how to interact with the osmosis cli after installing the binary from step 1. This allows you to interact with the chain directly for sending TXs and IBC TXs, By default node endpoint is set to localhost the settings are stored in ~/.osmosisd/config/client.toml

Add RPC node (if not running a node)

You can find public RPC's here: add to a CLI command

--node <nodeurl>:<port>

Alternatively add to config by typing into terminal

osmosisd config node https://rpc.osl.zone:443

Set chain-id and keyring backend

osmosisd config chain-id osmosis-1
osmosisd config keyring-backend test

Set Variables

OSMO_WALLET="NAME OF WALLET"
OSMO_MONIKER="NAME OF CHOICE FOR NODE"

Add a wallet (optional)

This is not required to run a full node but can be added;

# create new
osmosisd keys add $OSMO_WALLET
# to restore from seed
osmosisd keys add $OSMO_WALLET --recover
# other commands
keys list
keys show $OSMO_WALLET

These are some examples, a full list can be queried with osmosisd help, and more information can be found in the docs here:

3. Configure Osmosis Node

Initialize node

osmosisd init $OSMO_MONIKER

Get Genesis

Download and place the genesis file in the osmosis config folder:

wget -O ~/.osmosisd/config/genesis.json https://github.com/osmosis-labs/networks/raw/main/osmosis-1/genesis.json

Seeds, Persistent peers, Address book

Some validators will host these files that can help find peers which can help your node to catch up. Example polkachu

4. Download Chain Data

This install method is using snapshot data, this means downloading the blockchain history directly from a trusted source. This is much quicker than syncing and verifying from genesis, which can be done should you decide, but requires a slightly different install method.


To Sync from genesis (optional)

This means starting from V1 osmosis binary and syncing the entire chain state from block 0, this can be time consuming but is the most trust-less way to join osmosis chain. The blockchain data will be ‘default’ which can consume more space (approx. 700-800GB /20-6-23)

Download V1 of Osmosis:

cd osmosis
git checkout v1.0.0

make install

Option 1: Quicksync

This example is with Quicksync by Chainlayer, which works with default pruning settings.

Download liblz4-tool to handle the compressed file

sudo apt-get install wget liblz4-tool aria2 -y

Using pruned snapshot data, find the URL from here (using one of the hosted examples)

On Download right click and copy clean link
On Download right click and copy clean link
URL=<place URL here>
cd $HOME/.osmosisd/
wget -O - $URL | lz4 -d | tar -xvf -

Option 2: Other Snapshot Providers

many community members host this data example: polkachu

NOTE: pruning settings may need to change, be sure to check with provider

Example: (for polkachu)

app.toml settings

# Prune Type
pruning = "custom"

# Prune Strategy
pruning-keep-recent = "100"
pruning-keep-every = "0"
pruning-interval = "10"

config.toml settings

indexer = "null"

5. Setup SystemD to run Node

Option 1: without Cosmovisor

Create System service to run node as a background service

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

Enable and Start service

sudo systemctl daemon-reload
sudo systemctl enable osmosisd
sudo systemctl start osmosisd

Check status and logs

sudo systemctl status osmosisd
journalctl -u osmosisd -f

Stop service

sudo systemctl stop osmosisd

Make changes to service file

sudo nano /etc/systemd/system/osmosisd.service
Working Node will look something like this
Working Node will look something like this

Check Sync status

curl -s localhost:26657/status | jq .result | jq .sync_info
curl -s localhost:26657/status | grep block_height

Option 2: With Cosmovisor

Cosmovisor: is a process management tool to handle cosmos based chain upgrades seamlessly, it looks for chain upgrades and downloads & installs at the correct block height.

Create Directories for Cosmovisor

cd
mkdir -p ~/.osmosisd/cosmovisor/genesis/bin
mkdir -p ~/.osmosisd/cosmovisor/upgrades 

create directory for corresponding binary version

mkdir -p ~/.osmosisd/cosmovisor/upgrades/v19/bin

Install Cosmovisor binary

go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest

Copy binary to Cosmovisor directory

Note on versions: if using snapshot (this guide) you are downloading the latest binary, with chain data manually downloaded and placed in the correct location, cosmovisor will look from the block height the node is currently on and the corresponding binary in the upgrades folder.  The binary also needs to be placed in ~/.osmosisd/cosmovisor/genesis/bin for first start up or an error will occur.

cp $GOPATH/bin/osmosisd ~/.osmosisd/cosmovisor/genesis/bin
cp $GOPATH/bin/osmosisd ~/.osmosisd/cosmovisor/upgrades/v19/bin/

Setup System Service for Cosmovisor

Create System service to run node as a background service through Cosmovisor

echo "[Unit]
Description=Cosmovisor daemon
After=network-online.target
[Service]
Environment=\"DAEMON_NAME=osmosisd\"
Environment=\"DAEMON_HOME=${HOME}/.osmosisd\"
Environment=\"DAEMON_RESTART_AFTER_UPGRADE=true\"
Environment=\"DAEMON_ALLOW_DOWNLOAD_BINARIES=false\"
Environment=\"DAEMON_LOG_BUFFER_SIZE=512\"
Environment=\"UNSAFE_SKIP_BACKUP=true\"
User=$USER
ExecStart=${HOME}/go/bin/cosmovisor run start
Restart=always
RestartSec=3
LimitNOFILE=infinity
LimitNPROC=infinity
[Install]
WantedBy=multi-user.target
" | sudo tee /lib/systemd/system/cosmovisor.service > /dev/null

Additional Settings to Open up node for API calls

Edit RPC/gRPC server configurations

Edit Configurations to ensure APIs are open and reachable on all servers, to expose externally change to 0.0.0.0 which will listen for requests from any IP.

If configuring with a sub-domain process (setup locally) then localhost should be used, as these API ports would only need to be exposed to the host.

Ports can be changed, if need be but will need to be changed in any other services that connect.

Open RPC: in config.toml

# TCP or UNIX socket address for the RPC server to listen on
laddr = "tcp://0.0.0.0:26657"

# TCP or UNIX socket address for the gRPC server to listen on
# NOTE: This server only supports /broadcast_tx_commit
grpc_laddr = ""

Open REST API: in app.toml

[api]

# Enable defines if the API server should be enabled.
enable = true

# Swagger defines if swagger documentation should automatically be registered.
swagger = false

# Address defines the API server to listen on.
address = "tcp://0.0.0.0:1317"

Open gRPC: in app.toml

[grpc]

# Enable defines if the gRPC server should be enabled.
enable = true

# Address defines the gRPC server address to bind to.
address = "tcp://0.0.0.0:9090"

Add Open all Ports

sudo ufw allow 26657 # RPC
sudo ufw allow 9090 # grpc
sudo ufw allow 1317 # REST 

ensure do not get locked out, if on VPS

sudo ufw allow shh
sudo ufw enable

to change ports edit the port in the configuration files above, this should not be needed when setting up with TLS domain routing as NGIX will manage routing through a specified port, this port is the one you need to make sure to avoid conflict and port forward/open as needed.

More on setting up TLS Certificates here: sub-domains with NGINX

Subscribe to GLCstaked
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.