Node Installation Guide

Update system and install build tools

sudo apt update

sudo apt-get install git curl build-essential make jq gcc snapd chrony lz4 tmux unzip bc -y

Install Go

rm -rf $HOME/go sudo rm -rf /usr/local/go cd $HOME curl https://dl.google.com/go/go1.19.5.linux-amd64.tar.gz | sudo tar -C/usr/local -zxvf - cat <<'EOF' >>$HOME/.profile export GOROOT=/usr/local/go export GOPATH=$HOME/go export GO111MODULE=on export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin EOF source $HOME/.profile go version

Install Node

cd $HOME

rm -rf c4e-chain

git clone https://github.com/chain4energy/c4e-chain.git

cd c4e-chain

git checkout v1.3.1

make install

c4ed version

Initialize Node

Replace NodeName with your own moniker.

c4ed init ApeironNodes --chain-id=perun-1

Clone reposrepository with chains

git clone https://github.com/chain4energy/c4e-chains.git cd c4e-chains/$CHAINID

Copy genesis file from repo

cp genesis.json ~/.c4e-chain/config/

Change the persistent peers inside config.toml file

sed -e "s|persistent_peers = \".*\"|persistent_peers = \"$(cat .data | grep -oP 'Persistent peers\s+\K\S+')\"|g" ~/.c4e-chain/config/config.toml > ~/.c4e-chain/config/config.toml.tmp mv ~/.c4e-chain/config/config.toml.tmp ~/.c4e-chain/config/config.toml

Change external_address value to contact your node using public ip of your node:

PUB_IP=`curl -s -4 icanhazip.com` sed -e "s|external_address = \".*\"|external_address = \"$PUB_IP:26656\"|g" ~/.c4e-chain/config/config.toml > ~/.c4e-chain/config/config.toml.tmp mv ~/.c4e-chain/config/config.toml.tmp ~/.c4e-chain/config/config.toml

Create Service

sudo tee /etc/systemd/system/c4ed.service > /dev/null <<EOF [Unit] Description=c4ed Daemon After=network-online.target [Service] User=$USER ExecStart=$(which c4ed) start Restart=always RestartSec=3 LimitNOFILE=65535 [Install] WantedBy=multi-user.target EOF sudo systemctl daemon-reload sudo systemctl enable c4ed

Sync With Statesync

sudo systemctl stop c4ed

c4ed tendermint unsafe-reset-all --home ~/.c4e-chain/ --keep-addr-book\

SNAP_RPC="https://rpc-m-c4e.apeironnodes.com:443"

LATEST_HEIGHT=$(curl -s $SNAP_RPC/block | jq -r .result.block.header.height); \

BLOCK_HEIGHT=$((LATEST_HEIGHT - 1000)); \

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

echo $LATEST_HEIGHT $BLOCK_HEIGHT $TRUST_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\"| ; \

s|^(seeds[[:space:]]+=[[:space:]]+).*$|\1\"\"|" ~/.c4e-chain/config/config.toml

more ~/.c4e-chain/config/config.toml | grep 'rpc_servers'

more ~/.c4e-chain/config/config.toml | grep 'trust_height'

more ~/.c4e-chain/config/config.toml | grep 'trust_hash'

Launch Node

sudo systemctl restart c4ed journalctl -u c4ed -f

Last updated