Skip to content

sinascorpion/0glabs-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 

Repository files navigation

image

Official Links

🛠️System Requirements

Ram cpu disk
8GB 4Core 500+ SSD

📌Step 1: Installation packeges and dependencies

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

# Install Go if you need
sudo rm -rf /usr/local/go
curl -L https://go.dev/dl/go1.21.6.linux-amd64.tar.gz | sudo tar -xzf - -C /usr/local
echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> $HOME/.bash_profile
source .bash_profile
go version

📌Step 2: Set moniker and install node

Give your validator a name by which you can find yourself in explorer, put it in ""

MONIKER="" 

After that, insert the following node installation command

# Clone project repository
cd $HOME
rm -rf 0g-chain
git clone https://github.com/0glabs/0g-chain.git
cd 0g-chain
git checkout v0.3.1
git submodule update --init
make install

# Set node CLI configuration
0gchaind config chain-id zgtendermint_16600-2
0gchaind config keyring-backend test
0gchaind config node tcp://localhost:26657

# Initialize the node
0gchaind init "$MONIKER" --chain-id zgtendermint_16600-2

# Download genesis and addrbook files
wget https://snapshots-testnet.unitynodes.com/0gchain-testnet/addrbook.json -O $HOME/.0gchain/config/addrbook.json
wget https://snapshots-testnet.unitynodes.com/0gchain-testnet/genesis.json -O $HOME/.0gchain/config/genesis.json

# Set seeds, peers
PEERS="[email protected]:26656,[email protected]:12656,[email protected]:12656,[email protected]:26656,[email protected]:12656,[email protected]:26656,[email protected]:26656,[email protected]:26646,[email protected]:13456,[email protected]:12656,[email protected]:12656,[email protected]:26656,[email protected]:12656,[email protected]:12656,[email protected]:26656"
SEEDS="[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656"
sed -i 's|^seeds *=.*|seeds = "'$SEEDS'"|; s|^persistent_peers *=.*|persistent_peers = "'$PEERS'"|' $HOME/.0gchain/config/config.toml

# Set minimum gas price
sed -i "s/^minimum-gas-prices *=.*/minimum-gas-prices = \"0ua0gi\"/" $HOME/.0gchain/config/app.toml

# Set pruning
pruning="custom"
pruning_keep_recent="100"
pruning_keep_every="0"
pruning_interval="50"
sed -i -e "s/^pruning *=.*/pruning = \"$pruning\"/" $HOME/.0gchain/config/app.toml
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"$pruning_keep_recent\"/" $HOME/.0gchain/config/app.toml
sed -i -e "s/^pruning-keep-every *=.*/pruning-keep-every = \"$pruning_keep_every\"/" $HOME/.0gchain/config/app.toml
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"$pruning_interval\"/" $HOME/.0gchain/config/app.toml

# Download latest chain data snapshot
curl https://snapshots-testnet.unitynodes.com/0gchain-testnet/0gchain-testnet-latest.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.0gchain

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

### Start service and run node
echo ""
printColor blue "[6/6] Start service and run node"

sudo systemctl daemon-reload
sudo systemctl enable 0gchaind.service
sudo systemctl start 0gchaind.service

📌Step 3: Node Health Check

Follow the commands to check if your node is working properly

  1. Check version
0gchaind version
  1. View sync status
local_height=$(0gchaind status | jq -r .sync_info.latest_block_height); network_height=$(curl -s https://rpc.0gchain-testnet.unitynodes.com/status | jq -r .result.sync_info.latest_block_height); blocks_left=$((network_height - local_height)); echo "Your node height: $local_height"; echo "Network height: $network_height"; echo "Blocks left: $blocks_left"

Blocks left - 0-1 everything is fine and your node catches up with the last block of the network.

  1. Check logs
tail -f -n 100 $HOME/.0gchain/log/chain.log

If your node is installed and fully synchronized with the network, proceed with the creation of the validator.

📝 Create Validator

📌Step 1: Create or import wallet

0gchaind keys add wallet --eth

!Save all information after entering the command, without this you will not be able to restore data to the wallet. SAVE SEED PHRASE (12 words).

Or if you had it before you can recover

  • Replace WALLET_NAME
0gchaind keys add WALLET_NAME --eth --recover

📌Step 2: Request test tokens to your wallet address

We request the private key from our EVM address

0gchaind keys unsafe-export-eth-key wallet # or your wallet name

Press Y and enter We keep this private key with us Go to the metamask and import the wallet using it: We open the Faucet 0G Link 🚰 and request tokens to the metamask address we received

📌Step 3: Check your balance in terminal

0gchaind q bank balances $(0gchaind keys show $WALLET_NAME -a)

📌Step 4: Create validator

Replace YOUR_WALLET with your wallet name

0gchaind tx staking create-validator \
--amount 1000000ua0gi \
--chain-id=zgtendermint_16600-2 \
--pubkey $(0gchaind tendermint show-validator) \
--moniker "$NODE_MONIKER" \
--identity "" \
--website "" \
--details "" \
--commission-rate 0.1 \
--commission-max-rate 0.2 \
--commission-max-change-rate 0.01 \
--min-self-delegation 1 \
--from YOUR_WALLET \
--gas-prices=0.25ua0gi  \
--gas-adjustment=1.5 \
--gas=auto \
-y

📌Step 5: Backup.

cat $HOME/.0gchain/config/priv_validator_key.json

Delegate tokens

0gchaind tx staking delegate $(0gchaind keys show WALLET_NAME --bech val -a) 1000000ua0gi --from WALLET_NAME -y

Useful commands

  • Replace WALLET_NAME

Unjail Node (if your node is jailed)

0gchaind tx slashing unjail --from WALLET_NAME --chain-id zgtendermint_16600-2 --gas-adjustment 1.5 --gas auto --gas-prices 0.00252ua0gi -y

Active Validators list

0gchaind q staking validators -o json --limit=1000 \
| jq '.validators[] | select(.status=="BOND_STATUS_BONDED")' \
| jq -r '.tokens + " - " + .description.moniker' \
| sort -gr | nl

inActive Validators list

0gchaind q staking validators -o json --limit=1000 \
| jq '.validators[] | select(.status=="BOND_STATUS_UNBONDED")' \
| jq -r '.tokens + " - " + .description.moniker' \
| sort -gr | nl

Wallet Balance

0gchaind q bank balances $(0gchaind keys show WALLET_NAME -a)

Your Validator Status

0gchaind q staking validator $(0gchaind keys show WALLET_NAME --bech val -a)

Delete Node

sudo systemctl stop 0gchaind.service
sudo systemctl disable 0gchaind.service
sudo rm /etc/systemd/system/0gchaind.service
rm -rf $HOME/.0gchain $HOME/0g-chain

Check the validators list in Explorer

https://explorer.coinhunterstr.com/0G-Newton/staking

fill out the google form:

https://docs.google.com/forms/d/e/1FAIpQLScsa1lpn43F7XAydVlKK_ItLGOkuz2fBmQaZjecDn76kysQsw/viewform?ts=6617a343

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published