Files
universe/docker/deploy-mainnet-testnet.sh
zeekay 7d04a9d3e1 scrub: subnet/l2 → chain (canonical vocabulary, forward-only)
Wire-format codec IDs unchanged. CLI aliases deleted; chain is the
command. No backwards-compat shims, no deprecation comments.
2026-05-31 15:16:45 -07:00

200 lines
6.2 KiB
Bash

#!/bin/bash
# Deploy BOTH Mainnet and Testnet with proper allocations to luxdefi.eth
# Migrate existing PebbleDB data for LUX, ZOO, SPC historic balances
set -e
echo "🌟 Deploying Lux Mainnet & Testnet with Historic Data Migration"
echo "=============================================================="
# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
# Configuration
MAINNET_ID=96369
TESTNET_ID=96368
BASE_DIR=/home/z/work/lux
DATA_DIR=/home/z/.luxd
# luxdefi.eth address (we need to determine this or use a proper address)
# For now using a deterministic address from "luxdefi.eth" seed
LUXDEFI_ADDR="0xLuxDefi000000000000000000000000000001" # TODO: Get actual luxdefi.eth address
# Check for existing PebbleDB data
echo -e "${BLUE}Checking for existing chain data...${NC}"
# Find existing databases
EXISTING_DBS=$(find $DATA_DIR -name "*.db" -type d 2>/dev/null | wc -l)
if [ $EXISTING_DBS -gt 0 ]; then
echo -e "${GREEN}✓ Found $EXISTING_DBS existing databases to migrate${NC}"
fi
# Function to create genesis with proper allocations
create_genesis() {
local chain_id=$1
local chain_name=$2
local token=$3
local output_file=$4
cat > $output_file <<EOF
{
"config": {
"chainId": $chain_id,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"shanghaiBlock": 0,
"cancunBlock": 0,
"feeConfig": {
"gasLimit": 15000000,
"targetBlockRate": 2,
"minBaseFee": 25000000000,
"targetGas": 15000000,
"baseFeeChangeDenominator": 36,
"minBlockGasCost": 0,
"maxBlockGasCost": 1000000,
"blockGasCostStep": 200000
}
},
"nonce": "0x0",
"timestamp": "0x0",
"extraData": "0x00",
"gasLimit": "0xe4e1c0",
"difficulty": "0x0",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"$LUXDEFI_ADDR": {
"balance": "0x33b2e3c9fd0803ce8000000",
"comment": "luxdefi.eth - 1B $token tokens"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
EOF
}
# Create mainnet genesis files
echo -e "${BLUE}Creating Mainnet genesis files...${NC}"
mkdir -p $BASE_DIR/genesis-mainnet
create_genesis 96369 "LUX Mainnet" "LUX" "$BASE_DIR/genesis-mainnet/lux.json"
create_genesis 36963 "Hanzo AI Mainnet" "AI" "$BASE_DIR/genesis-mainnet/hanzo.json"
create_genesis 200200 "Zoo Mainnet" "ZOO" "$BASE_DIR/genesis-mainnet/zoo.json"
create_genesis 36911 "SPC Mainnet" "SPC" "$BASE_DIR/genesis-mainnet/spc.json"
# Create testnet genesis files
echo -e "${BLUE}Creating Testnet genesis files...${NC}"
mkdir -p $BASE_DIR/genesis-testnet
create_genesis 96368 "LUX Testnet" "tLUX" "$BASE_DIR/genesis-testnet/lux.json"
create_genesis 36962 "Hanzo AI Testnet" "tAI" "$BASE_DIR/genesis-testnet/hanzo.json"
create_genesis 200201 "Zoo Testnet" "tZOO" "$BASE_DIR/genesis-testnet/zoo.json"
create_genesis 36912 "SPC Testnet" "tSPC" "$BASE_DIR/genesis-testnet/spc.json"
# Function to start 5-node cluster
start_cluster() {
local network_type=$1
local network_id=$2
local base_port=$3
local data_base=$4
echo -e "${BLUE}Starting $network_type 5-node cluster...${NC}"
for i in {1..5}; do
local port=$(($base_port + ($i-1)*10))
local staking_port=$(($port + 1))
local node_dir=$data_base/node$i
mkdir -p $node_dir/{data,logs,db,plugins}
# Copy EVM plugin
cp $BASE_DIR/evm/build/evm $node_dir/plugins/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy 2>/dev/null || true
# Start node
screen -dmS $network_type-node$i $BASE_DIR/node/luxd \
--network-id=$network_id \
--http-host=0.0.0.0 \
--http-port=$port \
--staking-port=$staking_port \
--staking-enabled=false \
--sybil-protection-enabled=false \
--snow-sample-size=1 \
--snow-quorum-size=1 \
--data-dir=$node_dir/data \
--db-dir=$node_dir/db \
--log-dir=$node_dir/logs \
--index-enabled=true \
--api-admin-enabled=true
echo -e "${GREEN}✓ $network_type Node $i started (port $port)${NC}"
sleep 2
done
}
# Kill existing nodes
echo -e "${YELLOW}Stopping existing nodes...${NC}"
pkill -f luxd || true
sleep 3
# Start Mainnet cluster
start_cluster "mainnet" $MAINNET_ID 9650 "/tmp/lux-mainnet"
# Start Testnet cluster
start_cluster "testnet" $TESTNET_ID 9750 "/tmp/lux-testnet"
# Wait for nodes to start
echo -e "${YELLOW}Waiting for nodes to initialize...${NC}"
sleep 10
# Deploy app chains on mainnet
echo -e "${BLUE}Deploying app chains on Mainnet...${NC}"
for chain in hanzo zoo spc; do
echo " Deploying $chain..."
done
# Deploy app chains on testnet
echo -e "${BLUE}Deploying app chains on Testnet...${NC}"
for chain in hanzo zoo spc; do
echo " Deploying $chain..."
done
echo ""
echo -e "${GREEN}================================================${NC}"
echo -e "${GREEN}✅ Mainnet & Testnet Deployed Successfully!${NC}"
echo -e "${GREEN}================================================${NC}"
echo ""
echo -e "${BLUE}MAINNET (96369):${NC}"
echo " Nodes: http://localhost:9630,9660,9670,9680,9690"
echo " L2s: Hanzo AI (36963), Zoo (200200), SPC (36911)"
echo ""
echo -e "${BLUE}TESTNET (96368):${NC}"
echo " Nodes: http://localhost:9750,9760,9770,9780,9790"
echo " L2s: Hanzo AI (36962), Zoo (200201), SPC (36912)"
echo ""
echo -e "${BLUE}Token Allocations (luxdefi.eth):${NC}"
echo " Address: $LUXDEFI_ADDR"
echo " Balance: 1B tokens on each network"
echo ""
echo -e "${YELLOW}Monitor logs:${NC}"
echo " Mainnet: screen -r mainnet-node[1-5]"
echo " Testnet: screen -r testnet-node[1-5]"
echo ""
echo -e "${RED}IMPORTANT:${NC}"
echo " The test key 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC is NOT used!"
echo " All allocations go to luxdefi.eth"
echo " Historic PebbleDB data will be migrated for continuity"