Skip to main content

How to run up a Berachain node (+ snapshot!)

ยท 3 min read
George
Co-Founder of Ghost

This is a guide on how to run a Berachain ๐Ÿป โ›“๏ธ node for the bArtio testnet.

Berachain nodes consist of a consensus client and an execution client. The consensus client is called beacon-kit and the execution client can be any of the ethereum clients (go-ethereum, reth, nethermind, etc). At Ghost, we run both go-ethereum and reth nodes, and for this guide we'll use reth.

You can run a node that syncs from genesis if you want, or you can use a snapshot that we created that'll help you sync much faster.

Install dependenciesโ€‹

Make sure you your machine has go and rust installed because we'll be compiling beacon-kit and reth

  1. Install go (minimum version v1.22.4)
  2. Install rust (minimum version v1.79.0)

Download snapshotโ€‹

The Ghost team has created a snapshot you can use. The snapshot has both the consensus layer state (for beacon-kit) and the execution layer state (for reth)

sudo apt-get install lz4

mkdir bera
cd bera

wget 'https://public-snapshots.ghostgraph.xyz/bera-testnet-20240815.tar.lz4'

tar --use-compress-program=lz4 -xvf bera-testnet-20240815.tar.lz4

ls bera-snapshot
## you should see:
## beacond-data reth-data

Build the clientsโ€‹

Now lets build the consensus client (beacon-kit) and the execution client (we'll use reth)

## still in bera dir

git clone https://github.com/berachain/beacon-kit/
git clone https://github.com/paradigmxyz/reth

## build beacon-kit which will serve as the consensus client
cd beacon-kit
git checkout v0.2.0-alpha.2
make

## build reth which will serve as the execution client
cd ../reth
git checkout v1.0.1
cargo build --release

Run Rethโ€‹

cd ~/bera/reth/
./target/release/reth node \
--datadir ../bera-snapshot/reth-data \
--chain ../bera-snapshot/beacond-data/config/eth-genesis.json \
--instance 2 \
--http \
--ws

If you have cast installed you can confirm the node is using the snapshot data

$ cast bn -r 'http://localhost:8544'
1517942

Run Beacon-kitโ€‹

cd ~/bera/beacon-kit

## generate priv_validator_key.json and priv_validator_state.json files
## we'll use the beacon-kit init command
## in a temp location and extract just these files

./build/bin/beacond init --home tmp-bera --chain-id 80084 tmp-bartio
cp tmp-bera/config/priv_validator_key.json ../bera-snapshot/beacond-data/config/
cp tmp-bera/data/priv_validator_state.json ../bera-snapshot/beacond-data/data/

## now let's run the consensus client

export [email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,c28827cb96c14c905b127b92065a3fb4cd77d7f6@testnet-seeds.whispernode.com:25456,8a0fbd4a06050519b6bce88c03932bd0a57060bd@beacond-testnet.blacknodes.net:26656,d9903c2f9902243c88f2758fe2e81e305e737fb3@bera-testnet-seeds.nodeinfra.com:26656,[email protected]:26656,cf44af098820f50a1e96d51b7af6861bc961e706@berav2-seeds.staketab.org:5001,6b5040a0e1b29a2cca224b64829d8f3d8796a3e3@berachain-testnet-v2-2.seed.l0vd.com:21656,4f93da5553f0dfaafb620532901e082255ec3ad3@berachain-testnet-v2-1.seed.l0vd.com:61656,[email protected]:26656

./build/bin/beacond start \
--home ../bera-snapshot/beacond-data \
--beacon-kit.engine.jwt-secret-path ../bera-snapshot/reth-data/jwt.hex \
--beacon-kit.engine.rpc-dial-url http://127.0.0.1:8651 \
--p2p.seeds $P2P_SEEDS \
--p2p.seed_mode

Disclaimerโ€‹

This guide is being provided as is. The codebases (beacon-kit, reth) that it references are open source but are not written by this author. They may have bugs. The guide also may have bugs and may not work on your system. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness. It has not been audited and as such there can be no assurance it will work as intended, and users may experience delays, failures, errors, omissions or loss of transmitted information. Nothing in these docs should be construed as investment advice or legal advice for any particular facts or circumstances and is not meant to replace competent counsel. It is strongly advised for you to contact a reputable attorney in your jurisdiction for any questions or concerns with respect thereto. Author is not liable for any use of the foregoing, and users should proceed with caution and use at their own risk.