Files
b6580bfa54 fix(boot): real staking validators, localnet id 1337 (no --automine) (#24)
Every network now boots as a real staking validator using keys under
<data>/staking (operator-mounted secret; luxd generates locally if absent).
Drops the --automine shortcut entirely — the production and local paths are
identical. localnet primary-network id is 1337 (C-Chain 31337), not the
string "local".

- LUXD_NETWORK_ID override so zoo/hanzo universes reuse this script verbatim
  (same network names, only the id/genesis/S3 path differ).
- Optional --staking-tls-cert/key/signer wiring for mounted secrets.
- LUXD_DEV=true is the local single-node escape hatch (sybil-off +
  skip-bootstrap) — never the default.

Proven locally on luxd/1.30.6 + database v1.20.3: boots id=1337 with
auto-generated ECDSA+ML-KEM+ML-DSA staking keys, restore-on-boot hydrates the
physical snapshot, ships PQ-encrypted CDC incrementals.

Co-authored-by: Hanzo Dev <[email protected]>
2026-06-15 22:35:48 -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[@]}"