Tutorial: Connect the bloXroute Gateway with Lighthouse and Prysm Consensus Layers

bloXroute Team
6 min readOct 17, 2022

--

By: Chris Cacace, Technical Product Manager

In an earlier article, we learned how to Launch a Full Eth2 Node and Connect with the bloXroute Gateway. In it, we used either Nimbus or Teku as our consensus layers. For this supplementary tutorial, we will connect the bloXroute gateway with the more widely used Lighthouse and Prysm nodes.

Let’s get started!

For this tutorial, the technologies we will be using are:

  • Geth Execution Layer node
  • Prysm or Lighthouse Consensus Layer nodes
  • Docker
  • bloXroute Go-Gateway
  • AWS EC2 (or equivalent) running Ubuntu

Spin up an EC2 Instance and Run Geth

To begin, launch a remote server running Ubuntu that meets the minimum system requirements recommended by Geth. Then, follow the instructions in the Geth docs to install and start Geth on this instance.

For more detailed steps on how to do this, check out our article on how to launch an Eth2 node from scratch.

Once you have Geth properly installed for the first time, it will wait for a properly configured consensus layer to proceed. Once you reach this point, continue to either one of the next steps.

Option 1: Lighthouse — Install and Perform a Trusted Sync

We will use the Lighthouse documentation located here to proceed.

Connect to your remote machine and install Lighthouse following these steps:

  1. Use Homebrew to install Lighthouse

brew install lighthouse

2. Confirm that it was installed properly

lighthouse --help

Next, we will perform a Trusted Sync using an Infura node. This saves time by allowing your beacon node to fetch a recent checkpoint.

We will now run our lighthouse node using a checkpoint sync as explained in the lighthouse documentation :

  1. Create a directory to run lighthouse and change into it

mkdir lighthouse

cd lighthouse

2. Run this command to start your node with a checkpoint sync:

nohup lighthouse bn --checkpoint-sync-url https://mainnet.checkpoint.sigp.io/ --execution -jwt ../.ethereum/geth/jwtsecret --network mainnet --http &

3. Find the process id

ps -e

~ % … 13629 ? 17:06:48 lighthouse …

4. Disown the process. This will allow the program to continue running when the terminal cancels.

disown 13629

Your Lighthouse node will now allow your Geth execution layer to begin syncing if it has not already.

Option 2: Prysm — Install and Perform a Trusted Sync

We will use the Prysm documentation located here to proceed.

First, connect to your remote machine and install Prysm following these steps:

  1. Create a directory to store the prysm script and download it

mkdir prysm && cd prysm

Next, we will create the private key which we will use to boot the Prysm node from. This keeps the node’s peerID consistent between restarts.

  1. Run this command to generate a wallet.

./prysm.sh validator wallet create

2. You should see this if the creation was successful:

~ % [2022–10–14 20:47:12] INFO accounts: Successfully created wallet with ability to import keystores --wallet-dir=/home/ubuntu/.eth2validators/prysm-wallet-v2

3. Navigate to the location of the wallet and open it using vim

cd ../.eth2validators/prysm-wallet-v2/direct/accounts

vim all-accounts.keystore.json

4. Copy the message in checksum. This is your private key

5. Navigate out of this folder and back to the prysm folder

cd ../../../.. && cd prysm

6. Create a new file called key.txt with the private key. Note: this file will not contain an end of line (EOL)

echo -n ‘8a424a138314bc7685dec81afbb97d471bf150eb0f1bc651424293230079cf6b’ > key.txt

We will also need to find our remote machine’s public IP address.

  1. Run this command to get YourOwnPublicIP

curl ifconfig.me

Run this command to start the Prysm node with initial sync and consistent private key for peerID

  1. ./prysm.sh beacon-chain --execution-endpoint=http://127.0.0.1:8551 --jwt-secret=../.ethereum/geth/jwtsecret --checkpoint-sync-url=https://mainnet.infura.io/v3/a1c48218b30b4f178ccee7286e24eeef --p2p-priv-key key.txt --p2p-host-ip=<YourOwnPublicIP>

Your Prysm node will now allow your Geth execution layer to begin syncing if it has not already.

Wait for Geth to fully Sync

The Geth node will start downloading the entire blockchain. If starting from zero, this process will take 2–3 days.

You must wait until the Full Geth node has fully synced and state healed to connect it to the bloXroute Gateway

Build and Attach the bloXroute Gateway

Now that your Geth execution node and Nimbus consensus layer are fully synced, we can build the bloXroute Gateway locally using Docker.

To start, we will obtain the Geth Enode and the Lighthouse/Prysm ENR. Use these commands to obtain the enode:

  1. Connect to the geth console

geth attach

2. Then when the geth console opens, use:

> admin.nodeInfo

3. It should print out:

{enode: “enode://5d1f138db81d0822db5e5b49b332b753e30fb99cb1085477bb618fece476be63712495b037fc14debba54a45caa4482f1ad5e805dc04fa9cdbf4b1f53dc7dbd7@54.237.232.34:30303”,…

Your enode will be passed as a parameter for the bloXroute gateway.

Next, obtain your Lighthouse or Prysm consensus layer’s enr.

  1. Run this curl request for Lighthouse

curl -1s http:/127.0.0.1:5052/eth/v1/node/identity | jq -r ‘.data.enr’

OR

Run this curl request for Prysm

curl -1s http:/127.0.0.1:3500/eth/v1/node/identity | jq -r ‘.data.enr’

2. It should print out (Note: if there are trailing ‘==’, ignore it)

enr:-LK4QGsa2_q-CGS2tAUJ3-FcZpgTmskjoiS3EmoU562wWCtZJdHJXAZOliCzUqAUm8X_L0wXhoRYnxMlYdDdgS88BosBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpBKJsWLAgAAAP__________gmlkgnY0gmlwhDbt6CKJc2VjcDI1NmsxoQLAKZ42wviknv8gK8U-UWSTzJZzmnlYwL540K-_ItkeGoN0Y3CCIyiDdWRwgiMo

With your enode and enr we can build the bloXroute gateway locally following the bloXroute documentation. Note: Make sure the docker is properly installed and up to date.

  1. Pull the latest Gateway image locally using:

docker pull bloxroute/bloxroute-gateway-go

2. Build the Gateway using this command

docker run --name bxgateway-go-ELCL -d -v /Users/christophercacace/Desktop/gateway_logs:/app/bloxroute/logs -v /Users/christophercacace/Desktop/external_gateway:/app/bloxroute/ssl -p 1801:1801 -p 28333:28333 bloxroute/bloxroute-gateway-go --blockchain-network Mainnet --ws --port 1801 --enodes enode://5d1f138db81d0822db5e5b49b332b753e30fb99cb1085477bb618fece476be63712495b037fc14debba54a45caa4482f1ad5e805dc04fa9cdbf4b1f53dc7dbd7@54.237.232.34:30303 --enr enr:-LK4QGsa2_q-CGS2tAUJ3-FcZpgTmskjoiS3EmoU562wWCtZJdHJXAZOliCzUqAUm8X_L0wXhoRYnxMlYdDdgS88BosBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpBKJsWLAgAAAP__________gmlkgnY0gmlwhDbt6CKJc2VjcDI1NmsxoQLAKZ42wviknv8gK8U-UWSTzJZzmnlYwL540K-_ItkeGoN0Y3CCIyiDdWRwgiMo

Now that the Gateway has been created and is running, we will follow the bloXroute documentation to add the Gateway’s enode as a trusted peer to Geth.

  1. Search for “Started p2p networking” in the docker logs to obtain the Gateway’s enode.

My Gateways enode is:

enode://4ffb44c94bfce958c7b2ba4fd3b53f21346186e65aef581b13bb394a99abc5e183c930ab6f16c11e7b51ee3d08a73a100d3a68ad6761a27e296a1762af63d4b7

2. Go to your remote console and attach to the Geth console once again.

geth attach

3. Add the Gateway enode as a trusted peer to Geth

> admin.addTrustedPeer(“enode://4ffb44c94bfce958c7b2ba4fd3b53f21346186e65aef581b13bb394a99abc5e183c930ab6f16c11e7b51ee3d08a73a100d3a68ad6761a27e296a1762af63d4b7”)

4. This should return

true

Next, we will follow the bloXroute documentation to add the Gateway’s as a trusted peer to Nimbus Consensus Layer. To do this, we will need to find your Gateway’s peerID and multi-address.

  1. Search for “Starting P2P beacon node” in the docker logs to obtain the Gateway’s peerID.

My logs read:

time=”2022–09–27T01:12:49.551174" level=info msg=”Starting P2P beacon node: [/ip4/172.17.0.2/tcp/13000 /ip4/<MyIP>/tcp/13000], peer ID: 16Uiu2HAkzW96bU9DZ7XUevQ1jjZKAoiB4SPZao3Lz6WJTrDeu7g7" connType=beacon

2. The multiaddress required is structured like “/ip4/<IPaddressOfGateway>/tcp/13000/p2p/<GatewayPeerID>”

From my own logs I can find /ip4/173.68.187.173/tcp/13000 and peer ID: 16Uiu2HAkzW96bU9DZ7XUevQ1jjZKAoiB4SPZao3Lz6WJTrDeu7g7

The multi-address is: /ip4/173.68.187.173/tcp/13000

The peerID is: 16Uiu2HAkzW96bU9DZ7XUevQ1jjZKAoiB4SPZao3Lz6WJTrDeu7g7

Return to your remote machine running your Lighthouse/Prysm node and kill the process.

  1. Display all of the processes running:

ps -e

2. Find the lighthouse process in the output

~ % 23126 pts/0 00:15:16 lighthouse

OR

Find the prysm process in the output

~ % 50988 pts/4 00:05:14 beacon-chain-v3

3. Kill the process totally:

kill -9 23126

OR

kill -9 50988

Restart the Lighthouse/Prysm node with the added “ — direct-peer” tag:

For Lighthouse:

  1. This command to run the beacon node without hanging up

nohup lighthouse bn --execution-endpoint http://127.0.0.1:8551 --execution-jwt ../.ethereum/geth/jwtsecret --network mainnet --http --trusted-peers 16Uiu2HAkzW96bU9DZ7XUevQ1jjZKAoiB4SPZao3Lz6WJTrDeu7g7 --libp2p-addresses /ip4/173.68.187.173/tcp/13000 &

2. Find the process again and disown it.

ps -e

~ % 23126 pts/0 00:15:16 lighthouse

disown 23126

3. This will generate a nohup.out file, which you can observe in the console using this:

tail -f nohup.out

For Prysm:

  1. This command to run the beacon node without hanging up

nohup ./prysm.sh beacon-chain --execution-endpoint=http://127.0.0.1:8551 --jwt-secret=../.ethereum/geth/jwtsecret --checkpoint-sync url=https://mainnet.infura.io/v3/a1c48218b30b4f178ccee7286e24eeef --p2p-priv-key key.txt &

Note: If you are still having trouble connecting, try increasing the maximum peer count temporarily on your geth and Prysm nodes

2. This will generate a nohup.out file, which you can observe in the console using this:

tail -f nohup.out

Once both the execution and consensus layers are running properly, restart the bloXroute gateway.

It’s done!

Your logs should read this:

~ % INFO [10–07|15:52:53.035] Started P2P networking self=enode://e79647e1ffa5004dba8c93ec27e4cb90f7207234c19de0e0d7a269d9e3fcdbdc2742a897ced3ba42ce0f319ea1627040c5249178ece67642fe166a69f58b9be6@127.0.0.1:0

~ % DEBUG[10–07|15:52:53.218] Adding p2p peer peercount=1 id=7a76e934550cf6a7 conn=staticdial addr=54.237.232.34:30303 name=Geth/v1.10.25-stable…

Conclusion

Your Gateway is now the greatest peer your Eth2 node could ask for. Your node will receive blocks hundreds of milliseconds faster than your competitors, and you will be able to execute trades faster than the competition.

--

--

bloXroute Team
bloXroute Team

Written by bloXroute Team

Scaling blockchains to thousands of on-chain transactions per second. Today.

No responses yet