Berachain

Detailed Installation and Configuration

1. Install Go

Berachain is built using Go, so you'll need to install it first:

wget https://go.dev/dl/go1.19.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.19.linux-amd64.tar.gz
echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.profile
source ~/.profile

2. Install Berachain

git clone https://github.com/berachain/berachain
cd berachain
make install

3. Initialize the node

berad init <your-moniker> --chain-id berachain-testnet

4. Configure genesis and TOML files

cd ~/.berad/config
curl -o genesis.json https://raw.githubusercontent.com/berachain/node-config/main/networks/closed-testnet/archive/config/genesis.json
curl -o app.toml https://raw.githubusercontent.com/berachain/node-config/main/networks/closed-testnet/archive/config/app.toml
curl -o config.toml https://raw.githubusercontent.com/berachain/node-config/main/networks/closed-testnet/archive/config/config.toml

5. Edit config.toml

Open ~/.berad/config/config.toml and make the following changes:

# Comma separated list of seed nodes to connect to
seeds = "1234abcd@seed1.example.com:26656,5678efgh@seed2.example.com:26656"

# Comma separated list of nodes to keep persistent connections to
persistent_peers = "1234abcd@peer1.example.com:26656,5678efgh@peer2.example.com:26656"

# Set this to true to enable the peer-exchange reactor
pex = true

# Maximum number of inbound peers
max_num_inbound_peers = 40

# Maximum number of outbound peers to connect to, excluding persistent peers
max_num_outbound_peers = 10

6. Edit app.toml

Open ~/.berad/config/app.toml and make the following changes:

# The minimum gas prices a validator is willing to accept for processing a transaction
minimum-gas-prices = "0.025ubera"

# Enable API server
[api]
enable = true
address = "tcp://0.0.0.0:1317"

# Enable Prometheus metrics
[telemetry]
enabled = true
prometheus-retention-time = 60

# Enable state sync
[state-sync]
snapshot-interval = 1000
snapshot-keep-recent = 2

7. Create a systemd service file

Create a file named /etc/systemd/system/berad.service:

[Unit]
Description=Berachain Node
After=network-online.target

[Service]
User=bera
ExecStart=/home/bera/go/bin/berad start
Restart=always
RestartSec=3
LimitNOFILE=4096

[Install]
WantedBy=multi-user.target

8. Start the node

sudo systemctl enable berad
sudo systemctl start berad

9. Monitor logs

sudo journalctl -u berad -f

Additional Scripts

Validator Creation Script

Here's a script to create a validator (you'll need to have tokens in your account):

#!/bin/bash

MONIKER="your_moniker"
CHAIN_ID="berachain-testnet"
KEYRING="os"
KEY_NAME="your_key_name"
AMOUNT="1000000ubera"
COMMISSION_RATE="0.10"
COMMISSION_MAX_RATE="0.20"
COMMISSION_MAX_CHANGE_RATE="0.01"
MIN_SELF_DELEGATION="1"

berad tx staking create-validator \
  --amount=$AMOUNT \
  --pubkey=$(berad tendermint show-validator) \
  --moniker=$MONIKER \
  --chain-id=$CHAIN_ID \
  --commission-rate=$COMMISSION_RATE \
  --commission-max-rate=$COMMISSION_MAX_RATE \
  --commission-max-change-rate=$COMMISSION_MAX_CHANGE_RATE \
  --min-self-delegation=$MIN_SELF_DELEGATION \
  --gas="auto" \
  --gas-adjustment=1.5 \
  --gas-prices="0.025ubera" \
  --from=$KEY_NAME \
  --keyring-backend=$KEYRING

Node Status Check Script

Here's a script to check the status of your node:

#!/bin/bash

# Check sync status
CATCHING_UP=$(berad status | jq .SyncInfo.catching_up)
LATEST_BLOCK_HEIGHT=$(berad status | jq .SyncInfo.latest_block_height)
VOTING_POWER=$(berad status | jq .ValidatorInfo.VotingPower)

echo "Node Synced: $CATCHING_UP"
echo "Latest Block: $LATEST_BLOCK_HEIGHT"
echo "Voting Power: $VOTING_POWER"

# Check number of peers
PEER_COUNT=$(berad net info | jq .n_peers)
echo "Number of Peers: $PEER_COUNT"

# Check validator status (if applicable)
VALIDATOR_ADDRESS=$(berad keys show $KEY_NAME --bech val -a)
VALIDATOR_STATUS=$(berad query staking validator $VALIDATOR_ADDRESS --output json)
echo "Validator Status: $VALIDATOR_STATUS"

Last updated