Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Lighthouse beacon node peer #47

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@
path = erigon/erigon
url = https://github.com/roberto-bayardo/erigon
branch = devnet-v3
[submodule "lighthouse"]
path = lighthouse/lighthouse
url = https://github.com/sigp/lighthouse
branch = eip4844
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ devnet-up:
prysm-validator-node\
jaeger-tracing

lighthouse-up:
docker compose up -d\
execution-node\
execution-node-3\
prysm-beacon-node\
prysm-validator-node\
lighthouse-beacon-node-follower

lodestar-up:
docker compose up -d\
execution-node\
Expand Down
52 changes: 52 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ version: '3.4'
volumes:
geth_data:
geth_data2:
geth_data3:
beacon_node_data:
beacon_node_follower_data:
lighthouse_beacon_node_data:

services:
execution-node:
Expand Down Expand Up @@ -38,6 +40,23 @@ services:
source: ./geth/geth-genesis.json
target: /genesis.json

execution-node-3:
depends_on:
- execution-node
build:
context: ./geth
dockerfile: Dockerfile.geth
environment:
PEER: execution-node:30303
GETH_VERBOSITY: 4
ports:
- "8547:8545"
volumes:
- "geth_data3:/db"
- type: bind
source: ./geth/geth-genesis.json
target: /genesis.json

prysm-beacon-node:
depends_on:
- execution-node
Expand Down Expand Up @@ -133,6 +152,39 @@ services:
source: ./shared/chain-config.yml
target: /config/chain-config.yml

lighthouse-beacon-node-follower:
depends_on:
- execution-node-3
- prysm-beacon-node
build:
context: ./lighthouse
dockerfile: Dockerfile.lighthouse
args:
- FEATURES=spec-minimal
environment:
BEACON_NODE_RPC: http://prysm-beacon-node:3500
EXECUTION_NODE_URL: http://execution-node-3:8545
VERBOSITY: debug
TESTNET_DIR: /config
entrypoint: ["run_beacon_node_peer.sh"]
ports:
- "5052:5052"
- "9000:9000"
volumes:
- "lighthouse_beacon_node_data:/chaindata"
- type: bind
source: ./shared/chain-config.yml
target: /config/config.yaml
- type: bind
source: ./lighthouse/deploy_block.txt
target: /config/deploy_block.txt
- type: bind
source: ./lighthouse/run_beacon_node.sh
target: /usr/local/bin/run_beacon_node.sh
- type: bind
source: ./lighthouse/run_beacon_node_peer.sh
target: /usr/local/bin/run_beacon_node_peer.sh

lodestar-beacon-node:
depends_on:
- execution-node
Expand Down
17 changes: 17 additions & 0 deletions lighthouse/Dockerfile.lighthouse
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM rust:1.65.0-bullseye AS builder
RUN apt-get update && apt-get -y upgrade && apt-get install -y cmake libclang-dev protobuf-compiler
COPY lighthouse lighthouse
ARG FEATURES
ENV FEATURES $FEATURES
RUN cd lighthouse && make

FROM ubuntu:22.04
RUN apt-get update && apt-get -y upgrade && apt-get install -y --no-install-recommends \
libssl-dev \
ca-certificates \
curl \
iproute2 \
jq \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local/cargo/bin/lighthouse /usr/local/bin/lighthouse
1 change: 1 addition & 0 deletions lighthouse/deploy_block.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
1 change: 1 addition & 0 deletions lighthouse/lighthouse
Submodule lighthouse added at bc0af7
42 changes: 42 additions & 0 deletions lighthouse/run_beacon_node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/env bash

set -exu -o pipefail

: "${EXECUTION_NODE_URL:-}"
: "${VERBOSITY:-info}"

# wait for the execution node to start
RETRIES=60
i=0
until curl --silent --fail "$EXECUTION_NODE_URL";
do
sleep 1
if [ $i -eq $RETRIES ]; then
echo 'Timed out waiting for execution node'
exit 1
fi
echo 'Waiting for execution node...'
((i=i+1))
done

EXTERNAL_IP=$(ip addr show eth0 | grep inet | awk '{ print $2 }' | cut -d '/' -f1)
NETWORK_PORT=9000
HTTP_PORT=5052

lighthouse \
beacon_node \
--debug-level $VERBOSITY \
--datadir /chaindata \
--purge-db \
--execution-endpoint "$EXECUTION_NODE_URL" \
--execution-jwt-secret-key 0x98ea6e4f216f2fb4b69fff9b3a44842c38686ca685f3f55dc48c5d3fb1107be4 \
--testnet-dir $TESTNET_DIR \
--port $NETWORK_PORT \
--http \
--http-port $HTTP_PORT \
--enable-private-discovery \
--enr-address $EXTERNAL_IP \
--enr-udp-port $NETWORK_PORT \
--enr-tcp-port $NETWORK_PORT \
--subscribe-all-subnets \
--disable-packet-filter $@
37 changes: 37 additions & 0 deletions lighthouse/run_beacon_node_peer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/env bash

set -exu -o pipefail

: "${BEACON_NODE_RPC:-}"
: "${TESTNET_DIR:-}"

# wait for the beacon node to start
RETRIES=60
i=0
until curl --fail --silent "${BEACON_NODE_RPC}/eth/v1/node/health"; do
sleep 1
if [ $i -eq $RETRIES ]; then
echo "Timed out retrieving beacon node p2p addr"
exit 1
fi
echo "waiting for beacon node RPC..."
((i=i+1))
done

# Retrieve the enr of the bootstrap node. We will sync blocks from this peer.
PEER=$(curl --fail "$BEACON_NODE_RPC"/eth/v1/node/identity | jq '.data.enr' | tr -d '"' | tr -d '=')
P2P_ADDRESS=$(curl --fail "$BEACON_NODE_RPC"/eth/v1/node/identity | jq -r .data.p2p_addresses[0])

if [ "$PEER" = "null" ]; then
echo "Unable to start beacon-node: Beacon Node address is unavailable via $BEACON_NODE_RPC}"
exit 1
fi

echo "Retrieving genesis state from beacon node..."
curl --header "Accept: application/octet-stream" --output $TESTNET_DIR/genesis.ssz "${BEACON_NODE_RPC}/eth/v2/debug/beacon/states/genesis"
echo "Genesis state saved to $TESTNET_DIR/genesis.ssz"

run_beacon_node.sh \
--target-peers=1 \
--boot-nodes "$PEER" \
--libp2p-addresses "$P2P_ADDRESS" $@
1 change: 1 addition & 0 deletions shared/chain-config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
PRESET_BASE: 'minimal'
CONFIG_NAME: 'local'

ALTAIR_FORK_EPOCH: 1
Expand Down