Skip to content

Commit

Permalink
Prysm custom testnets
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdowne committed Sep 1, 2023
1 parent be4dcc1 commit 05163b5
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 29 deletions.
2 changes: 1 addition & 1 deletion prysm-cl-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ services:
- MEV_NODE=${MEV_NODE}
- CL_EXTRAS=${CL_EXTRAS:-}
- ARCHIVE_NODE=${ARCHIVE_NODE:-}
- NETWORK=${NETWORK}
ports:
- ${HOST_IP:-}${PRYSM_PORT}:${PRYSM_PORT}/tcp
- ${HOST_IP:-}${PRYSM_UDP_PORT}:${PRYSM_UDP_PORT}/udp
Expand Down Expand Up @@ -71,7 +72,6 @@ services:
- ${CL_MAX_PEER_COUNT:-45}
- --verbosity
- ${LOG_LEVEL}
- --${NETWORK}
- --accept-terms-of-use
- --monitoring-host
- 0.0.0.0
Expand Down
2 changes: 1 addition & 1 deletion prysm-vc-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ services:
- GRAFFITI=${GRAFFITI:-}
- DEFAULT_GRAFFITI=${DEFAULT_GRAFFITI:-false}
- WEB3SIGNER=${WEB3SIGNER:-false}
- NETWORK=${NETWORK}
networks:
default:
aliases:
Expand All @@ -49,7 +50,6 @@ services:
- ${CL_NODE:-http://consensus:4000}
- --verbosity
- ${LOG_LEVEL}
- --${NETWORK}
- --accept-terms-of-use
- --monitoring-host
- 0.0.0.0
Expand Down
5 changes: 3 additions & 2 deletions prysm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ services:
- MEV_NODE=${MEV_NODE}
- CL_EXTRAS=${CL_EXTRAS:-}
- ARCHIVE_NODE=${ARCHIVE_NODE:-}
- NETWORK=${NETWORK}
ports:
- ${HOST_IP:-}${PRYSM_PORT}:${PRYSM_PORT}/tcp
- ${HOST_IP:-}${PRYSM_UDP_PORT}:${PRYSM_UDP_PORT}/udp
Expand All @@ -54,6 +55,7 @@ services:
- 0.0.0.0
- --grpc-gateway-port
- ${CL_REST_PORT:-5052}
- --grpc-gateway-corsdomain=*
# Allow larger messages so credential change messages can be sent
- --rpc-max-page-size
- "200000"
Expand All @@ -71,7 +73,6 @@ services:
- ${CL_MAX_PEER_COUNT:-45}
- --verbosity
- ${LOG_LEVEL}
- --${NETWORK}
- --accept-terms-of-use
- --monitoring-host
- 0.0.0.0
Expand All @@ -97,6 +98,7 @@ services:
- GRAFFITI=${GRAFFITI:-}
- DEFAULT_GRAFFITI=${DEFAULT_GRAFFITI:-false}
- WEB3SIGNER=${WEB3SIGNER:-false}
- NETWORK=${NETWORK}
networks:
default:
aliases:
Expand All @@ -113,7 +115,6 @@ services:
- consensus:4000
- --verbosity
- ${LOG_LEVEL}
- --${NETWORK}
- --accept-terms-of-use
- --monitoring-host
- 0.0.0.0
Expand Down
2 changes: 1 addition & 1 deletion prysm/Dockerfile.binary
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ARG USER=prysmconsensus
ARG UID=10002

RUN apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y --no-install-recommends \
ca-certificates curl bash tzdata \
ca-certificates curl bash tzdata git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 1 addition & 1 deletion prysm/Dockerfile.source
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ARG USER=prysmconsensus
ARG UID=10002

RUN apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y --no-install-recommends \
ca-certificates curl bash tzdata \
ca-certificates curl bash tzdata git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
27 changes: 25 additions & 2 deletions prysm/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 prysmvalidator 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/prysm/testnet/${config_dir}" ]; then
mkdir -p /var/lib/prysm/testnet
cd /var/lib/prysm/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="--chain-config-file=/var/lib/prysm/testnet/${config_dir}/config.yaml"
else
__network="--${NETWORK}"
fi

# Check whether we should use MEV Boost
if [ "${MEV_BOOST}" = "true" ]; then
__mev_boost="--enable-builder"
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 "$@" ${__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 "$@" "--graffiti" "${GRAFFITI}" ${__w3s_url} ${__mev_boost} ${__doppel} ${VC_EXTRAS}
exec "$@" ${__network} "--graffiti" "${GRAFFITI}" ${__w3s_url} ${__mev_boost} ${__doppel} ${VC_EXTRAS}
fi
64 changes: 43 additions & 21 deletions prysm/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,32 @@ if [[ -O "/var/lib/prysm/ee-secret/jwtsecret" ]]; then
chmod 666 /var/lib/prysm/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/prysm/testnet/${config_dir}" ]; then
mkdir -p /var/lib/prysm/testnet
cd /var/lib/prysm/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/prysm/testnet/${config_dir}/bootstrap_nodes.txt")"
deploy_block=$(cat "/var/lib/prysm/testnet/${config_dir}/deploy_block.txt")
set +e
__network="--chain-config-file=/var/lib/prysm/testnet/${config_dir}/config.yaml --genesis-state=/var/lib/prysm/testnet/${config_dir}/genesis.ssz \
--enable-debug-rpc-endpoints --bootstrap-node=${bootnodes} --contract-deployment-block=${deploy_block}"
else
__network="--${NETWORK}"
fi

# Check whether we should rapid sync
if [ -n "${RAPID_SYNC_URL:+x}" ]; then
__rapid_sync="--checkpoint-sync-url=${RAPID_SYNC_URL}"
Expand All @@ -42,31 +68,27 @@ else
__prune=""
fi

# Fetch genesis file as needed if beacon
if [[ "$1" =~ ^(beacon-chain)$ ]]; then
if [[ "$*" =~ --prater || "$*" =~ --goerli ]]; then
GENESIS=/var/lib/prysm/genesis.ssz
if [ ! -f "$GENESIS" ]; then
echo "Fetching genesis file for Goerli testnet"
curl -fsSL -o "$GENESIS" https://github.com/eth-clients/eth2-networks/raw/master/shared/prater/genesis.ssz
fi
# Fetch genesis file as needed
if [[ "$*" =~ --prater || "$*" =~ --goerli ]]; then
GENESIS=/var/lib/prysm/genesis.ssz
if [ ! -f "$GENESIS" ]; then
echo "Fetching genesis file for Goerli testnet"
curl -fsSL -o "$GENESIS" https://github.com/eth-clients/eth2-networks/raw/master/shared/prater/genesis.ssz
fi
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" "--genesis-state=$GENESIS" ${__rapid_sync} ${__prune} ${__mev_boost} ${CL_EXTRAS}
elif [[ "$*" =~ --sepolia ]]; then
GENESIS=/var/lib/prysm/genesis.ssz
if [ ! -f "$GENESIS" ]; then
echo "Fetching genesis file for Sepolia testnet"
curl -fsSL -o "$GENESIS" https://github.com/eth-clients/merge-testnets/raw/main/sepolia/genesis.ssz
fi
exec "$@" "--genesis-state=$GENESIS" ${__rapid_sync} ${__prune} ${__mev_boost} ${CL_EXTRAS}
elif [[ "$*" =~ --sepolia ]]; then
GENESIS=/var/lib/prysm/genesis.ssz
if [ ! -f "$GENESIS" ]; then
echo "Fetching genesis file for Sepolia testnet"
curl -fsSL -o "$GENESIS" https://github.com/eth-clients/merge-testnets/raw/main/sepolia/genesis.ssz
fi
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" "--genesis-state=$GENESIS" ${__rapid_sync} ${__prune} ${__mev_boost} ${CL_EXTRAS}
else
exec "$@" "--genesis-state=$GENESIS" ${__rapid_sync} ${__prune} ${__mev_boost} ${CL_EXTRAS}
else
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" ${__rapid_sync} ${__prune} ${__mev_boost} ${CL_EXTRAS}
fi
else # Not the CL / beacon
exec "$@"
exec "$@" ${__network} ${__rapid_sync} ${__prune} ${__mev_boost} ${CL_EXTRAS}
fi

0 comments on commit 05163b5

Please sign in to comment.