Live chain is v27.4.0 (abci_info); v25.3.2 halts at the v26/v27 upgrade heights (ghcr lags but v27.4.0 IS pullable). Statesync omits CosmWasm + IBC 08-wasm files -> gaia panics 'wasmlckeeper failed initialize pinned codes / Error opening Wasm file'. init.sh now: skip statesync if data/application.db exists (idempotent restart, preserves a restored snapshot); on fresh statesync, seed wasm from polkachu cosmos_wasmonly.tar.lz4. Porting cursor's host fix into the repo (host /root/rpc edits get reverted by run-rpc-update re-clone). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
66 lines
3.0 KiB
Bash
66 lines
3.0 KiB
Bash
#!/bin/sh
|
|
# cosmos-hub (gaiad) entrypoint — family C, pure CometBFT (no EL). Thin: sources the
|
|
# shared cometbft-common.sh and orchestrates init + statesync bootstrap + start.
|
|
# Genesis replay across ~25 gaia governance upgrades is impractical, so we statesync
|
|
# near head with the current binary. Serves CometBFT RPC :26657 (the dshackle upstream).
|
|
set -e
|
|
. /usr/local/bin/cometbft-common.sh
|
|
|
|
HOME_DIR="/root/.gaia"
|
|
CONFIG_DIR="$HOME_DIR/config"
|
|
CHAIN_ID="${CHAIN_ID:-cosmoshub-4}"
|
|
GENESIS_URL="${GENESIS_URL:-https://github.com/cosmos/mainnet/raw/master/genesis/genesis.cosmoshub-4.json.gz}"
|
|
STATESYNC_RPC="${STATESYNC_RPC:-https://cosmos-rpc.polkachu.com:443}"
|
|
MIN_GAS="${MIN_GAS:-0.005uatom}"
|
|
MONIKER="${MONIKER:-rpc-node}"
|
|
|
|
ct_apk curl jq
|
|
|
|
if gaiad init "$MONIKER" --chain-id "$CHAIN_ID" --home "$HOME_DIR" >/dev/null 2>&1; then
|
|
ct_log "fresh init; fetching genesis"
|
|
ct_fetch "$GENESIS_URL" "$CONFIG_DIR/genesis.json.gz" required
|
|
if gzip -t "$CONFIG_DIR/genesis.json.gz" 2>/dev/null; then
|
|
gunzip -f "$CONFIG_DIR/genesis.json.gz"
|
|
else
|
|
mv "$CONFIG_DIR/genesis.json.gz" "$CONFIG_DIR/genesis.json" # served plain, not gzipped
|
|
fi
|
|
ct_localize_home "$CONFIG_DIR"
|
|
ct_set_min_gas_prices "$CONFIG_DIR/app.toml" "$MIN_GAS"
|
|
else
|
|
ct_log "already initialized, continuing"
|
|
fi
|
|
|
|
# Serve RPC on all interfaces (dshackle/traefik upstream); default is 127.0.0.1.
|
|
sed -i '/^\[rpc\]/,/^\[/{s|^laddr = .*|laddr = "tcp://0.0.0.0:26657"|}' "$CONFIG_DIR/config.toml"
|
|
|
|
ct_patch_p2p "$CONFIG_DIR/config.toml" "$IP" "${P2P_PORT:-26656}"
|
|
ct_merge_seeds "$CONFIG_DIR/config.toml" "$SEEDS"
|
|
ct_set_persistent_peers "$CONFIG_DIR/config.toml" "$PERSISTENT_PEERS"
|
|
ct_set_moniker "$CONFIG_DIR/config.toml" "$MONIKER"
|
|
|
|
# Statesync ONLY on a fresh node. If application state already exists (a restored snapshot
|
|
# or prior sync), do NOT re-arm statesync — it would try to re-restore and, because statesync
|
|
# omits the CosmWasm + IBC 08-wasm blobs, the node panics at startup
|
|
# ("wasmlckeeper failed initialize pinned codes / Error opening Wasm file").
|
|
if [ -e "$HOME_DIR/data/application.db" ]; then
|
|
ct_log "statesync: existing data dir, skipping"
|
|
else
|
|
ct_configure_statesync "$CONFIG_DIR/config.toml" "$STATESYNC_RPC"
|
|
# statesync restores IAVL state but NOT the wasm files gaia needs at startup. Seed them
|
|
# from the wasm-only snapshot (best-effort; the fully robust alternative for wasm chains is
|
|
# a full snapshot restore). Extracts wasm/ (CosmWasm) + the IBC 08-light-client wasm.
|
|
if [ -n "$WASM_SNAPSHOT_URL" ] && { [ ! -d "$HOME_DIR/wasm" ] || [ -z "$(ls -A "$HOME_DIR/wasm" 2>/dev/null)" ]; }; then
|
|
ct_log "fetching wasm snapshot $WASM_SNAPSHOT_URL"
|
|
ct_apk lz4 tar
|
|
if curl -sL "$WASM_SNAPSHOT_URL" | lz4 -dc | tar -xf - -C "$HOME_DIR"; then
|
|
ct_log "wasm snapshot extracted into $HOME_DIR"
|
|
else
|
|
ct_log "WARN wasm snapshot fetch/extract failed"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
ct_seed_priv_validator_state "$HOME_DIR"
|
|
|
|
exec gaiad start --home "$HOME_DIR" --minimum-gas-prices "$MIN_GAS" "$@"
|