Files
Hanzo DevandGitHub ea03508ca7 feat(k8s): unify with luxfi/universe — coherent boot + snapshot-native replication (#3)
Brings zoo to parity with lux: the SAME luxd-boot.sh (byte-identical to
luxfi/universe k8s/boot) drives every network, and native ZAP replication
(PQ-encrypted, restore-on-boot) replaces the boot-time admin_importChain (RLP)
path.

- k8s/boot/: shared entrypoint + mainnet/testnet/devnet env (ids 1/2/3,
  zoo EVM chainIds 200200/200201/200202, S3 path zoo/<net>/zaprepl,
  endpoint s3.zoo-system). Script is byte-identical to luxfi/universe.
- k8s/zoo-<net>/snapshot-native/: replicate-s3-creds + replicate-age secrets
  (fill from KMS) + ZooNetwork replication merge-patch. CRD already allows
  unknown fields, so spec.replication is accepted today.
- zoo-mainnet/luxd-rlp-import.yaml: RETIRED banner; kept as the provenance
  record of the one-time chain-200200 seed (now in the snapshot stream).
- SNAPSHOT-NATIVE-ROLLOUT.md: per-network apply order (devnet→testnet→mainnet).

Requires build-zoo rebuilt on database >= v1.20.3 and zooai operator
replication-env parity (mirror of luxfi/operator); until then the boot script
sets REPLICATE_* itself so replication works without operator changes.

Co-authored-by: Hanzo Dev <[email protected]>
2026-06-15 22:35:51 -07:00

66 lines
3.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Coherent luxd boot — ONE entrypoint for every network: local, devnet, testnet, mainnet.
#
# Every network runs as a REAL staking validator (keys from <data>/staking — the
# operator mounts the per-validator secret; luxd uses what's there). No --automine,
# no ephemeral keys: the production path and the local path are the same.
#
# The luxd binary (luxfi/database >= v1.20.3) restores-on-boot from the S3 snapshot
# stream, so this script does NOT do RLP import, peer keysync, or genesis-root
# surgery — it selects the network, stages plugins, and execs luxd.
#
# Network ids: local=1337 (C-Chain 31337), devnet=3, testnet=2, mainnet=1.
set -euo pipefail
NETWORK="${LUX_NETWORK:-${1:-local}}"
case "$NETWORK" in
local|localnet) NETID="1337" ;; # localnet primary-network id (C-Chain id 31337)
devnet) NETID="3" ;;
testnet) NETID="2" ;;
mainnet) NETID="1" ;;
*) echo "[luxd-boot] unknown network '$NETWORK' (want: local|devnet|testnet|mainnet)" >&2; exit 2 ;;
esac
# Per-universe override: zoo/hanzo reuse this script verbatim — same network names,
# only the primary-network id (and genesis/S3 path) differ. e.g. set LUXD_NETWORK_ID.
NETID="${LUXD_NETWORK_ID:-$NETID}"
DATA_DIR="${LUXD_DATA_DIR:-/data}"
HTTP_HOST="${LUXD_HTTP_HOST:-0.0.0.0}"
HTTP_PORT="${LUXD_HTTP_PORT:-9630}"
STAKING_PORT="${LUXD_STAKING_PORT:-9631}"
LUXD="${LUXD_BIN:-/luxd/build/luxd}"
# Native replication: per-network S3 path + restore-on-boot. Anything already set
# (operator / sourced env) wins; we only fill gaps.
export REPLICATE_S3_PATH="${REPLICATE_S3_PATH:-$NETWORK/zaprepl}"
export REPLICATE_CDC="${REPLICATE_CDC:-true}"
export REPLICATE_PHYSICAL_SNAPSHOT="${REPLICATE_PHYSICAL_SNAPSHOT:-true}"
export REPLICATE_AUTO_ON_OPEN="${REPLICATE_AUTO_ON_OPEN:-true}"
export REPLICATE_RESTORE_ON_BOOT="${REPLICATE_RESTORE_ON_BOOT:-true}"
# EVM (and other VM) plugins staged into the data plugin dir (idempotent).
PLUGIN_DIR="$DATA_DIR/plugins"
mkdir -p "$PLUGIN_DIR"
if [ -d /luxd/build/plugins ]; then cp -n /luxd/build/plugins/* "$PLUGIN_DIR/" 2>/dev/null || true; fi
ARGS=( --network-id="$NETID"
--data-dir="$DATA_DIR"
--http-host="$HTTP_HOST" --http-port="$HTTP_PORT"
--staking-port="$STAKING_PORT"
--plugin-dir="$PLUGIN_DIR" )
# Real staking keys live under $DATA_DIR/staking (operator-mounted secret). Point
# luxd at an explicit staking dir if provided.
[ -n "${LUXD_STAKING_TLS_CERT:-}" ] && ARGS+=( --staking-tls-cert-file="$LUXD_STAKING_TLS_CERT" )
[ -n "${LUXD_STAKING_TLS_KEY:-}" ] && ARGS+=( --staking-tls-key-file="$LUXD_STAKING_TLS_KEY" )
[ -n "${LUXD_STAKING_SIGNER:-}" ] && ARGS+=( --staking-signer-key-file="$LUXD_STAKING_SIGNER" )
# Custom genesis (mounted ConfigMap) overrides the binary's embedded genesis.
[ -n "${LUXD_GENESIS_FILE:-}" ] && [ -f "$LUXD_GENESIS_FILE" ] && ARGS+=( --genesis-file="$LUXD_GENESIS_FILE" )
# Single-node LOCAL dev only (never production) — opt-in, not the default.
if [ "${LUXD_DEV:-}" = "true" ]; then
ARGS+=( --sybil-protection-enabled=false --network-health-min-conn-peers=0 --skip-bootstrap=true )
fi
[ -n "${LUXD_EXTRA_ARGS:-}" ] && ARGS+=( ${LUXD_EXTRA_ARGS} )
echo "[luxd-boot] network=$NETWORK id=$NETID data=$DATA_DIR staking-keys=$([ -f "$DATA_DIR/staking/staker.key" ] && echo present || echo none) restore-on-boot=$REPLICATE_RESTORE_ON_BOOT s3-path=${REPLICATE_S3_PATH} plugins=$(ls "$PLUGIN_DIR" 2>/dev/null | wc -l)"
exec "$LUXD" "${ARGS[@]}"