Archive legacy status docs and canonicalize genesis entrypoints
This commit is contained in:
@@ -294,5 +294,4 @@ Tool: ✅ Configuration updated to use VM Scale Sets
|
||||
- [Besu Configuration](https://besu.hyperledger.org/stable/Reference/CLI/CLI-Syntax/)
|
||||
- [Kubernetes Best Practices](https://kubernetes.io/docs/concepts/security/)
|
||||
- [Azure VM Sizes](https://docs.microsoft.com/azure/virtual-machines/sizes)
|
||||
- [IBFT2 Consensus](https://besu.hyperledger.org/stable/HowTo/Configure/Consensus-Protocols/IBFT/)
|
||||
|
||||
- [Besu QBFT Consensus](https://besu.hyperledger.org/private-networks/how-to/configure/consensus/qbft)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
# Generate Genesis for ChainID 138 with proper IBFT extraData
|
||||
# Generate Genesis for ChainID 138 with proper QBFT extraData
|
||||
# This script uses Besu's operator generate-blockchain-config to create a proper genesis file
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
@@ -22,7 +22,7 @@ REQUEST_TIMEOUT=10
|
||||
GAS_LIMIT="0x1c9c380"
|
||||
NUM_VALIDATORS=${1:-4}
|
||||
|
||||
log_success "Generating genesis for ChainID ${CHAIN_ID} with proper IBFT extraData"
|
||||
log_success "Generating genesis for ChainID ${CHAIN_ID} with proper QBFT extraData"
|
||||
|
||||
# Check if Besu is installed
|
||||
if ! command -v besu &> /dev/null; then
|
||||
@@ -45,7 +45,7 @@ cat > "$CONFIG_DIR/genesis-config.json" <<EOF
|
||||
"berlinBlock": 0,
|
||||
"londonBlock": 0,
|
||||
"istanbulBlock": 0,
|
||||
"ibft2": {
|
||||
"qbft": {
|
||||
"blockperiodseconds": ${BLOCK_PERIOD},
|
||||
"epochlength": ${EPOCH_LENGTH},
|
||||
"requesttimeoutseconds": ${REQUEST_TIMEOUT}
|
||||
@@ -126,7 +126,7 @@ fi
|
||||
# Check extraData is not empty
|
||||
EXTRA_DATA=$(jq -r '.extraData' "$CONFIG_DIR/genesis.json")
|
||||
if [ "$EXTRA_DATA" = "0x" ] || [ -z "$EXTRA_DATA" ]; then
|
||||
log_error "Error: extraData is empty. IBFT configuration may be invalid"
|
||||
log_error "Error: extraData is empty. QBFT configuration may be invalid"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -153,4 +153,3 @@ echo "2. Store validator keys securely (Azure Key Vault for production)"
|
||||
echo "3. Deploy infrastructure using Terraform"
|
||||
echo "4. Update static-nodes.json with actual enode addresses after deployment"
|
||||
echo "5. Deploy Kubernetes resources"
|
||||
|
||||
|
||||
@@ -1,162 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
# Generate Genesis for ChainID 138 - DeFi Oracle Meta Mainnet
|
||||
# This script generates validator keys and creates the genesis.json with IBFT 2.0
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/../lib/init.sh"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
CONFIG_DIR="$PROJECT_ROOT/config"
|
||||
KEYS_DIR="$PROJECT_ROOT/keys"
|
||||
VALIDATORS_DIR="$KEYS_DIR/validators"
|
||||
ORACLE_DIR="$KEYS_DIR/oracle"
|
||||
|
||||
TARGET_SCRIPT="$SCRIPT_DIR/generate-genesis-proper.sh"
|
||||
|
||||
# Configuration
|
||||
CHAIN_ID=138
|
||||
BLOCK_PERIOD=2
|
||||
EPOCH_LENGTH=30000
|
||||
REQUEST_TIMEOUT=10
|
||||
GAS_LIMIT="0x1c9c380"
|
||||
NUM_VALIDATORS=4
|
||||
|
||||
log_success "Generating genesis for ChainID ${CHAIN_ID} - DeFi Oracle Meta Mainnet"
|
||||
|
||||
# Check if Besu is installed
|
||||
if ! command -v besu &> /dev/null; then
|
||||
log_error "Error: Besu CLI not found. Please install Besu."
|
||||
echo "Visit: https://besu.hyperledger.org/en/stable/HowTo/Get-Started/Installation-Options/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create directories
|
||||
mkdir -p "$VALIDATORS_DIR"
|
||||
mkdir -p "$ORACLE_DIR"
|
||||
mkdir -p "$CONFIG_DIR"
|
||||
|
||||
# Generate validator keys
|
||||
log_warn "Generating ${NUM_VALIDATORS} validator keys..."
|
||||
VALIDATOR_ADDRESSES=()
|
||||
for i in $(seq 1 $NUM_VALIDATORS); do
|
||||
VALIDATOR_DIR="$VALIDATORS_DIR/validator-$i"
|
||||
mkdir -p "$VALIDATOR_DIR"
|
||||
|
||||
# Generate key pair
|
||||
besu operator generate-blockchain-config \
|
||||
--config-file="$CONFIG_DIR/genesis-template.json" \
|
||||
--to="$VALIDATOR_DIR" \
|
||||
--private-key-file-name=key.priv 2>/dev/null || \
|
||||
besu public-key export-address \
|
||||
--node-private-key-file="$VALIDATOR_DIR/key.priv" > "$VALIDATOR_DIR/address.txt" 2>/dev/null || \
|
||||
{
|
||||
# Fallback: use openssl to generate keys if Besu tooling is limited
|
||||
openssl ecparam -genkey -name secp256k1 -noout -out "$VALIDATOR_DIR/key.pem" 2>/dev/null
|
||||
# Extract public key and derive address (simplified)
|
||||
openssl ec -in "$VALIDATOR_DIR/key.pem" -pubout -out "$VALIDATOR_DIR/pubkey.pem" 2>/dev/null
|
||||
}
|
||||
|
||||
# For now, we'll generate keys using a simpler method
|
||||
# In production, use proper HSM/KMS key generation
|
||||
if [ ! -f "$VALIDATOR_DIR/key.priv" ]; then
|
||||
# Generate a private key (32 bytes hex)
|
||||
PRIVATE_KEY=$(openssl rand -hex 32)
|
||||
echo "$PRIVATE_KEY" > "$VALIDATOR_DIR/key.priv"
|
||||
log_success "Generated validator $i key"
|
||||
fi
|
||||
|
||||
# Note: In production, use Besu's operator generate-blockchain-config
|
||||
# which properly generates keys and addresses
|
||||
done
|
||||
|
||||
# Generate oracle key
|
||||
log_warn "Generating oracle key..."
|
||||
ORACLE_PRIVATE_KEY=$(openssl rand -hex 32)
|
||||
echo "$ORACLE_PRIVATE_KEY" > "$ORACLE_DIR/key.priv"
|
||||
log_success "Generated oracle key"
|
||||
|
||||
# Generate IBFT extraData
|
||||
# Note: This is a placeholder. In production, use Besu's operator generate-blockchain-config
|
||||
# which generates the proper RLP-encoded extraData with validator addresses
|
||||
log_warn "Generating IBFT extraData..."
|
||||
EXTRA_DATA="0x"
|
||||
|
||||
# Create genesis.json
|
||||
log_warn "Creating genesis.json..."
|
||||
cat > "$CONFIG_DIR/genesis.json" <<EOF
|
||||
{
|
||||
"config": {
|
||||
"chainId": ${CHAIN_ID},
|
||||
"berlinBlock": 0,
|
||||
"londonBlock": 0,
|
||||
"istanbulBlock": 0,
|
||||
"clique": null,
|
||||
"ibft2": {
|
||||
"blockperiodseconds": ${BLOCK_PERIOD},
|
||||
"epochlength": ${EPOCH_LENGTH},
|
||||
"requesttimeoutseconds": ${REQUEST_TIMEOUT}
|
||||
},
|
||||
"ethash": {}
|
||||
},
|
||||
"nonce": "0x0",
|
||||
"timestamp": "0x$(printf '%x' $(date +%s))",
|
||||
"gasLimit": "${GAS_LIMIT}",
|
||||
"difficulty": "0x1",
|
||||
"mixHash": "0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365",
|
||||
"coinbase": "0x0000000000000000000000000000000000000000",
|
||||
"alloc": {
|
||||
"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb": {
|
||||
"balance": "0xde0b6b3a7640000"
|
||||
}
|
||||
},
|
||||
"extraData": "${EXTRA_DATA}",
|
||||
"number": "0x0",
|
||||
"gasUsed": "0x0",
|
||||
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
|
||||
}
|
||||
EOF
|
||||
|
||||
log_success "Genesis file created at: $CONFIG_DIR/genesis.json"
|
||||
log_warn "Note: extraData must be generated using Besu's operator generate-blockchain-config"
|
||||
log_warn "with the actual validator addresses for production deployment."
|
||||
|
||||
# Create a template for proper genesis generation
|
||||
cat > "$CONFIG_DIR/genesis-template.json" <<EOF
|
||||
{
|
||||
"genesis": {
|
||||
"config": {
|
||||
"chainId": ${CHAIN_ID},
|
||||
"berlinBlock": 0,
|
||||
"londonBlock": 0,
|
||||
"istanbulBlock": 0,
|
||||
"ibft2": {
|
||||
"blockperiodseconds": ${BLOCK_PERIOD},
|
||||
"epochlength": ${EPOCH_LENGTH},
|
||||
"requesttimeoutseconds": ${REQUEST_TIMEOUT}
|
||||
}
|
||||
},
|
||||
"nonce": "0x0",
|
||||
"timestamp": "0x0",
|
||||
"gasLimit": "${GAS_LIMIT}",
|
||||
"difficulty": "0x1",
|
||||
"mixHash": "0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365",
|
||||
"coinbase": "0x0000000000000000000000000000000000000000",
|
||||
"alloc": {}
|
||||
},
|
||||
"blockchain": {
|
||||
"nodes": {
|
||||
"generate": true,
|
||||
"count": ${NUM_VALIDATORS}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
log_success "Setup complete!"
|
||||
log_warn "Next steps:"
|
||||
echo "1. Review and update genesis.json with actual validator addresses"
|
||||
echo "2. Generate proper IBFT extraData using: besu operator generate-blockchain-config"
|
||||
echo "3. Store validator keys securely (Azure Key Vault for production)"
|
||||
echo "4. Deploy infrastructure using Terraform"
|
||||
log_warn "scripts/generate-genesis.sh is now a compatibility wrapper."
|
||||
log_warn "Forwarding to the canonical QBFT generator: ./scripts/generate-genesis-proper.sh ${1:-4}"
|
||||
|
||||
exec "$TARGET_SCRIPT" "$@"
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
set -e
|
||||
|
||||
# Generate validator keys for IBFT 2.0
|
||||
# This script generates validator keypairs for Besu IBFT 2.0 consensus
|
||||
# Generate validator keys for QBFT
|
||||
# This script generates validator keypairs for Besu QBFT consensus
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/../lib/init.sh"
|
||||
@@ -46,4 +46,3 @@ done
|
||||
echo "Validator keys generated in: $KEYS_DIR"
|
||||
echo "Password file: $PASSWORD_FILE"
|
||||
echo "IMPORTANT: Store keys securely. For production, use Azure Key Vault or HSM."
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ EXTRA_DATA=$(jq -r '.extraData' "$GENESIS_FILE")
|
||||
if [ "$EXTRA_DATA" != "0x" ] && [ -n "$EXTRA_DATA" ]; then
|
||||
log_success "✓ extraData is set: ${EXTRA_DATA:0:50}..."
|
||||
|
||||
# Validate extraData length (should be reasonable for IBFT)
|
||||
# Validate extraData length (should be reasonable for QBFT)
|
||||
EXTRA_DATA_LENGTH=$(echo -n "$EXTRA_DATA" | wc -c)
|
||||
if [ "$EXTRA_DATA_LENGTH" -gt 2 ]; then
|
||||
log_success "✓ extraData has content (length: $EXTRA_DATA_LENGTH)"
|
||||
@@ -67,12 +67,12 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check IBFT 2 / QBFT configuration
|
||||
log_warn "Checking IBFT 2 / QBFT configuration..."
|
||||
IBFT_CONFIG=$(jq -r '.config.ibft2 // .config.qbft // "null"' "$GENESIS_FILE")
|
||||
if [ "$IBFT_CONFIG" != "null" ]; then
|
||||
log_success "✓ IBFT 2.0 / QBFT configuration exists"
|
||||
# Prefer qbft for Chain 138
|
||||
# Check QBFT configuration
|
||||
log_warn "Checking QBFT configuration..."
|
||||
CONSENSUS_CONFIG=$(jq -r '.config.qbft // .config.ibft2 // "null"' "$GENESIS_FILE")
|
||||
if [ "$CONSENSUS_CONFIG" != "null" ]; then
|
||||
log_success "✓ QBFT-compatible consensus configuration exists"
|
||||
# Prefer qbft for Chain 138, but tolerate older ibft2-shaped historical files.
|
||||
BLOCK_KEY=".config.qbft.blockperiodseconds // .config.ibft2.blockperiodseconds"
|
||||
EPOCH_KEY=".config.qbft.epochlength // .config.ibft2.epochlength"
|
||||
BLOCK_PERIOD=$(jq -r "$BLOCK_KEY" "$GENESIS_FILE")
|
||||
@@ -88,7 +88,7 @@ if [ "$IBFT_CONFIG" != "null" ]; then
|
||||
log_warn "⚠ Epoch length is $EPOCH_LENGTH (expected 30000)"
|
||||
fi
|
||||
else
|
||||
log_error "✗ IBFT 2.0 / QBFT configuration not found"
|
||||
log_error "✗ QBFT-compatible consensus configuration not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -117,4 +117,3 @@ fi
|
||||
|
||||
log_success "Genesis file validation completed"
|
||||
log_success "✓ All validations passed"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user