Archive legacy status docs and canonicalize genesis entrypoints
This commit is contained in:
@@ -150,7 +150,7 @@ if [ -f "config/genesis.json" ] || [ -f "genesis.json" ]; then
|
||||
SUCCESS=$((SUCCESS + 1))
|
||||
else
|
||||
log_error "❌ Genesis file not found"
|
||||
echo " Generate with: ./scripts/generate-genesis.sh"
|
||||
echo " Generate with: ./scripts/generate-genesis-proper.sh 4"
|
||||
ERRORS=$((ERRORS + 1))
|
||||
fi
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ fi
|
||||
|
||||
if [ "$BLOCK" -eq 0 ]; then
|
||||
echo "❌ Network is not producing blocks yet"
|
||||
echo " Please wait for IBFT validators to initialize"
|
||||
echo " Please wait for QBFT validators to initialize"
|
||||
echo " Run this script again once blocks are being produced"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -72,13 +72,13 @@ if [ -f "config/genesis.json" ]; then
|
||||
EXTRADATA=$(grep -oE '"extraData"[[:space:]]*:[[:space:]]*"[^"]*"' config/genesis.json | cut -d'"' -f4)
|
||||
if [ "$EXTRADATA" = "0x" ] || [ -z "$EXTRADATA" ]; then
|
||||
log_error "❌ Genesis extraData is empty (no validators configured)"
|
||||
log_warn " Fix: Run ./scripts/generate-genesis.sh to regenerate with validators"
|
||||
log_warn " Fix: Run ./scripts/generate-genesis-proper.sh 4 to regenerate with validators"
|
||||
|
||||
# Check if validator keys exist
|
||||
VALIDATOR_KEY_COUNT=$(find keys/validators -name "key.pub" 2>/dev/null | wc -l)
|
||||
if [ "$VALIDATOR_KEY_COUNT" -gt 0 ]; then
|
||||
log_success " ✅ Validator keys found: ${VALIDATOR_KEY_COUNT}"
|
||||
log_warn " Run: ./scripts/generate-genesis.sh"
|
||||
log_warn " Run: ./scripts/generate-genesis-proper.sh 4"
|
||||
else
|
||||
log_error " ❌ No validator keys found"
|
||||
log_warn " Run: ./scripts/key-management/generate-validator-keys.sh 4"
|
||||
@@ -152,11 +152,10 @@ log_info "=== Summary ==="
|
||||
log_success "Configuration issues checked"
|
||||
log_warn "Critical fixes needed:"
|
||||
echo " 1. Update terraform.tfvars node_count (set sentries=3, rpc=3)"
|
||||
echo " 2. Regenerate genesis.json with validators (./scripts/generate-genesis.sh)"
|
||||
echo " 2. Regenerate genesis.json with validators (./scripts/generate-genesis-proper.sh 4)"
|
||||
echo " 3. Verify Kubernetes version is supported"
|
||||
echo " 4. Configure Terraform backend"
|
||||
log_warn "Security recommendations:"
|
||||
echo " 1. Restrict RPC CORS origins"
|
||||
echo " 2. Restrict RPC host allowlist"
|
||||
echo " 3. Review network security groups"
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Generate IBFT 2.0 Genesis with Validator Addresses
|
||||
Generate QBFT Genesis with Validator Addresses
|
||||
This script extracts validator addresses from keys and creates proper genesis.json
|
||||
"""
|
||||
|
||||
@@ -40,7 +40,7 @@ def extract_address_from_key(key_path):
|
||||
|
||||
def generate_extra_data(validator_addresses):
|
||||
"""
|
||||
Generate IBFT 2.0 extraData
|
||||
Generate QBFT extraData
|
||||
Format: RLP([32 bytes Vanity, [][20 bytes]Validators, 65 bytes Signature])
|
||||
This is a placeholder - proper encoding requires RLP library
|
||||
"""
|
||||
|
||||
@@ -1,177 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Generate Genesis with Validator Addresses for IBFT 2.0
|
||||
# This script generates validator keys and creates a proper genesis.json with extraData
|
||||
|
||||
set -e
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/../lib/init.sh"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
cd "$PROJECT_ROOT"
|
||||
# Load .env via dotenv (RPC CR/LF trim). Fallback: raw source.
|
||||
if [[ -f "$SCRIPT_DIR/../lib/deployment/dotenv.sh" ]]; then
|
||||
# shellcheck disable=SC1090
|
||||
source "$SCRIPT_DIR/../lib/deployment/dotenv.sh"
|
||||
load_deployment_env --repo-root "${PROJECT_ROOT:-$REPO_ROOT}"
|
||||
elif [[ -n "${PROJECT_ROOT:-}" && -f "$PROJECT_ROOT/.env" ]]; then
|
||||
set -a
|
||||
# shellcheck disable=SC1090
|
||||
source "$PROJECT_ROOT/.env"
|
||||
set +a
|
||||
elif [[ -n "${REPO_ROOT:-}" && -f "$REPO_ROOT/.env" ]]; then
|
||||
set -a
|
||||
# shellcheck disable=SC1090
|
||||
source "$REPO_ROOT/.env"
|
||||
set +a
|
||||
fi
|
||||
|
||||
CONFIG_DIR="$PROJECT_ROOT/config"
|
||||
KEYS_DIR="$PROJECT_ROOT/keys"
|
||||
VALIDATORS_DIR="$KEYS_DIR/validators"
|
||||
|
||||
|
||||
CHAIN_ID=138
|
||||
NUM_VALIDATORS=4
|
||||
|
||||
log_info "=== Generating Genesis with Validators for Chain ID ${CHAIN_ID} ==="
|
||||
|
||||
# Step 1: Generate validator keys if they don't exist
|
||||
log_warn "Step 1: Checking validator keys..."
|
||||
if [ ! -d "$VALIDATORS_DIR" ] || [ -z "$(ls -A $VALIDATORS_DIR 2>/dev/null)" ]; then
|
||||
log_warn " Generating ${NUM_VALIDATORS} validator keys..."
|
||||
if [ -f "scripts/key-management/generate-validator-keys.sh" ]; then
|
||||
./scripts/key-management/generate-validator-keys.sh $NUM_VALIDATORS
|
||||
else
|
||||
log_error " ❌ Key generation script not found"
|
||||
log_warn " Creating keys manually..."
|
||||
mkdir -p "$VALIDATORS_DIR"
|
||||
for i in $(seq 1 $NUM_VALIDATORS); do
|
||||
VALIDATOR_DIR="$VALIDATORS_DIR/validator-$i"
|
||||
mkdir -p "$VALIDATOR_DIR"
|
||||
PRIVATE_KEY=$(openssl rand -hex 32)
|
||||
echo "$PRIVATE_KEY" > "$VALIDATOR_DIR/key.priv"
|
||||
chmod 600 "$VALIDATOR_DIR/key.priv"
|
||||
log_success " ✅ Generated validator $i key"
|
||||
done
|
||||
fi
|
||||
else
|
||||
KEY_COUNT=$(find "$VALIDATORS_DIR" -name "key.priv" 2>/dev/null | wc -l)
|
||||
log_success " ✅ Found ${KEY_COUNT} validator keys"
|
||||
fi
|
||||
|
||||
# Step 2: Try to generate proper genesis using Besu
|
||||
log_warn "Step 2: Generating genesis with Besu..."
|
||||
if command -v besu &> /dev/null; then
|
||||
log_success " ✅ Besu CLI found"
|
||||
|
||||
# Create genesis template if it doesn't exist
|
||||
if [ ! -f "$CONFIG_DIR/genesis-template.json" ]; then
|
||||
cat > "$CONFIG_DIR/genesis-template.json" <<EOF
|
||||
{
|
||||
"genesis": {
|
||||
"config": {
|
||||
"chainId": ${CHAIN_ID},
|
||||
"berlinBlock": 0,
|
||||
"londonBlock": 0,
|
||||
"istanbulBlock": 0,
|
||||
"ibft2": {
|
||||
"blockperiodseconds": 2,
|
||||
"epochlength": 30000,
|
||||
"requesttimeoutseconds": 10
|
||||
}
|
||||
},
|
||||
"nonce": "0x0",
|
||||
"timestamp": "0x0",
|
||||
"gasLimit": "0x1c9c380",
|
||||
"difficulty": "0x1",
|
||||
"mixHash": "0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365",
|
||||
"coinbase": "0x0000000000000000000000000000000000000000",
|
||||
"alloc": {}
|
||||
},
|
||||
"blockchain": {
|
||||
"nodes": {
|
||||
"generate": true,
|
||||
"count": ${NUM_VALIDATORS}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
log_success " ✅ Created genesis-template.json"
|
||||
fi
|
||||
|
||||
# Try to use Besu to generate proper genesis
|
||||
TEMP_GENESIS_DIR=$(mktemp -d)
|
||||
if besu operator generate-blockchain-config \
|
||||
--config-file="$CONFIG_DIR/genesis-template.json" \
|
||||
--to="$TEMP_GENESIS_DIR" \
|
||||
--private-key-file-name=key.priv 2>/dev/null; then
|
||||
log_success " ✅ Generated genesis using Besu"
|
||||
|
||||
# Copy generated genesis if it exists
|
||||
if [ -f "$TEMP_GENESIS_DIR/genesis.json" ]; then
|
||||
cp "$TEMP_GENESIS_DIR/genesis.json" "$CONFIG_DIR/genesis.json"
|
||||
log_success " ✅ Updated config/genesis.json with proper extraData"
|
||||
fi
|
||||
|
||||
# Copy validator keys if generated
|
||||
if [ -d "$TEMP_GENESIS_DIR/keys" ]; then
|
||||
cp -r "$TEMP_GENESIS_DIR/keys"/* "$VALIDATORS_DIR/" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
rm -rf "$TEMP_GENESIS_DIR"
|
||||
else
|
||||
log_warn " ⚠️ Besu genesis generation failed (may need manual configuration)"
|
||||
rm -rf "$TEMP_GENESIS_DIR"
|
||||
fi
|
||||
else
|
||||
log_warn " ⚠️ Besu CLI not found"
|
||||
log_warn " Install Besu to generate proper IBFT 2.0 extraData"
|
||||
log_warn " Visit: https://besu.hyperledger.org/en/stable/HowTo/Get-Started/Installation-Options/"
|
||||
fi
|
||||
|
||||
# Step 3: Verify genesis file
|
||||
log_warn "Step 3: Verifying genesis file..."
|
||||
if [ -f "$CONFIG_DIR/genesis.json" ]; then
|
||||
EXTRADATA=$(grep -oE '"extraData"[[:space:]]*:[[:space:]]*"[^"]*"' "$CONFIG_DIR/genesis.json" | cut -d'"' -f4)
|
||||
if [ "$EXTRADATA" = "0x" ] || [ -z "$EXTRADATA" ]; then
|
||||
log_error " ❌ Genesis extraData is still empty"
|
||||
log_warn " ⚠️ Manual step required:"
|
||||
log_warn " 1. Extract validator addresses from keys/validators/*/key.priv"
|
||||
log_warn " 2. Use Besu to generate proper RLP-encoded extraData"
|
||||
log_warn " 3. Update config/genesis.json extraData field"
|
||||
log_warn " Alternative: Use Besu's operator generate-blockchain-config command"
|
||||
log_warn " Example:"
|
||||
log_warn " besu operator generate-blockchain-config \\"
|
||||
log_warn " --config-file=config/genesis-template.json \\"
|
||||
log_warn " --to=keys/validators \\"
|
||||
log_warn " --private-key-file-name=key.priv"
|
||||
else
|
||||
EXTRADATA_LEN=${#EXTRADATA}
|
||||
if [ "$EXTRADATA_LEN" -gt 4 ]; then
|
||||
log_success " ✅ Genesis extraData appears to contain validators (length: ${EXTRADATA_LEN} chars)"
|
||||
else
|
||||
log_warn " ⚠️ Genesis extraData may be incomplete (length: ${EXTRADATA_LEN} chars)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Verify Chain ID
|
||||
GENESIS_CHAIN_ID=$(grep -oE '"chainId"[[:space:]]*:[[:space:]]*[0-9]+' "$CONFIG_DIR/genesis.json" | grep -oE '[0-9]+')
|
||||
if [ "$GENESIS_CHAIN_ID" = "138" ]; then
|
||||
log_success " ✅ Chain ID: 138 (correct)"
|
||||
else
|
||||
log_error " ❌ Chain ID mismatch: ${GENESIS_CHAIN_ID} (expected 138)"
|
||||
fi
|
||||
else
|
||||
log_error " ❌ Genesis file not found"
|
||||
fi
|
||||
|
||||
log_info "=== Summary ==="
|
||||
log_success "Genesis generation process completed"
|
||||
log_warn "Next Steps:"
|
||||
echo " 1. Verify validator keys exist: ls -la keys/validators/*/key.priv"
|
||||
echo " 2. If extraData is still empty, use Besu to generate proper genesis:"
|
||||
echo " besu operator generate-blockchain-config --config-file=config/genesis-template.json --to=keys/validators"
|
||||
echo " 3. Update all ConfigMaps in k8s/base/*/statefulset.yaml with new genesis.json"
|
||||
echo " 4. Update Helm ConfigMaps if using Helm deployment"
|
||||
log_warn "scripts/deployment/generate-genesis-with-validators.sh is now a compatibility wrapper."
|
||||
log_warn "Forwarding to the canonical QBFT generator: ./scripts/generate-genesis-proper.sh ${1:-4}"
|
||||
|
||||
exec "$PROJECT_ROOT/scripts/generate-genesis-proper.sh" "$@"
|
||||
|
||||
@@ -116,7 +116,7 @@ fi
|
||||
if [ -f "$PROJECT_ROOT/config/genesis.json" ]; then
|
||||
log "Genesis file exists"
|
||||
else
|
||||
warn "Genesis file not found. Run: ./scripts/generate-genesis.sh"
|
||||
warn "Genesis file not found. Run: ./scripts/generate-genesis-proper.sh 4"
|
||||
fi
|
||||
|
||||
# Verify Terraform configuration
|
||||
@@ -209,4 +209,3 @@ info "2. Review terraform/terraform.tfvars"
|
||||
info "3. Initialize Terraform: cd terraform && terraform init"
|
||||
info "4. Plan deployment: terraform plan"
|
||||
info "5. Apply when ready: terraform apply"
|
||||
|
||||
|
||||
@@ -112,11 +112,11 @@ if [ -f "config/genesis.json" ]; then
|
||||
((ERRORS++))
|
||||
fi
|
||||
|
||||
# Check IBFT configuration
|
||||
if grep -q "ibft2" config/genesis.json || grep -q "ibft" config/genesis.json; then
|
||||
log_success "✅ IBFT consensus configured"
|
||||
# Check consensus configuration
|
||||
if grep -q "qbft" config/genesis.json || grep -q "ibft2" config/genesis.json; then
|
||||
log_success "✅ QBFT-compatible consensus configured"
|
||||
else
|
||||
log_error "❌ IBFT consensus not found in genesis"
|
||||
log_error "❌ Consensus configuration not found in genesis"
|
||||
((ERRORS++))
|
||||
fi
|
||||
|
||||
@@ -363,4 +363,3 @@ else
|
||||
log_error " Please fix ${ERRORS} error(s) before deployment"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user