From 0e027f5213ad19811a332d464d09108fb18a4882 Mon Sep 17 00:00:00 2001 From: Alice Date: Mon, 28 Sep 2026 01:12:47 +0700 Subject: [PATCH] fix: validate node type and drop dead vars in init-bedrock - Reject unknown NODE_TYPE values early. Previously a typo such as NODE_TYPE=ful silently fell through and synced from genesis as a full node instead of failing. - Require BEDROCK_DATADIR to be set with a clear error instead of failing later inside extract with an empty datadir. - Remove the unused TORRENTS_DIR and BEDROCK_TMP_PATH variables and initialize BEDROCK_TAR_DOWNLOAD so the download block never reads an unset variable. --- scripts/init-bedrock.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/init-bedrock.sh b/scripts/init-bedrock.sh index 6b47cf0..a0cb785 100755 --- a/scripts/init-bedrock.sh +++ b/scripts/init-bedrock.sh @@ -7,11 +7,11 @@ source ./scripts/utils.sh # Common variables. INITIALIZED_FLAG=/shared/initialized.txt BEDROCK_JWT_PATH=/shared/jwt.txt -GETH_DATA_DIR=$BEDROCK_DATADIR -TORRENTS_DIR=/torrents/$NETWORK_NAME +: "${BEDROCK_DATADIR:?BEDROCK_DATADIR is not set (expected from envs//op-geth.env)}" +GETH_DATA_DIR="$BEDROCK_DATADIR" BEDROCK_TAR_PATH=/downloads/bedrock.tar BEDROCK_TAR_CHECKSUM_PATH= -BEDROCK_TMP_PATH=/bedrock-tmp +BEDROCK_TAR_DOWNLOAD="" function validate_snapshot_filename() { local snapshot_filename="$1" @@ -71,6 +71,14 @@ fi echo "Bedrock node needs to be initialized..." echo "Initializing via download..." +# Fail fast on an unknown node type: without this, a typo such as +# NODE_TYPE=ful would silently fall through and sync from genesis as a +# full node. +if [ "$NODE_TYPE" != "archive" ] && [ "$NODE_TYPE" != "full" ]; then + echo "Unsupported node type: $NODE_TYPE (expected 'full' or 'archive')" >&2 + exit 1 +fi + # Resolve the latest archival geth datadir snapshot from the ChainSnap indexes. echo "Fetching download link..."