shibarium heimdall init.sh: stop injecting rest_server (crash fix) #16

Merged
sebastian merged 1 commits from shibarium-heimdall-init-fix into main 2026-06-20 03:26:29 +00:00
Showing only changes of commit 39d2fa93e2 - Show all commits

View File

@@ -44,11 +44,26 @@ ct_log "Starting heimdalld bootstrap for chain ${CHAIN_ID} (home=${CMT_HOME})"
# Ensure home dir exists
mkdir -p "$CMT_HOME/config" "$CMT_HOME/data"
# Step 1: heimdalld init
ct_log "Running heimdalld init --home $CMT_HOME --chain $CHAIN"
heimdalld init --home "$CMT_HOME" --chain "$CHAIN"
# Self-heal: earlier builds injected `rest_server = true` into config.toml on EVERY
# boot (non-idempotent), accumulating duplicates until heimdalld died on
# "toml: key rest_server is already defined". rest_server is not a valid CometBFT
# config.toml key — REST is enabled by --rest-server in the start command — so strip
# any previously-injected copies before heimdalld reads the config.
if [ -f "$CMT_HOME/config/config.toml" ]; then
sed -i '/^rest_server = true$/d' "$CMT_HOME/config/config.toml"
fi
# Step 2: Fetch genesis if GENESIS_URL is set
# Step 1: heimdalld init — FIRST BOOT ONLY. Re-initializing an existing home resets
# node identity/state and re-parses the existing config; guard on config.toml.
if [ ! -f "$CMT_HOME/config/config.toml" ]; then
ct_log "First boot: heimdalld init --home $CMT_HOME --chain $CHAIN"
heimdalld init --home "$CMT_HOME" --chain "$CHAIN"
sed -i '/^rest_server = true$/d' "$CMT_HOME/config/config.toml" 2>/dev/null || true
else
ct_log "Already initialized — skipping heimdalld init"
fi
# Step 2: Fetch the shibarium (heimdall-109) genesis if GENESIS_URL is set (idempotent).
if [ -n "$GENESIS_URL" ]; then
ct_log "Fetching genesis from $GENESIS_URL"
ct_fetch "$GENESIS_URL" "$CMT_HOME/config/genesis.json" required
@@ -81,10 +96,10 @@ if [ -f "$CMT_HOME/config/config.toml" ]; then
sed -i 's|^cors_allowed_origins = .*|cors_allowed_origins = ["*" ]|' "$CMT_HOME/config/config.toml"
sed -i 's|^cors_allowed_methods = .*|cors_allowed_methods = ["HEAD", "GET", "POST", "OPTIONS"]|' "$CMT_HOME/config/config.toml"
sed -i 's|^cors_allowed_headers = .*|cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time"]|' "$CMT_HOME/config/config.toml"
# Enable REST server in config (though --rest-server flag takes precedence)
sed -i 's|^\[rpc\]|[rpc]\nrest_server = true|' "$CMT_HOME/config/config.toml"
# Set REST server address
sed -i 's|^rest_server_addr = .*|rest_server_addr = "0.0.0.0:1317"|' "$CMT_HOME/config/config.toml"
# NOTE: do NOT inject `rest_server` / `rest_server_addr` into config.toml. REST/LCD
# is enabled by the --rest-server / --rest-server.addr flags in the start command
# below; injecting the key duplicates one heimdalld already defines and crashes it
# with "toml: key rest_server is already defined".
fi
# Step 9: Seed priv_validator_state if present in config