Installation
Current Version
Port Prefix
v0.4.0
284
Minimum hardware Requirements #
CPU : 4x CPUs
Ram : 8GB RAM
Storage: 100GB of storage (SSD or NVME)
Setting Variables
echo "export WALLET="wallet"" >> $HOME/.bash_profile
echo "export MONIKER="test"" >> $HOME/.bash_profile
echo "export 0g-chain_CHAIN_ID="zgtendermint_16600-2"" >> $HOME/.bash_profile
echo "export 0g-chain_PORT="284"" >> $HOME/.bash_profile
echo "export DAEMON_NAME="0gchaind"" >> $HOME/.bash_profile
echo "export DAEMON_HOME=$HOME/.0gchain"" >> $HOME/.bash_profile
source $HOME/.bash_profile
Install dependencies
sudo apt update && sudo apt upgrade -y && sudo apt-get install make build-essential gcc git jq chrony lz4 tmux unzip bc -y && sudo apt install -y curl git jq lz4 build-essential unzip
INSTALL GO
ver="1.21.3" && \
wget "https://golang.org/dl/go$ver.linux-amd64.tar.gz" && \
sudo rm -rf /usr/local/go && \
sudo tar -C /usr/local -xzf "go$ver.linux-amd64.tar.gz" && \
rm "go$ver.linux-amd64.tar.gz" && \
echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> $HOME/.bash_profile && \
source $HOME/.bash_profile && \
go version
# Adding Go's location to profile
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
Download and build binary
# Clone project repository
cd $HOME
rm -rf bcna
git clone https://github.com/0glabs/0g-chain.git
cd 0g-chain
git checkout v0.4.0
# Build binaries
make build
# Prepare binaries for Cosmovisor
mkdir -p $HOME/.0gchain/cosmovisor/genesis/bin
cp $HOME/go/bin/0gchaind $HOME/.0gchain/cosmovisor/genesis/bin/
# Create application symlinks
sudo ln -s $HOME/.0gchain/cosmovisor/genesis $HOME/.0gchain/cosmovisor/current -f
sudo ln -s $HOME/.0gchain/cosmovisor/current/bin/0gchaind /usr/local/bin/0gchaind -f
Installing Cosmovisor
# Download and install Cosmovisor
go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@latest
# Create service
sudo tee /etc/systemd/system/og.service > /dev/null << EOF
[Unit]
Description=0g-chain node service
After=network-online.target
[Service]
User=$USER
ExecStart=$(which cosmovisor) run start
Restart=on-failure
RestartSec=10
LimitNOFILE=65535
Environment="DAEMON_HOME=$HOME/.0gchain"
Environment="DAEMON_NAME=0gchaind"
Environment="UNSAFE_SKIP_BACKUP=true"
[Install]
WantedBy=multi-user.target
EOF
# Reload Daemon
sudo systemctl daemon-reload
sudo systemctl enable og.service
Initialize Node & Configuring Node Port
# Set node configuration
0gchaind init $MONIKER --chain-id zgtendermint_16600-2
0gchaind config node tcp://localhost:28457
0gchaind config keyring-backend file
# Set custom ports in client.toml
sed -i.bak -e "s%:26457%:${0g-chain_PORT}57%g" $HOME/.0gchain/config/client.toml
# Set custom ports in app.toml
sed -i.bak -e "s%:1317%:${0g-chain_PORT}17%g;
s%:8080%:${0g-chain_PORT}80%g;
s%:9090%:${0g-chain_PORT}90%g;
s%:9091%:${0g-chain_PORT}91%g;
s%:8545%:${0g-chain_PORT}45%g;
s%:8546%:${0g-chain_PORT}46%g;
s%:6065%:${0g-chain_PORT}65%g" $HOME/.0gchain/config/app.toml
# Set custom ports in config.toml file
sed -i.bak -e "s%:26658%:${0g-chain_PORT}58%g;
s%:26657%:${0g-chain_PORT}57%g;
s%:6060%:${0g-chain_PORT}60%g;
s%:26656%:${0g-chain_PORT}56%g;
s%^external_address = \"\"%external_address = \"$(wget -qO- eth0.me):${0g-chain_PORT}56\"%;
s%:26660%:${0g-chain_PORT}60%g" $HOME/.0gchain/config/config.toml
# Download genesis and addrbook
wget -O $HOME/.0gchain/config/genesis.json https://files.nodeshub.online/testnet/0g-chain/genesis.json
wget -O $HOME/.0gchain/config/addrbook.json https://files.nodeshub.online/testnet/0g-chain/addrbook.json
# Add Seeds and Peers
SEEDS=6f6a3a908634b79b6fe7c4988efec2553f188234@0g-chain.seed.nodeshub.online:13056"
PEERS="cd529839591e13f5ed69e9a029c5d7d96de170fe@46.4.55.46:34656,28070a5cf6464c4f1a7716acdace3e7e57f39fd6@75.119.157.128:26646,baeceedd1ec1ba6ce1b6d19bb40f7b571026fb05@75.119.136.242:26646,b2ea93761696d4881e87f032a7f6158c6c25d92c@45.14.194.241:26646,d589ec553a75287d87635a8403f140f53b2f8432@85.239.232.29:13456"
sed -i -e "s/^seeds *=.*/seeds = \"$SEEDS\"/; s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $HOME/.0gchain/config/config.toml
# Set minimum gas price
sed -i -e "s|^minimum-gas-prices *=.*|minimum-gas-prices = \"0ua0gi\"|" $HOME/.0gchain/config/app.toml
# Set pruning and Indexer to Null
sed -i -e "s/^pruning =./pruning = "custom"/" $HOME/.0gchain/config/app.toml sed -i -e "s/^pruning-keep-recent =./pruning-keep-recent = "100"/"
$HOME/.0gchain/config/app.toml sed -i -e "s/^pruning-interval =./pruning-interval = "50"/" $HOME/.0gchain/config/app.toml
sed -i -e "s/^indexer *=.*/indexer = \"null\"/" $HOME/.0gchain/config/config.toml
Download Snapshot - Not Available
sudo systemctl stop og
# Back up priv_validator_state.json if needed
cp ~/.0gchain/data/priv_validator_state.json ~/.0gchain/priv_validator_state.json.backup
# On some tendermint chains
0gchaind unsafe-reset-all --home $HOME/.0gchain --keep-addr-book
# On other tendermint chains
0gchaind tendermint unsafe-reset-all --home $HOME/.0gchain --keep-addr-book
curl https://files.nodeshub.online/testnet/og/snapshot/og_snap.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.0gchain
mv $HOME/.0gchain/priv_validator_state.json.backup $HOME/.0gchain/data/priv_validator_state.json
sudo systemctl restart og && sudo journalctl -u og -f -o cat
Start service and check the logs
sudo systemctl start og.service && sudo journalctl -u og -f -o cat
Last updated