feat: add production setup and infrastructure improvements
Some checks failed
AITBC CI/CD Pipeline / lint-and-test (3.11) (pull_request) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.12) (pull_request) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.13) (pull_request) Has been cancelled
Security Scanning / Bandit Security Scan (apps/coordinator-api/src) (pull_request) Has been cancelled
Security Scanning / Bandit Security Scan (cli/aitbc_cli) (pull_request) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-core/src) (pull_request) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-crypto/src) (pull_request) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-sdk/src) (pull_request) Has been cancelled
Security Scanning / Bandit Security Scan (tests) (pull_request) Has been cancelled
Security Scanning / CodeQL Security Analysis (javascript) (pull_request) Has been cancelled
Security Scanning / CodeQL Security Analysis (python) (pull_request) Has been cancelled
Security Scanning / Dependency Security Scan (pull_request) Has been cancelled
Security Scanning / Container Security Scan (pull_request) Has been cancelled
Security Scanning / OSSF Scorecard (pull_request) Has been cancelled
AITBC CI/CD Pipeline / test-cli (pull_request) Has been cancelled
AITBC CI/CD Pipeline / test-services (pull_request) Has been cancelled
AITBC CI/CD Pipeline / test-production-services (pull_request) Has been cancelled
AITBC CI/CD Pipeline / security-scan (pull_request) Has been cancelled
AITBC CI/CD Pipeline / build (pull_request) Has been cancelled
AITBC CI/CD Pipeline / deploy-staging (pull_request) Has been cancelled
AITBC CI/CD Pipeline / deploy-production (pull_request) Has been cancelled
AITBC CI/CD Pipeline / performance-test (pull_request) Has been cancelled
AITBC CI/CD Pipeline / docs (pull_request) Has been cancelled
AITBC CI/CD Pipeline / release (pull_request) Has been cancelled
AITBC CI/CD Pipeline / notify (pull_request) Has been cancelled
Security Scanning / Security Summary Report (pull_request) Has been cancelled
Some checks failed
AITBC CI/CD Pipeline / lint-and-test (3.11) (pull_request) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.12) (pull_request) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.13) (pull_request) Has been cancelled
Security Scanning / Bandit Security Scan (apps/coordinator-api/src) (pull_request) Has been cancelled
Security Scanning / Bandit Security Scan (cli/aitbc_cli) (pull_request) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-core/src) (pull_request) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-crypto/src) (pull_request) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-sdk/src) (pull_request) Has been cancelled
Security Scanning / Bandit Security Scan (tests) (pull_request) Has been cancelled
Security Scanning / CodeQL Security Analysis (javascript) (pull_request) Has been cancelled
Security Scanning / CodeQL Security Analysis (python) (pull_request) Has been cancelled
Security Scanning / Dependency Security Scan (pull_request) Has been cancelled
Security Scanning / Container Security Scan (pull_request) Has been cancelled
Security Scanning / OSSF Scorecard (pull_request) Has been cancelled
AITBC CI/CD Pipeline / test-cli (pull_request) Has been cancelled
AITBC CI/CD Pipeline / test-services (pull_request) Has been cancelled
AITBC CI/CD Pipeline / test-production-services (pull_request) Has been cancelled
AITBC CI/CD Pipeline / security-scan (pull_request) Has been cancelled
AITBC CI/CD Pipeline / build (pull_request) Has been cancelled
AITBC CI/CD Pipeline / deploy-staging (pull_request) Has been cancelled
AITBC CI/CD Pipeline / deploy-production (pull_request) Has been cancelled
AITBC CI/CD Pipeline / performance-test (pull_request) Has been cancelled
AITBC CI/CD Pipeline / docs (pull_request) Has been cancelled
AITBC CI/CD Pipeline / release (pull_request) Has been cancelled
AITBC CI/CD Pipeline / notify (pull_request) Has been cancelled
Security Scanning / Security Summary Report (pull_request) Has been cancelled
- Add production genesis initialization scripts - Add keystore management for production - Add production node runner - Add setup production automation - Add AI memory system for development tracking - Add translation cache service - Add development heartbeat monitoring - Update blockchain RPC router - Update coordinator API main configuration - Update secure pickle service - Update claim task script - Update blockchain service configuration - Update gitignore for production files
This commit is contained in:
68
scripts/run_production_node.py
Normal file
68
scripts/run_production_node.py
Normal file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Production launcher for AITBC blockchain node.
|
||||
Sets up environment, initializes genesis if needed, and starts the node.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
# Configuration
|
||||
CHAIN_ID = "ait-mainnet"
|
||||
DATA_DIR = Path("/opt/aitbc/data/ait-mainnet")
|
||||
DB_PATH = DATA_DIR / "chain.db"
|
||||
KEYS_DIR = Path("/opt/aitbc/keystore")
|
||||
|
||||
# Check for proposer key in keystore
|
||||
PROPOSER_KEY_FILE = KEYS_DIR / "aitbc1genesis.json"
|
||||
if not PROPOSER_KEY_FILE.exists():
|
||||
print(f"[!] Proposer keystore not found at {PROPOSER_KEY_FILE}")
|
||||
print(" Run scripts/keystore.py to generate it first.")
|
||||
sys.exit(1)
|
||||
|
||||
# Set environment variables
|
||||
os.environ["CHAIN_ID"] = CHAIN_ID
|
||||
os.environ["SUPPORTED_CHAINS"] = CHAIN_ID
|
||||
os.environ["DB_PATH"] = str(DB_PATH)
|
||||
os.environ["PROPOSER_ID"] = "aitbc1genesis"
|
||||
# PROPOSER_KEY will be read from keystore by the node? Currently .env expects hex directly.
|
||||
# We can read the keystore, decrypt, and set PROPOSER_KEY, but the node doesn't support that out of box.
|
||||
# So we require that PROPOSER_KEY is set in .env file manually after key generation.
|
||||
# This script will check for PROPOSER_KEY env var or fail with instructions.
|
||||
if not os.getenv("PROPOSER_KEY"):
|
||||
print("[!] PROPOSER_KEY environment variable not set.")
|
||||
print(" Please edit /opt/aitbc/apps/blockchain-node/.env and set PROPOSER_KEY to the hex private key of aitbc1genesis.")
|
||||
sys.exit(1)
|
||||
|
||||
# Ensure data directory
|
||||
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Optionally initialize genesis if DB doesn't exist
|
||||
if not DB_PATH.exists():
|
||||
print("[*] Database not found. Initializing production genesis...")
|
||||
result = subprocess.run([
|
||||
sys.executable,
|
||||
"/opt/aitbc/scripts/init_production_genesis.py",
|
||||
"--chain-id", CHAIN_ID,
|
||||
"--db-path", str(DB_PATH)
|
||||
], check=False)
|
||||
if result.returncode != 0:
|
||||
print("[!] Genesis initialization failed. Aborting.")
|
||||
sys.exit(1)
|
||||
|
||||
# Start the node
|
||||
print(f"[*] Starting blockchain node for chain {CHAIN_ID}...")
|
||||
# Change to the blockchain-node directory (since .env and uvicorn expect relative paths)
|
||||
os.chdir("/opt/aitbc/apps/blockchain-node")
|
||||
# Use the virtualenv Python
|
||||
venv_python = Path("/opt/aitbc/apps/blockchain-node/.venv/bin/python")
|
||||
if not venv_python.exists():
|
||||
print(f"[!] Virtualenv not found at {venv_python}")
|
||||
sys.exit(1)
|
||||
|
||||
# Exec uvicorn
|
||||
os.execv(str(venv_python), [str(venv_python), "-m", "uvicorn", "aitbc_chain.app:app", "--host", "127.0.0.1", "--port", "8006"])
|
||||
Reference in New Issue
Block a user