Cosmos Full Node

Deploy a full node for cosmos chain

Cosmos hub is the economic centre of the Interchain cosmos ecosystem. Full node is a node that does not build blocks (non-validating) but stores the chain state and allows direct access to the network. NOTE: full node refers to a non-archival implementation of the node.

Hardware requirements

Running a full archive node can be resource intensive, as the state is +1.6TB. for a default full node using quicksync (snapshot) which this guide will cover 1TB would suffice, but 2TB will allow large buffer. current Cosmos Hub mainnet `cosmoshub-4`

Minimum: 16GB / 1TB Storage SSD / 4vCPU (8threads)

Recommended: 32GB RAM / 2TB Storage SSD / 4vCPU (8threads)

Setup device

Install ubuntu 20.04 LTS

Update packages and upgrade device

sudo apt update && sudo apt upgrade -y

Configure swap

32GB RAM is more than suitable for cosmos, however it is a good idea to have swap configured to allow a buffer to be used in Storage. Chain upgrades via cosmovisor can be very memory intensive.

See this guide for how to do this: PENDING

Depending on storage used you can choose to configure 16GB or 32GB and set swappiness parameter to 10 to use swap only when the RAM usage is really high.

Open Ports

PEDNING

1. Install Cosmos Binary

Method 1: Install Script

PENDING

Method 2: Manual Build

Install Dependencies

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

Install Go

Current cosmos binary requires v1.20.+ go, the following method is using a useful go install script by osmosis-labs, installs PATH variables to .bashrc and sets up in a way compatible with the rest of the build. Go binary installs to $HOME/.go

wget -q -O - https://git.io/vQhTU | bash -s -- --version 1.20.3
source $HOME/.bashrc

Alternative method: instructions from cosmos docs here:

Install Cosmos Binary

Find Releases here:

Latest stable release is v10.0.1, must use Go v1.20 to build, to start with this binary must use  statesync or quicksync (snapshot)

git clone -b v10.0.1 https://github.com/cosmos/gaia.git
cd gaia && make install

# confirm install
gaiad version –long

Binary installs to $HOME/go/bin/gaiad

2. Cosmos CLI

PENDING

3. Configure Cosmos Node

Initiate the Chain

This creates the initial config files in working folder `.gaia`

gaiad init <custom-moniker>
moniker can be edited here
moniker can be edited here

Obtain Genesis

cd
wget https://raw.githubusercontent.com/cosmos/mainnet/master/genesis/genesis.cosmoshub-4.json.gz
gzip -d genesis.cosmoshub-4.json.gz
mv genesis.cosmoshub-4.json ~/.gaia/config/genesis.json

Optional: Set seeds and peers

Registry Here: This helps the node find peers quicker by setting persistent peers, syntax as follows:

# Comma separated list of seed nodes to connect to
seeds = "<seed node id 1>@<seed node address 1>:26656,<seed node id 2>@<seed node address 2>:26656"

# Comma separated list of nodes to keep persistent connections to
persistent_peers = "<node id 1>@<node address 1>:26656,<node id 2>@<node address 2>:26656"

Optional: Download quicksync addrbook

wget https://dl2.quicksync.io/json/addrbook.cosmos.json
mv addrbook.cosmos.json ~/.gaia/config/addrbook.json

4. Set up Cosmovisor

Cosmovisor is a process manager developed to relieve node operators of having to manually intervene every time there is an upgrade. Cosmovisor monitors the governance module for upgrade proposals; it will take care of downloading the new binary, stopping the old one, switching to the new one, and restarting. Info on cosmovisor operation: https://github.com/cosmos/cosmos-sdk/tree/main/tools/cosmovisor

Create directories for cosmovisor

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

create directory for corresponding binary version

mkdir -p ~/.gaia/cosmovisor/upgrades/v10/bin

Install Cosmovisor

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

Binary installs to $HOME/go/bin/cosmovisor

Confirm installed with cosmovisor version

The error is because variables are not set, don’t worry as these are set in the service file
The error is because variables are not set, don’t worry as these are set in the service file

Copy binary to working folder in 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 ~/.gaia/cosmovisor/genesis/bin for first start up or an error will occur.

cp $GOPATH/bin/gaiad ~/.gaia/cosmovisor/genesis/bin
cp $GOPATH/bin/gaiad ~/.gaia/cosmovisor/upgrades/v10/bin/

5. Download Chain Data

This install method is using snapshot data, this means downloading the blockchain history directly from a trusted source, many community members host this data example: chainlayer

This is much quicker than syncing and verifying from genesis, which can be done should you decide, but requires a slightly different install method.

Download liblz4-tool to handle the compressed file

sudo apt-get install wget liblz4-tool aria2 jq -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
SNAPURL="https://dl2.quicksync.io/cosmoshub-4-pruned.20230624.0310.tar.lz4"
cd $HOME/.gaia/
wget -O - $SNAPURL | lz4 -d | tar -xvf –
download will look similar
download will look similar

Syncing from genesis: (if not using snapshot)

To sync an archive or full node from scratch, it is important to note that you must start with V4.2.1 (opens new window)and proceed through different upgrades, more info here:

6. Set up SystemD

Setup System service to run cosmosvisor

sudo tee /etc/systemd/system/cosmovisor.service > /dev/null <<EOF  
[Unit]
Description=Gaia Daemon
After=network-online.target

[Service]
Environment="DAEMON_HOME=$HOME/.gaia"
Environment="DAEMON_NAME=gaiad"
Environment="DAEMON_ALLOW_DOWNLOAD_BINARIES=false"
Environment="DAEMON_RESTART_AFTER_UPGRADE=true"
User=$USER
ExecStart=${HOME}/go/bin/cosmovisor run start
Restart=always
RestartSec=3
LimitNOFILE=4096

[Install]
WantedBy=multi-user.target
EOF

Enable and Start service

sudo systemctl daemon-reload
sudo systemctl enable cosmovisor
sudo systemctl start cosmovisor

Check status and logs

sudo systemctl status cosmovisor
journalctl -u cosmovisor -f

Make changes to the service

sudo nano /etc/systemd/system/cosmovisor.service
If configured correctly logs should look similar
If configured correctly logs should look similar
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.