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

OCD eth1 rename #1902

Merged
merged 1 commit into from
Aug 11, 2024
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
6 changes: 3 additions & 3 deletions besu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ services:
- ARCHIVE_NODE=${ARCHIVE_NODE:-}
- NETWORK=${NETWORK}
volumes:
- besu-eth1-data:/var/lib/besu
- besu-el-data:/var/lib/besu
- besu-eth1-data:/var/lib/besu-og
- /etc/localtime:/etc/localtime:ro
- jwtsecret:/var/lib/besu/ee-secret
ports:
Expand All @@ -43,8 +44,6 @@ services:
entrypoint:
- docker-entrypoint.sh
- /opt/besu/bin/besu
- --data-path
- /var/lib/besu
- --p2p-port
- ${EL_P2P_PORT:-30303}
- --rpc-http-enabled
Expand Down Expand Up @@ -92,6 +91,7 @@ services:
command: /bin/sh

volumes:
besu-el-data:
besu-eth1-data:
jwtsecret:

Expand Down
1 change: 1 addition & 0 deletions besu/Dockerfile.binary
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ RUN set -eux; \
gosu nobody true

# Create data mount point with permissions
RUN mkdir -p /var/lib/besu-og && chown -R ${USER}:${USER} /var/lib/besu-og && chmod -R 700 /var/lib/besu-og
RUN mkdir -p /var/lib/besu/ee-secret && chown -R ${USER}:${USER} /var/lib/besu && chmod -R 700 /var/lib/besu && chmod 777 /var/lib/besu/ee-secret

# Cannot assume buildkit, hence no chmod
Expand Down
1 change: 1 addition & 0 deletions besu/Dockerfile.source
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ RUN adduser \
--ingroup "${USER}" \
"${USER}"

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

# Cannot assume buildkit, hence no chmod
Expand Down
11 changes: 9 additions & 2 deletions besu/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ else
__spec=""
fi

# New or old datadir
if [ -d /var/lib/besu-og/database ]; then
__datadir="--data-path /var/lib/besu-og"
else
__datadir="--data-path /var/lib/besu"
fi

if [ -f /var/lib/besu/prune-marker ]; then
rm -f /var/lib/besu/prune-marker
if [ "${ARCHIVE_NODE}" = "true" ]; then
Expand All @@ -73,9 +80,9 @@ if [ -f /var/lib/besu/prune-marker ]; then
fi
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" ${__network} ${__prune} ${EL_EXTRAS} storage trie-log prune
exec "$@" ${__datadir} ${__network} ${__prune} ${EL_EXTRAS} storage trie-log prune
else
# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" ${__network} ${__prune} ${__spec} ${EL_EXTRAS}
exec "$@" ${__datadir} ${__network} ${__prune} ${__spec} ${EL_EXTRAS}
fi
29 changes: 25 additions & 4 deletions ethd
Original file line number Diff line number Diff line change
Expand Up @@ -1361,10 +1361,10 @@ resync-execution() {

case "${value}" in
*erigon.yml* ) __el_volume='erigon-el-data'; __el_client="erigon";;
*geth.yml* ) __el_volume='geth-eth1-data'; __el_client="geth";;
*geth.yml* ) __el_volume='geth-el-data'; __el_client="geth";;
*reth.yml* ) __el_volume='reth-el-data'; __el_client="reth";;
*besu.yml* ) __el_volume='besu-eth1-data'; __el_client="besu";;
*nethermind.yml* ) __el_volume='nm-eth1-data'; __el_client="nethermind";;
*besu.yml* ) __el_volume='besu-el-data'; __el_client="besu";;
*nethermind.yml* ) __el_volume='nethermind-el-data'; __el_client="nethermind";;
* ) echo "You do not appear to be running an execution layer client. Nothing to do."; return 0;;
esac

Expand All @@ -1384,6 +1384,20 @@ resync-execution() {
echo "Stopping ${__el_client} container"
docompose stop execution && docompose rm -f execution
dodocker volume rm "$(dodocker volume ls -q -f "name=${__el_volume}")"
__volume_id=""
if [[ "${__el_volume}" =~ geth-el-data ]]; then
__legacy_volume="$(basename "$(realpath .)")_geth-eth1-data"
__volume_id="$(dodocker volume ls -q -f "name=${__legacy_volume}")"
elif [[ "${__el_volume}" =~ besu-el-data ]]; then
__legacy_volume="$(basename "$(realpath .)")_besu-eth1-data"
__volume_id="$(dodocker volume ls -q -f "name=${__legacy_volume}")"
elif [[ "${__el_volume}" =~ nethermind-el-data ]]; then
__legacy_volume="$(basename "$(realpath .)")_nm-eth1-data"
__volume_id="$(dodocker volume ls -q -f "name=${__legacy_volume}")"
fi
if [ -n "${__volume_id}" ]; then
dodocker volume rm "${__volume_id}"
fi
echo
echo "${__el_client} stopped and database deleted."
echo
Expand Down Expand Up @@ -1467,8 +1481,15 @@ attach-geth() {
echo "You do not appear to be using Geth, aborting."
exit 1
fi
__legacy_datadir=$(dodocker run --rm -v "$(dodocker volume ls -q -f \
"name=$(basename "$(realpath .)")[_-]geth-eth1-data")":"/var/lib/goethereum" \
alpine:3 sh -c 'if [ -d "/var/lib/goethereum/geth/chaindata" ]; then echo true; else echo false; fi')

docompose exec -it execution bash -c "geth attach /var/lib/goethereum/geth.ipc"
if [ "${__legacy_datadir}" = "true" ]; then
docompose exec -it execution bash -c "geth attach /var/lib/goethereum/geth.ipc"
else
docompose exec -it execution bash -c "geth attach /var/lib/geth/geth.ipc"
fi
}


Expand Down
8 changes: 4 additions & 4 deletions geth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ services:
- ANCIENT_DIR=${ANCIENT_DIR:-}
volumes:
- geth-eth1-data:/var/lib/goethereum
- geth-el-data:/var/lib/geth
- ${ANCIENT_DIR:-.nada}:/var/lib/ancient
- /etc/localtime:/etc/localtime:ro
- jwtsecret:/var/lib/goethereum/ee-secret
- jwtsecret:/var/lib/geth/ee-secret
ports:
- ${HOST_IP:-}:${EL_P2P_PORT:-30303}:${EL_P2P_PORT:-30303}/tcp
- ${HOST_IP:-}:${EL_P2P_PORT:-30303}:${EL_P2P_PORT:-30303}/udp
Expand All @@ -51,8 +52,6 @@ services:
- 0.0.0.0
- --http.vhosts=*
- --http.corsdomain=*
- --datadir
- /var/lib/goethereum
- --port
- ${EL_P2P_PORT:-30303}
- --http.port
Expand All @@ -68,7 +67,7 @@ services:
- --pprof.addr
- 0.0.0.0
- --authrpc.jwtsecret
- /var/lib/goethereum/ee-secret/jwtsecret
- /var/lib/geth/ee-secret/jwtsecret
- --authrpc.addr
- 0.0.0.0
- --authrpc.port
Expand All @@ -84,6 +83,7 @@ services:
- metrics.network=${NETWORK}

volumes:
geth-el-data:
geth-eth1-data:
jwtsecret:

Expand Down
3 changes: 2 additions & 1 deletion geth/Dockerfile.binary
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ RUN adduser \
--ingroup "${USER}" \
"${USER}"

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

# Cannot assume buildkit, hence no chmod
COPY --chown=${USER}:${USER} ./docker-entrypoint.sh /usr/local/bin/
Expand Down
3 changes: 2 additions & 1 deletion geth/Dockerfile.source
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ RUN adduser \
--ingroup "${USER}" \
"${USER}"

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

# Cannot assume buildkit, hence no chmod
COPY --from=builder --chown=${USER}:${USER} /src/go-ethereum/build/bin/geth /usr/local/bin/
Expand Down
39 changes: 23 additions & 16 deletions geth/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@
set -euo pipefail

if [ "$(id -u)" = '0' ]; then
chown -R geth:geth /var/lib/goethereum
chown -R geth:geth /var/lib/geth
exec su-exec geth docker-entrypoint.sh "$@"
fi

if [ -n "${JWT_SECRET}" ]; then
echo -n "${JWT_SECRET}" > /var/lib/goethereum/ee-secret/jwtsecret
echo -n "${JWT_SECRET}" > /var/lib/geth/ee-secret/jwtsecret
echo "JWT secret was supplied in .env"
fi

if [[ ! -f /var/lib/goethereum/ee-secret/jwtsecret ]]; then
if [[ ! -f /var/lib/geth/ee-secret/jwtsecret ]]; then
echo "Generating JWT secret"
__secret1=$(head -c 8 /dev/urandom | od -A n -t u8 | tr -d '[:space:]' | sha256sum | head -c 32)
__secret2=$(head -c 8 /dev/urandom | od -A n -t u8 | tr -d '[:space:]' | sha256sum | head -c 32)
echo -n "${__secret1}""${__secret2}" > /var/lib/goethereum/ee-secret/jwtsecret
echo -n "${__secret1}""${__secret2}" > /var/lib/geth/ee-secret/jwtsecret
fi

if [[ -O "/var/lib/goethereum/ee-secret" ]]; then
if [[ -O "/var/lib/geth/ee-secret" ]]; then
# In case someone specifies JWT_SECRET but it's not a distributed setup
chmod 777 /var/lib/goethereum/ee-secret
chmod 777 /var/lib/geth/ee-secret
fi
if [[ -O "/var/lib/goethereum/ee-secret/jwtsecret" ]]; then
chmod 666 /var/lib/goethereum/ee-secret/jwtsecret
if [[ -O "/var/lib/geth/ee-secret/jwtsecret" ]]; then
chmod 666 /var/lib/geth/ee-secret/jwtsecret
fi

__ancient=""
Expand All @@ -41,26 +41,33 @@ if [[ "${NETWORK}" =~ ^https?:// ]]; then
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/goethereum/testnet/${config_dir}" ]; then
mkdir -p /var/lib/goethereum/testnet
cd /var/lib/goethereum/testnet
if [ ! -d "/var/lib/geth/testnet/${config_dir}" ]; then
mkdir -p /var/lib/geth/testnet
cd /var/lib/geth/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/goethereum/testnet/${config_dir}/bootnode.txt")"
networkid="$(jq -r '.config.chainId' "/var/lib/goethereum/testnet/${config_dir}/genesis.json")"
bootnodes="$(paste -s -d, "/var/lib/geth/testnet/${config_dir}/bootnode.txt")"
networkid="$(jq -r '.config.chainId' "/var/lib/geth/testnet/${config_dir}/genesis.json")"
set +e
__network="--bootnodes=${bootnodes} --networkid=${networkid} --http.api=eth,net,web3,debug,admin,txpool"
if [ ! -d "/var/lib/goethereum/geth/chaindata/" ]; then
geth init --state.scheme path --datadir /var/lib/goethereum "/var/lib/goethereum/testnet/${config_dir}/genesis.json"
if [ ! -d "/var/lib/geth/geth/chaindata/" ]; then
geth init --datadir /var/lib/geth "/var/lib/geth/testnet/${config_dir}/genesis.json"
fi
else
__network="--${NETWORK}"
fi

# New or old datadir
if [ -d /var/lib/goethereum/geth/chaindata ]; then
__datadir="--datadir /var/lib/goethereum"
else
__datadir="--datadir /var/lib/geth"
fi

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

# Word splitting is desired for the command line parameters
# shellcheck disable=SC2086
exec "$@" ${__ancient} ${__ipv6} ${__network} ${__prune} ${__verbosity} ${EL_EXTRAS}
exec "$@" ${__datadir} ${__ancient} ${__ipv6} ${__network} ${__prune} ${__verbosity} ${EL_EXTRAS}
6 changes: 3 additions & 3 deletions nethermind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ services:
- AUTOPRUNE_NM=${AUTOPRUNE_NM:-true}
- NETWORK=${NETWORK}
volumes:
- nm-eth1-data:/var/lib/nethermind
- nethermind-el-data:/var/lib/nethermind
- nm-eth1-data:/var/lib/nethermind-og
- /etc/localtime:/etc/localtime:ro
- jwtsecret:/var/lib/nethermind/ee-secret
ports:
Expand All @@ -44,8 +45,6 @@ services:
entrypoint:
- docker-entrypoint.sh
- /nethermind/nethermind
- --datadir
- /var/lib/nethermind
- --Init.WebSocketsEnabled
- "true"
- --Network.DiscoveryPort
Expand Down Expand Up @@ -92,6 +91,7 @@ services:
- metrics.network=${NETWORK}

volumes:
nethermind-el-data:
nm-eth1-data:
jwtsecret:

Expand Down
2 changes: 2 additions & 0 deletions nethermind/Dockerfile.binary
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ RUN adduser \

# This only goes so far. keystore, logs and nethermind_db are volumes and need to be chown'd in the entrypoint
RUN chown -R ${USER}:${USER} /nethermind
RUN mkdir -p /var/lib/nethermind-og && chown -R ${USER}:${USER} /var/lib/nethermind-og \
&& chmod -R 700 /var/lib/nethermind-og
RUN mkdir -p /var/lib/nethermind/ee-secret && chown -R ${USER}:${USER} /var/lib/nethermind \
&& chmod -R 700 /var/lib/nethermind && chmod 777 /var/lib/nethermind/ee-secret

Expand Down
2 changes: 2 additions & 0 deletions nethermind/Dockerfile.source
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ WORKDIR /nethermind
COPY --from=builder --chown=${USER}:${USER} /nethermind/out .

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

Expand Down
9 changes: 8 additions & 1 deletion nethermind/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ else
echo "${__prune}"
fi

# New or old datadir
if [ -d /var/lib/nethermind-og/nethermind_db ]; then
__datadir="--datadir /var/lib/nethermind-og"
else
__datadir="--datadir /var/lib/nethermind"
fi

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