diff --git a/ephemery/ephemery-config.sh b/ephemery/ephemery-config.sh index 9cabf048..c7988925 100755 --- a/ephemery/ephemery-config.sh +++ b/ephemery/ephemery-config.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Fetches the network config of the current Ephemery iteration and prints the directory holding # config.yaml, genesis.ssz, genesis.json, bootstrap_nodes.txt, enodes.txt and deposit_contract_block.txt. -# Prysm, Geth, Nimbus, Lighthouse, Erigon and Nethermind have no built-in Ephemery. The genesis repo +# Prysm, Geth, Nimbus, Lighthouse, Erigon, Reth and Nethermind have no built-in Ephemery. The genesis repo # does not keep these files in git, they come as a release per iteration, so the git-based custom # network path cannot fetch them. # Each iteration's retention.vars has its genesis time and reset interval. An iteration fetched before @@ -9,7 +9,7 @@ # release, and waits for one that is live if there is none yet: a node on an ended iteration is useless. # Call with the directory to keep iterations in. Messages go to stderr, the path to stdout. # Client images get it from the "ephemery" additional build context, see geth.yml, prysm.yml, -# nimbus.yml, nimbus-el.yml, lighthouse.yml, erigon.yml and nethermind.yml. +# nimbus.yml, nimbus-el.yml, lighthouse.yml, erigon.yml, reth.yml and nethermind.yml. set -Eeuo pipefail base_dir="$1" diff --git a/ethd b/ethd index 051ab53f..fb6f11d1 100755 --- a/ethd +++ b/ethd @@ -7045,6 +7045,7 @@ __query_execution_client() { choices+=("besu.yml" "Besu (Java)") choices+=("erigon.yml" "Erigon (Go)") choices+=("nethermind.yml" "Nethermind (.NET)") + choices+=("reth.yml" "Reth (Rust)") fi elif [[ "${arch}" =~ (aarch64|arm64) ]] ; then choices+=("ethrex.yml" "Ethrex (Rust)") diff --git a/reth.yml b/reth.yml index cb55d5d3..67375d07 100644 --- a/reth.yml +++ b/reth.yml @@ -11,6 +11,8 @@ services: restart: "unless-stopped" build: context: ./reth + additional_contexts: + ephemery: ./ephemery dockerfile: ${RETH_DOCKERFILE} args: - BUILD_TARGET=${RETH_SRC_BUILD_TARGET:-main} diff --git a/reth/Dockerfile.binary b/reth/Dockerfile.binary index 36e6cb97..516cfd50 100644 --- a/reth/Dockerfile.binary +++ b/reth/Dockerfile.binary @@ -1,4 +1,4 @@ -# hadolint global ignore=DL3007,DL3008,DL3059 +# hadolint global ignore=DL3007,DL3008,DL3022,DL3059 ARG DOCKER_TAG=latest ARG DOCKER_REPO=ghcr.io/paradigmxyz/reth @@ -21,6 +21,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install git-lfs \ wget \ jq \ + curl \ && gosu nobody true \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* @@ -37,6 +38,7 @@ RUN mkdir -p /var/lib/reth/ee-secret && chown -R ${USER}:${USER} /var/lib/reth & # Cannot assume buildkit, hence no chmod COPY --chown=${USER}:${USER} ./docker-entrypoint.sh /usr/local/bin/ +COPY --from=ephemery --chown=${USER}:${USER} ephemery-config.sh /usr/local/bin/ # Belt and suspenders RUN chmod -R 755 /usr/local/bin/* diff --git a/reth/Dockerfile.source b/reth/Dockerfile.source index d293d89c..9d4df2c6 100644 --- a/reth/Dockerfile.source +++ b/reth/Dockerfile.source @@ -1,4 +1,4 @@ -# hadolint global ignore=DL3007,DL3008,DL3059,DL4006 +# hadolint global ignore=DL3007,DL3008,DL3022,DL3059,DL4006 # Build reth in a stock rust container FROM rust:trixie AS builder @@ -58,6 +58,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install git-lfs \ wget \ jq \ + curl \ && gosu nobody true \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* @@ -78,6 +79,7 @@ RUN mkdir -p /var/lib/reth/ee-secret && chown -R ${USER}:${USER} /var/lib/reth & # Cannot assume buildkit, hence no chmod COPY --from=builder --chown=${USER}:${USER} /src/bin/reth /usr/local/bin/ COPY --chown=${USER}:${USER} ./docker-entrypoint.sh /usr/local/bin/ +COPY --from=ephemery --chown=${USER}:${USER} ephemery-config.sh /usr/local/bin/ # Belt and suspenders RUN chmod -R 755 /usr/local/bin/* diff --git a/reth/docker-entrypoint.sh b/reth/docker-entrypoint.sh index e25aab3f..84d953ed 100755 --- a/reth/docker-entrypoint.sh +++ b/reth/docker-entrypoint.sh @@ -44,7 +44,25 @@ if [[ -O /var/lib/reth/ee-secret/jwtsecret ]]; then chmod 666 /var/lib/reth/ee-secret/jwtsecret fi -if [[ "${NETWORK}" =~ ^https?:// ]]; then +config_dir_path="" +if [[ "${NETWORK}" = "ephemery" ]]; then + config_dir_path="$(ephemery-config.sh /var/lib/reth/testnet/ephemery)" + # A new iteration has a new genesis, and the chain data of the old one is for a dead chain. + # ee-secret is the JWT secret volume and testnet holds the Ephemery configs; both stay. + __iteration="$(basename "$(dirname "${config_dir_path}")")" + if [[ -f /var/lib/reth/ephemery-iteration ]]; then + __old_iteration="$(cat /var/lib/reth/ephemery-iteration)" + if [[ ! "${__old_iteration}" = "${__iteration}" ]]; then + echo "Ephemery reset from ${__old_iteration} to ${__iteration}, removing the old chain data" + find /var/lib/reth -mindepth 1 -maxdepth 1 ! -name ee-secret ! -name testnet \ + ! -name ephemery-iteration -exec rm -rf {} + + if [[ -n "${STATIC_DIR}" && ! "${STATIC_DIR}" = ".nada" ]]; then + find /var/lib/static -mindepth 1 -maxdepth 1 -exec rm -rf {} + + fi + fi + fi + echo "${__iteration}" > /var/lib/reth/ephemery-iteration +elif [[ "${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) @@ -60,6 +78,8 @@ if [[ "${NETWORK}" =~ ^https?:// ]]; then git pull origin "${branch}" fi config_dir_path="/var/lib/reth/testnet/${config_dir}" +fi +if [[ -n "${config_dir_path}" ]]; then if [[ -f "${config_dir_path}/enodes.txt" ]]; then bootnodes="$(paste -sd, "${config_dir_path}/enodes.txt")" else @@ -219,7 +239,7 @@ if [[ -n "${__prune}" ]]; then fi if [[ -f /var/lib/reth/repair-trie ]]; then - if [[ "${NETWORK}" =~ ^https?:// ]]; then + if [[ -n "${config_dir_path}" ]]; then echo "Can't repair database on custom network" rm -f /var/lib/reth/repair-trie else @@ -231,7 +251,7 @@ if [[ -f /var/lib/reth/repair-trie ]]; then fi if [[ -f /var/lib/reth/migrate-v2 ]]; then - if [[ "${NETWORK}" =~ ^https?:// ]]; then + if [[ -n "${config_dir_path}" ]]; then echo "Can't migrate database on custom network" rm -f /var/lib/reth/migrate-v2 else @@ -271,7 +291,7 @@ if [[ -n "${__snap}" && ! -d /var/lib/reth/db ]]; then fi # EraE import -if [[ -n "${ERE_URL}" && ! -f /var/lib/reth/ere-import-complete && ! "${NETWORK}" =~ ^https?:// ]]; then # Fresh sync and named network +if [[ -n "${ERE_URL}" && ! -f /var/lib/reth/ere-import-complete && -z "${config_dir_path}" ]]; then # Fresh sync and named network if [[ "${NODE_TYPE}" =~ ^(full|archive|custom)$ ]]; then echo "Starting EraE history import from ${ERE_URL}" # shellcheck disable=SC2086