Skip to content
Open
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
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ services:
RPC_MAX_BLOCKS_PER_FILTER: "0"
EXTRA_OPTS: null
ARCHIVE_NODE: "false"
DOWNLOAD_SNAPSHOT: "true"
STORAGE_MODE: full
restart: unless-stopped
volumes:
reth: {}
77 changes: 76 additions & 1 deletion reth/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,87 @@ echo "${JWT_SECRET}" >"${JWT_PATH}"

post_jwt_to_dappmanager "${JWT_PATH}"

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'"
exit 1
;;
esac

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"
;;
minimal)
STORAGE_MODE_FLAG="--minimal"
SNAPSHOT_MODE_FLAG="--minimal"
;;
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', 'archive', or 'custom'"
exit 1
;;
esac

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 [ "${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
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}" \
Expand Down