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

Besu custom testnet #1498

Merged
merged 1 commit into from
Sep 1, 2023
Merged
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
5 changes: 1 addition & 4 deletions besu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ services:
- JWT_SECRET=${JWT_SECRET:-}
- EL_EXTRAS=${EL_EXTRAS:-}
- ARCHIVE_NODE=${ARCHIVE_NODE:-}
- NETWORK=${NETWORK}
volumes:
- besu-eth1-data:/var/lib/besu
- /etc/localtime:/etc/localtime:ro
Expand All @@ -44,8 +45,6 @@ services:
- --p2p-port
- ${EL_P2P_PORT:-30303}
- --rpc-http-enabled
- --rpc-http-api
- "WEB3,ETH,NET"
- --rpc-http-host
- 0.0.0.0
- --rpc-http-port
Expand All @@ -68,8 +67,6 @@ services:
- --engine-rpc-port=${EE_PORT:-8551}
- --logging
- ${LOG_LEVEL}
- --network
- ${NETWORK}
- --metrics-enabled
- --metrics-host
- 0.0.0.0
Expand Down
2 changes: 1 addition & 1 deletion besu/Dockerfile.binary
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ USER root
RUN groupmod -g "${GID}" besu && usermod -u "${UID}" -g "${GID}" besu

RUN set -eux; \
apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y gosu ca-certificates tzdata; \
apt-get update && 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 besu/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
tzdata \
gosu \
libjemalloc-dev \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
28 changes: 27 additions & 1 deletion besu/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,32 @@ if [[ -O "/var/lib/besu/ee-secret/jwtsecret" ]]; then
chmod 666 /var/lib/besu/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/besu/testnet/${config_dir}" ]; then
mkdir -p /var/lib/besu/testnet
cd /var/lib/besu/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/besu/testnet/${config_dir}/bootnode.txt")"
set +e
__network="--genesis-file=/var/lib/besu/testnet/${config_dir}/besu.json --bootnodes=${bootnodes} \
--kzg-trusted-setup=/var/lib/besu/testnet/${config_dir}/trusted_setup.txt --Xfilter-on-enr-fork-id=true \
--rpc-http-api=ADMIN,CLIQUE,MINER,ETH,NET,DEBUG,TXPOOL,ENGINE,TRACE,WEB3"
else
__network="--network ${NETWORK} --rpc-http-api WEB3,ETH,NET"
fi

if [ "${ARCHIVE_NODE}" = "true" ]; then
echo "Besu archive node without pruning"
__prune="--data-storage-format=FOREST --sync-mode=FULL"
Expand All @@ -35,4 +61,4 @@ fi

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