Skip to content

Commit

Permalink
Erigon custom testnet (eth-educators#1499)
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdowne authored Sep 1, 2023
1 parent c0e8df0 commit e0e6816
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
5 changes: 1 addition & 4 deletions erigon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ services:
- JWT_SECRET=${JWT_SECRET}
- EL_EXTRAS=${EL_EXTRAS:-}
- ARCHIVE_NODE=${ARCHIVE_NODE:-}
- NETWORK=${NETWORK}
volumes:
- erigon-el-data:/var/lib/erigon
- /etc/localtime:/etc/localtime:ro
Expand Down Expand Up @@ -57,8 +58,6 @@ services:
- ${ERIGON_TORRENT_PORT:-42069}
- --nat
- any
- --chain
- ${NETWORK}
- --log.console.verbosity
- ${LOG_LEVEL}
- --metrics
Expand All @@ -71,8 +70,6 @@ services:
- ${EL_RPC_PORT}
- --http.vhosts=*
- --http.corsdomain=*
- --http.api
- web3,eth,net,engine
- --ws
# Allow RocketPool >=1.9 watchtower queries
- --rpc.returndata.limit
Expand Down
2 changes: 1 addition & 1 deletion erigon/Dockerfile.binary
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ARG GID=10002

USER root

RUN apk --no-cache add shadow bash su-exec && groupmod -g "${GID}" ${USER} && usermod -u "${UID}" -g "${GID}" ${USER}
RUN apk --no-cache add shadow bash su-exec git jq && groupmod -g "${GID}" ${USER} && usermod -u "${UID}" -g "${GID}" ${USER}

RUN mkdir -p /var/lib/erigon/ee-secret && chown -R ${USER}:${USER} /var/lib/erigon && chmod -R 700 /var/lib/erigon && chmod 777 /var/lib/erigon/ee-secret

Expand Down
2 changes: 1 addition & 1 deletion erigon/Dockerfile.source
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ARG UID=10001
# GID 10002 is deliberate so it can exchange secret with CL
ARG GID=10002

RUN apk add --no-cache libgcc libstdc++ bash ca-certificates tzdata su-exec
RUN apk add --no-cache libgcc libstdc++ bash ca-certificates tzdata su-exec git jq

RUN addgroup \
--gid "${GID}" \
Expand Down
30 changes: 29 additions & 1 deletion erigon/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,34 @@ if [[ -O "/var/lib/erigon/ee-secret/jwtsecret" ]]; then
chmod 666 /var/lib/erigon/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/erigon/testnet/${config_dir}" ]; then
mkdir -p /var/lib/erigon/testnet
cd /var/lib/erigon/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/erigon/testnet/${config_dir}/bootnode.txt")"
networkid="$(jq -r '.config.chainId' "/var/lib/erigon/testnet/${config_dir}/genesis.json")"
set +e
__network="--bootnodes=${bootnodes} --networkid=${networkid} --http.api=eth,erigon,engine,web3,net,debug,trace,txpool,admin"
if [ ! -f /var/lib/erigon/setupdone ]; then
erigon init --datadir /var/lib/erigon "/var/lib/erigon/testnet/${config_dir}/genesis.json"
touch /var/lib/erigon/setupdone
fi
else
__network="--chain ${NETWORK} --http.api web3,eth,net,engine"
fi
# Check for network, and set prune accordingly

if [ "${ARCHIVE_NODE}" = "true" ]; then
Expand All @@ -52,4 +80,4 @@ fi

# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" ${__prune} ${EL_EXTRAS}
exec "$@" ${__network} ${__prune} ${EL_EXTRAS}

0 comments on commit e0e6816

Please sign in to comment.