Fullnode Install
tip: the following commands are executed as root by default. If you are not a root user, please prepend the commands with sudo
Requirements
The minimum hardware requirements for running an 0gchain node are:
Install Tools
apt -q update
apt -qy install curl git jq lz4 build-essential aria2 unzip wget
rm -rf /usr/local/go
curl -Ls https://go.dev/dl/go1.22.0.linux-amd64.tar.gz | sudo tar -xzf - -C /usr/local
eval $(echo 'export PATH=$PATH:/usr/local/go/bin' | sudo tee /etc/profile.d/gobinpath.sh)
eval $(echo 'export PATH=$PATH:$HOME/go/bin' | sudo tee /etc/profile.d/gopath.sh)
Clone and Build 0g
export TAG=v0.2.3
git clone -b v0.2.3 https://github.com/0glabs/0g-chain
cd 0g-chain
git checkout tags/$TAG # Tag the desired version
make install
0gchaind version
0g basic setup
# Set home dir, example: /data/0gchain
export DIR=/data/0gchain
mkdir -pv $DIR
ln -sv $DIR $HOME/.0gchain
0gchaind config chain-id zgtendermint_16600-2
# A moniker is a human-readable name for your node. Moniker can contain only ASCII characters, and cannot exceed 70 characters.
0gchaind init <moniker> --chain-id zgtendermint_16600-2
Set Custom Port
Get Script for <portset.sh>
DIR=$HOME/.0gchain
MIN_GAS=0.0001ua0gi
bash portset.sh $DIR $MIN_GAS 2
Genesis File
DIR=$HOME/.0gchain
curl -Ls https://github.com/0glabs/0g-chain/releases/download/v0.2.3/genesis.json > \
$DIR/config/genesis.json
# verify the correctness of the genesis configuration file
0gchaind validate-genesis
Add Seeds
DIR=$HOME/.0gchain
SEEDS="[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656"
sed -i -e "s|^seeds *=.*|seeds = \"$SEEDS\"|" $DIR/config/config.toml
Address Book
DIR=$HOME/.0gchain
rm -rf $DIR/config/addrbook.json
wget -O $HOME/.0gchain/config/addrbook.json https://files.nodeshub.online/testnet/0g-chain/addrbook.json
Create Service with Cosmovisor
DIR=$HOME/.0gchain
BIN=$(which 0gchaind)
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest
mkdir -pv $DIR/cosmovisor/genesis/bin
ln -sv $DIR/cosmovisor/genesis $DIR/cosmovisor/current
cp $BIN $DIR/cosmovisor/genesis/bin/
tee /etc/systemd/system/0gchain.service > /dev/null << EOF
[Unit]
Description=0gchain node service
After=network-online.target
[Service]
User=$USER
Restart=on-failure
Type=simple
ExecStart=$(which cosmovisor) run start
WorkingDirectory=$DIR
SyslogIdentifier=0gchaind
LimitNOFILE=65545
Environment="DAEMON_NAME=0gchaind"
Environment="DAEMON_HOME=$DIR"
Environment="DAEMON_ALLOW_DOWNLOAD_BINARIES=false"
Environment="DAEMON_LOG_BUFFER_SIZE=512"
Environment="DAEMON_RESTART_AFTER_UPGRADE=true"
Environment="UNSAFE_SKIP_BACKUP=true"
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable 0gchain.service
systemctl start 0gchain.service
journalctl -u 0gchain.service -f -o cat
TIP: Garbage Collection Optimization
To maximize sync speed for validators and other network providers that are running pruning nodes, the following settings are recommended:
Start 0gchaind process with environment variable and value
GOGC=900
; this instructs the golang garbage collector to wait until the heap has grown to 9x it's initial allocated size before running garbage collectionStart 0gchaind process with environment variable
GOMEMLIMIT
set to 66% of the total memory available to the 0gchaind process (e.g.GOMEMLIMIT=40GB
for a node with 64 GB of memory) to ensure garbage collection runs whenever 66% of the total memory is used
Last updated