From f4086ff33c544d8e6f1e19f78be5bcb02299a9ac Mon Sep 17 00:00:00 2001 From: 3alpha <15694175+3alpha@users.noreply.github.com> Date: Wed, 10 Jun 2026 13:37:05 +0200 Subject: [PATCH 1/2] Add reth snapshot and storage mode options --- docker-compose.yml | 3 +- reth/entrypoint.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index b8be0cf..1fb4d51 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,8 @@ services: environment: RPC_MAX_BLOCKS_PER_FILTER: "0" EXTRA_OPTS: null - ARCHIVE_NODE: "false" + DOWNLOAD_SNAPSHOT: "true" + STORAGE_MODE: full restart: unless-stopped volumes: reth: {} diff --git a/reth/entrypoint.sh b/reth/entrypoint.sh index 46a5b6f..ee252e1 100755 --- a/reth/entrypoint.sh +++ b/reth/entrypoint.sh @@ -8,12 +8,78 @@ echo "${JWT_SECRET}" >"${JWT_PATH}" post_jwt_to_dappmanager "${JWT_PATH}" +case "${DOWNLOAD_SNAPSHOT:-true}" in +true | false) ;; +*) + echo "[ERROR - entrypoint] DOWNLOAD_SNAPSHOT must be 'true' or 'false'" + exit 1 + ;; +esac + +case "${STORAGE_MODE:-full}" in +full) + STORAGE_MODE_FLAG="--full" + SNAPSHOT_MODE_FLAG="--full" + ;; +minimal) + STORAGE_MODE_FLAG="--minimal" + SNAPSHOT_MODE_FLAG="--minimal" + ;; +archive) + STORAGE_MODE_FLAG="" + SNAPSHOT_MODE_FLAG="--archive" + ;; +*) + echo "[ERROR - entrypoint] STORAGE_MODE must be 'full', 'minimal', or 'archive'" + exit 1 + ;; +esac + +if [ "${ARCHIVE_NODE}" = true ]; then + echo "[INFO - entrypoint] ARCHIVE_NODE=true detected; using STORAGE_MODE=archive" + STORAGE_MODE_FLAG="" + SNAPSHOT_MODE_FLAG="--archive" +fi + +is_data_dir_initialized() { + for path in \ + "${DATA_DIR}/${NETWORK}/db" \ + "${DATA_DIR}/${NETWORK}/reth.toml" \ + "${DATA_DIR}/${NETWORK}/static_files" \ + "${DATA_DIR}/${NETWORK}/rocksdb" \ + "${DATA_DIR}/db" \ + "${DATA_DIR}/reth.toml" \ + "${DATA_DIR}/static_files" \ + "${DATA_DIR}/rocksdb"; do + if [ -e "${path}" ]; then + return 0 + fi + done + + return 1 +} + echo "[INFO - entrypoint] Running Reth client for network: ${NETWORK}" +if [ "${DOWNLOAD_SNAPSHOT:-true}" = true ]; then + if is_data_dir_initialized; then + echo "[INFO - entrypoint] Reth data directory already initialized; skipping snapshot download" + else + echo "[INFO - entrypoint] Downloading ${NETWORK} ${SNAPSHOT_MODE_FLAG#--} snapshot before starting Reth" + # shellcheck disable=SC2086 + reth \ + download \ + -y \ + ${SNAPSHOT_MODE_FLAG} \ + --chain "${NETWORK}" \ + --datadir "${DATA_DIR}" + fi +fi + # shellcheck disable=SC2086 exec reth \ node \ - $( [ "${ARCHIVE_NODE}" = false ] && printf -- "--block-interval 5 --prune.senderrecovery.full --prune.receipts.before 0 --prune.accounthistory.distance 10064 --prune.storagehistory.distance 10064" ) \ + ${STORAGE_MODE_FLAG} \ --chain "${NETWORK}" \ --metrics 0.0.0.0:6060 \ --datadir "${DATA_DIR}" \ From 69f9fad93b9651277854cc6281d24d5ebcd7e18b Mon Sep 17 00:00:00 2001 From: 3alpha <15694175+3alpha@users.noreply.github.com> Date: Wed, 10 Jun 2026 15:43:27 +0200 Subject: [PATCH 2/2] Add custom mode, respect old archive flag --- docker-compose.yml | 1 + reth/entrypoint.sh | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 1fb4d51..8e4e36b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,6 +12,7 @@ services: environment: RPC_MAX_BLOCKS_PER_FILTER: "0" EXTRA_OPTS: null + ARCHIVE_NODE: "false" DOWNLOAD_SNAPSHOT: "true" STORAGE_MODE: full restart: unless-stopped diff --git a/reth/entrypoint.sh b/reth/entrypoint.sh index ee252e1..16a2220 100755 --- a/reth/entrypoint.sh +++ b/reth/entrypoint.sh @@ -8,7 +8,11 @@ echo "${JWT_SECRET}" >"${JWT_PATH}" post_jwt_to_dappmanager "${JWT_PATH}" -case "${DOWNLOAD_SNAPSHOT:-true}" in +DOWNLOAD_SNAPSHOT="${DOWNLOAD_SNAPSHOT:-true}" +ARCHIVE_NODE="${ARCHIVE_NODE:-false}" +STORAGE_MODE="${STORAGE_MODE:-full}" + +case "${DOWNLOAD_SNAPSHOT}" in true | false) ;; *) echo "[ERROR - entrypoint] DOWNLOAD_SNAPSHOT must be 'true' or 'false'" @@ -16,7 +20,12 @@ true | false) ;; ;; esac -case "${STORAGE_MODE:-full}" in +if [ "${ARCHIVE_NODE}" = true ]; then + echo "[INFO - entrypoint] ARCHIVE_NODE=true detected; using STORAGE_MODE=archive" + STORAGE_MODE="archive" +fi + +case "${STORAGE_MODE}" in full) STORAGE_MODE_FLAG="--full" SNAPSHOT_MODE_FLAG="--full" @@ -29,18 +38,16 @@ archive) STORAGE_MODE_FLAG="" SNAPSHOT_MODE_FLAG="--archive" ;; +custom) + STORAGE_MODE_FLAG="--block-interval 5 --prune.senderrecovery.full --prune.receipts.before 0 --prune.accounthistory.distance 10064 --prune.storagehistory.distance 10064" + SNAPSHOT_MODE_FLAG="" + ;; *) - echo "[ERROR - entrypoint] STORAGE_MODE must be 'full', 'minimal', or 'archive'" + echo "[ERROR - entrypoint] STORAGE_MODE must be 'full', 'minimal', 'archive', or 'custom'" exit 1 ;; esac -if [ "${ARCHIVE_NODE}" = true ]; then - echo "[INFO - entrypoint] ARCHIVE_NODE=true detected; using STORAGE_MODE=archive" - STORAGE_MODE_FLAG="" - SNAPSHOT_MODE_FLAG="--archive" -fi - is_data_dir_initialized() { for path in \ "${DATA_DIR}/${NETWORK}/db" \ @@ -61,7 +68,9 @@ is_data_dir_initialized() { echo "[INFO - entrypoint] Running Reth client for network: ${NETWORK}" -if [ "${DOWNLOAD_SNAPSHOT:-true}" = true ]; then +if [ "${STORAGE_MODE}" = custom ]; then + echo "[INFO - entrypoint] STORAGE_MODE=custom selected; skipping snapshot download" +elif [ "${DOWNLOAD_SNAPSHOT}" = true ]; then if is_data_dir_initialized; then echo "[INFO - entrypoint] Reth data directory already initialized; skipping snapshot download" else