Skip to content

Commit

Permalink
Add Lighthouse custom testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdowne committed Sep 1, 2023
1 parent 943a375 commit d2586f5
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 19 deletions.
3 changes: 1 addition & 2 deletions lighthouse-cl-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ services:
- ARCHIVE_NODE=${ARCHIVE_NODE:-false}
- IPV6=${IPV6:-false}
- CL_P2P_PORT=${CL_P2P_PORT:-9000}
- NETWORK=${NETWORK}
ports:
- ${HOST_IP:-}${CL_P2P_PORT:-9000}:${CL_P2P_PORT:-9000}/tcp
- ${HOST_IP:-}${CL_P2P_PORT:-9000}:${CL_P2P_PORT:-9000}/udp
Expand All @@ -57,8 +58,6 @@ services:
- 0.0.0.0
- --http-port
- ${CL_REST_PORT:-5052}
- --network
- ${NETWORK}
- --port
- ${CL_P2P_PORT:-9000}
- --target-peers
Expand Down
3 changes: 1 addition & 2 deletions lighthouse-vc-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ services:
- VC_EXTRAS=${VC_EXTRAS:-}
- GRAFFITI=${GRAFFITI:-}
- DEFAULT_GRAFFITI=${DEFAULT_GRAFFITI:-false}
- NETWORK=${NETWORK}
volumes:
- lhvalidator-data:/var/lib/lighthouse
- /etc/localtime:/etc/localtime:ro
Expand All @@ -45,8 +46,6 @@ services:
- /var/lib/lighthouse
- --beacon-nodes
- ${CL_NODE:-http://consensus:5052}
- --network
- ${NETWORK}
- --debug-level=${LOG_LEVEL}
- --metrics
- --metrics-address
Expand Down
6 changes: 2 additions & 4 deletions lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ services:
- ARCHIVE_NODE=${ARCHIVE_NODE:-false}
- IPV6=${IPV6:-false}
- CL_P2P_PORT=${CL_P2P_PORT:-9000}
- NETWORK=${NETWORK}
ports:
- ${HOST_IP:-}${CL_P2P_PORT:-9000}:${CL_P2P_PORT:-9000}/tcp
- ${HOST_IP:-}${CL_P2P_PORT:-9000}:${CL_P2P_PORT:-9000}/udp
Expand All @@ -58,8 +59,6 @@ services:
- 0.0.0.0
- --http-port
- ${CL_REST_PORT:-5052}
- --network
- ${NETWORK}
- --listen-address
- 0.0.0.0
- --port
Expand Down Expand Up @@ -94,6 +93,7 @@ services:
- VC_EXTRAS=${VC_EXTRAS:-}
- GRAFFITI=${GRAFFITI:-}
- DEFAULT_GRAFFITI=${DEFAULT_GRAFFITI:-false}
- NETWORK=${NETWORK}
volumes:
- lhvalidator-data:/var/lib/lighthouse
- /etc/localtime:/etc/localtime:ro
Expand All @@ -110,8 +110,6 @@ services:
- /var/lib/lighthouse
- --beacon-nodes
- ${CL_NODE:-http://consensus:5052}
- --network
- ${NETWORK}
- --debug-level=${LOG_LEVEL}
- --metrics
- --metrics-address
Expand Down
2 changes: 1 addition & 1 deletion lighthouse/Dockerfile.binary
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RUN mkdir -p /var/lib/lighthouse/validators && chown ${USER}:${USER} /var/lib/li

RUN set -eux; \
apt-get update; \
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y gosu ca-certificates tzdata; \
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y gosu ca-certificates tzdata git; \
rm -rf /var/lib/apt/lists/*; \
# verify that the binary works
gosu nobody true
Expand Down
1 change: 1 addition & 0 deletions lighthouse/Dockerfile.source
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install
ca-certificates \
wget \
tzdata \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
27 changes: 25 additions & 2 deletions lighthouse/docker-entrypoint-vc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@ if [ "$(id -u)" = '0' ]; then
exec gosu lhvalidator docker-entrypoint.sh "$@"
fi

if [[ "${NETWORK}" =~ ^https?:// ]]; then
echo "Custom testnet at ${NETWORK}"
repo=$(awk -F'/tree/' '{print $1}' <<< "${NETWORK}")
branch=$(awk -F'/tree/' '{print $2}' <<< "${NETWORK}" | cut -d'/' -f1)
config_dir=$(awk -F'/tree/' '{print $2}' <<< "${NETWORK}" | cut -d'/' -f2-)
echo "This appears to be the ${repo} repo, branch ${branch} and config directory ${config_dir}."
# For want of something more amazing, let's just fail if git fails to pull this
set -e
if [ ! -d "/var/lib/lighthouse/validators/testnet/${config_dir}" ]; then
mkdir -p /var/lib/lighthouse/validators/testnet
cd /var/lib/lighthouse/validators/testnet
git init --initial-branch="${branch}"
git remote add origin "${repo}"
git config core.sparseCheckout true
echo "${config_dir}" > .git/info/sparse-checkout
git pull origin "${branch}"
fi
set +e
__network="--testnet-dir=/var/lib/lighthouse/validators/testnet/${config_dir}"
else
__network="--network=${NETWORK}"
fi

# Check whether we should use MEV Boost
if [ "${MEV_BOOST}" = "true" ]; then
__mev_boost="--builder-proposals"
Expand All @@ -32,9 +55,9 @@ fi
if [ "${DEFAULT_GRAFFITI}" = "true" ]; then
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" ${__mev_boost} ${__beacon_stats} ${__doppel} ${VC_EXTRAS}
exec "$@" ${__network} ${__mev_boost} ${__beacon_stats} ${__doppel} ${VC_EXTRAS}
else
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" "--graffiti" "${GRAFFITI}" ${__mev_boost} ${__beacon_stats} ${__doppel} ${VC_EXTRAS}
exec "$@" ${__network} "--graffiti" "${GRAFFITI}" ${__mev_boost} ${__beacon_stats} ${__doppel} ${VC_EXTRAS}
fi
27 changes: 26 additions & 1 deletion lighthouse/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,31 @@ if [[ -O "/var/lib/lighthouse/ee-secret/jwtsecret" ]]; then
chmod 666 /var/lib/lighthouse/beacon/ee-secret/jwtsecret
fi

if [[ "${NETWORK}" =~ ^https?:// ]]; then
echo "Custom testnet at ${NETWORK}"
repo=$(awk -F'/tree/' '{print $1}' <<< "${NETWORK}")
branch=$(awk -F'/tree/' '{print $2}' <<< "${NETWORK}" | cut -d'/' -f1)
config_dir=$(awk -F'/tree/' '{print $2}' <<< "${NETWORK}" | cut -d'/' -f2-)
echo "This appears to be the ${repo} repo, branch ${branch} and config directory ${config_dir}."
# For want of something more amazing, let's just fail if git fails to pull this
set -e
if [ ! -d "/var/lib/lighthouse/beacon/testnet/${config_dir}" ]; then
mkdir -p /var/lib/lighthouse/beacon/testnet
cd /var/lib/lighthouse/beacon/testnet
git init --initial-branch="${branch}"
git remote add origin "${repo}"
git config core.sparseCheckout true
echo "${config_dir}" > .git/info/sparse-checkout
git pull origin "${branch}"
fi
bootnodes="$(paste -s -d, "/var/lib/lighthouse/beacon/testnet/${config_dir}/bootstrap_nodes.txt")"
set +e
__network="--testnet-dir=/var/lib/lighthouse/beacon/testnet/${config_dir} --boot-nodes=${bootnodes} \
--self-limiter=blob_sidecars_by_range:256/10"
else
__network="--network=${NETWORK}"
fi

# Check whether we should rapid sync
if [ -n "${RAPID_SYNC_URL}" ]; then
__rapid_sync="--checkpoint-sync-url=${RAPID_SYNC_URL}"
Expand Down Expand Up @@ -58,4 +83,4 @@ fi

# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" ${__mev_boost} ${__rapid_sync} ${__prune} ${__beacon_stats} ${__ipv6} ${CL_EXTRAS}
exec "$@" ${__network} ${__mev_boost} ${__rapid_sync} ${__prune} ${__beacon_stats} ${__ipv6} ${CL_EXTRAS}
3 changes: 1 addition & 2 deletions lodestar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ services:
- GRAFFITI=${GRAFFITI:-}
- DEFAULT_GRAFFITI=${DEFAULT_GRAFFITI:-false}
- WEB3SIGNER=${WEB3SIGNER}
- NETWORK=${NETWORK}
volumes:
- lsvalidator-data:/var/lib/lodestar/validators
- /etc/localtime:/etc/localtime:ro
Expand Down Expand Up @@ -120,8 +121,6 @@ services:
- 0.0.0.0
- --logLevel
- ${LOG_LEVEL}
- --network
- ${NETWORK}
- --suggestedFeeRecipient
- ${FEE_RECIPIENT}
- --force
Expand Down
27 changes: 25 additions & 2 deletions lodestar/docker-entrypoint-vc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@ if [ "$(id -u)" = '0' ]; then
exec su-exec lsvalidator docker-entrypoint.sh "$@"
fi

if [[ "${NETWORK}" =~ ^https?:// ]]; then
echo "Custom testnet at ${NETWORK}"
repo=$(awk -F'/tree/' '{print $1}' <<< "${NETWORK}")
branch=$(awk -F'/tree/' '{print $2}' <<< "${NETWORK}" | cut -d'/' -f1)
config_dir=$(awk -F'/tree/' '{print $2}' <<< "${NETWORK}" | cut -d'/' -f2-)
echo "This appears to be the ${repo} repo, branch ${branch} and config directory ${config_dir}."
# For want of something more amazing, let's just fail if git fails to pull this
set -e
if [ ! -d "/var/lib/lodestar/validators/testnet/${config_dir}" ]; then
mkdir -p /var/lib/lodestar/validators/testnet
cd /var/lib/lodestar/validators/testnet
git init --initial-branch="${branch}"
git remote add origin "${repo}"
git config core.sparseCheckout true
echo "${config_dir}" > .git/info/sparse-checkout
git pull origin "${branch}"
fi
set +e
__network="--paramsFile=/var/lib/lodestar/validators/testnet/${config_dir}/config.yaml"
else
__network="--network ${NETWORK}"
fi

# Check whether we should use MEV Boost
if [ "${MEV_BOOST}" = "true" ]; then
__mev_boost="--builder"
Expand Down Expand Up @@ -40,9 +63,9 @@ fi
if [ "${DEFAULT_GRAFFITI}" = "true" ]; then
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" ${__mev_boost} ${__beacon_stats} ${__doppel} ${__w3s_url} ${VC_EXTRAS}
exec "$@" ${__network} ${__mev_boost} ${__beacon_stats} ${__doppel} ${__w3s_url} ${VC_EXTRAS}
else
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" "--graffiti" "${GRAFFITI}" ${__mev_boost} ${__beacon_stats} ${__doppel} ${__w3s_url} ${VC_EXTRAS}
exec "$@" ${__network} "--graffiti" "${GRAFFITI}" ${__mev_boost} ${__beacon_stats} ${__doppel} ${__w3s_url} ${VC_EXTRAS}
fi
2 changes: 1 addition & 1 deletion teku-vc-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ services:
- GRAFFITI=${GRAFFITI:-}
- DEFAULT_GRAFFITI=${DEFAULT_GRAFFITI:-false}
- WEB3SIGNER=${WEB3SIGNER:-false}
- NETWORK=${NETWORK}
networks:
default:
aliases:
Expand All @@ -44,7 +45,6 @@ services:
- --beacon-node-api-endpoints=${CL_NODE:-http://consensus:5052}
- --data-path=/var/lib/teku
- --log-destination=CONSOLE
- --network=${NETWORK}
- --validator-keys=/var/lib/teku/validator-keys:/var/lib/teku/validator-passwords
- --validators-early-attestations-enabled=false
- --validator-api-enabled=true
Expand Down
27 changes: 25 additions & 2 deletions teku/docker-entrypoint-vc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,29 @@ if [ "$(id -u)" = '0' ]; then
exec gosu teku docker-entrypoint.sh "$@"
fi

if [[ "${NETWORK}" =~ ^https?:// ]]; then
echo "Custom testnet at ${NETWORK}"
repo=$(awk -F'/tree/' '{print $1}' <<< "${NETWORK}")
branch=$(awk -F'/tree/' '{print $2}' <<< "${NETWORK}" | cut -d'/' -f1)
config_dir=$(awk -F'/tree/' '{print $2}' <<< "${NETWORK}" | cut -d'/' -f2-)
echo "This appears to be the ${repo} repo, branch ${branch} and config directory ${config_dir}."
# For want of something more amazing, let's just fail if git fails to pull this
set -e
if [ ! -d "/var/lib/teku/testnet/${config_dir}" ]; then
mkdir -p /var/lib/teku/testnet
cd /var/lib/teku/testnet
git init --initial-branch="${branch}"
git remote add origin "${repo}"
git config core.sparseCheckout true
echo "${config_dir}" > .git/info/sparse-checkout
git pull origin "${branch}"
fi
set +e
__network="--network=/var/lib/teku/testnet/${config_dir}/config.yaml"
else
__network="--network=${NETWORK}"
fi

if [ -f /var/lib/teku/teku-keyapi.keystore ]; then
if [ "$(date +%s -r /var/lib/teku/teku-keyapi.keystore)" -lt "$(date +%s --date="300 days ago")" ]; then
rm /var/lib/teku/teku-keyapi.keystore
Expand Down Expand Up @@ -59,9 +82,9 @@ fi
if [ "${DEFAULT_GRAFFITI}" = "true" ]; then
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" ${__w3s_url} ${__mev_boost} ${__doppel} ${VC_EXTRAS}
exec "$@" ${__network} ${__w3s_url} ${__mev_boost} ${__doppel} ${VC_EXTRAS}
else
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" "--validators-graffiti=${GRAFFITI}" ${__w3s_url} ${__mev_boost} ${__doppel} ${VC_EXTRAS}
exec "$@" ${__network} "--validators-graffiti=${GRAFFITI}" ${__w3s_url} ${__mev_boost} ${__doppel} ${VC_EXTRAS}
fi

0 comments on commit d2586f5

Please sign in to comment.