Skip to content

Commit

Permalink
Reth custom testnet (eth-educators#1497)
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdowne authored Sep 1, 2023
1 parent a3a3df2 commit 8715a5d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
3 changes: 1 addition & 2 deletions reth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ services:
- EL_EXTRAS=${EL_EXTRAS:-}
- LOG_LEVEL=${LOG_LEVEL:-info}
- ARCHIVE_NODE=${ARCHIVE_NODE:-}
- NETWORK=${NETWORK}
# Make this RUST_LOG=${LOG_LEVEL:-info},engine=trace when requiring deep debug
- RUST_LOG=${LOG_LEVEL:-info}
- RUST_LOG_STYLE=never
Expand All @@ -46,8 +47,6 @@ services:
- node
- --datadir
- /var/lib/reth
- --chain
- ${NETWORK}
- --metrics
- 0.0.0.0:6060
- --port
Expand Down
1 change: 1 addition & 0 deletions reth/Dockerfile.binary
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install
ca-certificates \
tzdata \
gosu \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
1 change: 1 addition & 0 deletions reth/Dockerfile.source
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install
ca-certificates \
tzdata \
gosu \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
26 changes: 25 additions & 1 deletion reth/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,30 @@ if [[ -O "/var/lib/reth/ee-secret/jwtsecret" ]]; then
chmod 666 /var/lib/reth/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/reth/testnet/${config_dir}" ]; then
mkdir -p /var/lib/reth/testnet
cd /var/lib/reth/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/reth/testnet/${config_dir}/bootnode.txt")"
set +e
__network="--chain=/var/lib/reth/testnet/${config_dir}/genesis.json --bootnodes=${bootnodes}"
else
__network="--chain ${NETWORK}"
fi

# Set verbosity
shopt -s nocasematch
case ${LOG_LEVEL} in
Expand Down Expand Up @@ -59,4 +83,4 @@ fi

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

0 comments on commit 8715a5d

Please sign in to comment.