Files
aitbc/scripts/utils/deploy_enhanced_genesis.py
aitbc1 3352d63f36
All checks were successful
AITBC CLI Level 1 Commands Test / test-cli-level1 (push) Successful in 16s
api-endpoint-tests / test-api-endpoints (push) Successful in 35s
integration-tests / test-service-integration (push) Successful in 1m25s
package-tests / test-python-packages (map[name:aitbc-agent-sdk path:packages/py/aitbc-agent-sdk python_version:3.13]) (push) Successful in 16s
package-tests / test-python-packages (map[name:aitbc-cli path:. python_version:3.13]) (push) Successful in 14s
package-tests / test-python-packages (map[name:aitbc-core path:packages/py/aitbc-core python_version:3.13]) (push) Successful in 13s
package-tests / test-python-packages (map[name:aitbc-crypto path:packages/py/aitbc-crypto python_version:3.13]) (push) Successful in 10s
package-tests / test-python-packages (map[name:aitbc-sdk path:packages/py/aitbc-sdk python_version:3.13]) (push) Successful in 12s
package-tests / test-javascript-packages (map[name:aitbc-sdk node_version:24 path:packages/js/aitbc-sdk]) (push) Successful in 18s
python-tests / test-specific (push) Has been skipped
security-scanning / audit (push) Successful in 14s
systemd-sync / sync-systemd (push) Successful in 4s
package-tests / cross-language-compatibility (push) Successful in 2s
package-tests / package-integration-tests (push) Successful in 3s
Documentation Validation / validate-docs (push) Successful in 6m13s
python-tests / test (push) Successful in 14s
feat: major infrastructure refactoring and optimization
## 🚀 Central Virtual Environment Implementation
- Created central venv at /opt/aitbc/venv for all services
- Updated 34+ systemd services to use central python interpreter
- Fixed PYTHONPATH configurations for proper module imports
- Created aitbc-env wrapper script for environment management

## 📦 Requirements Management Overhaul
- Consolidated 8 separate requirements.txt files into central requirements.txt
- Added web3>=6.11.0 for blockchain functionality
- Created automated requirements migrator tool (scripts/requirements_migrator.py)
- Established modular requirements structure (requirements-modules/)
- Generated comprehensive migration reports and documentation

## 🔧 Service Configuration Fixes
- Fixed Adaptive Learning service domain imports (AgentStatus)
- Resolved logging conflicts in zk_proofs and adaptive_learning_health
- Created missing data modules (consumer_gpu_profiles.py)
- Updated CLI to version 0.2.2 with proper import handling
- Fixed infinite loop in CLI alias configuration

## 📡 Port Mapping and Service Updates
- Updated blockchain node port from 8545 to 8005
- Added Adaptive Learning service on port 8010
- Consolidated P2P/sync into blockchain-node service
- All 5 core services now operational and responding

## 📚 Documentation Enhancements
- Updated SYSTEMD_SERVICES.md for Debian root usage (no sudo)
- Added comprehensive VIRTUAL_ENVIRONMENT.md guide
- Created REQUIREMENTS_MERGE_SUMMARY.md with migration details
- Updated RUNTIME_DIRECTORIES.md for standard Linux paths
- Fixed service port mappings and dependencies

## 🛠️ CLI Improvements
- Fixed import errors and version display (0.2.2)
- Resolved infinite loop in bashrc alias
- Added proper error handling for missing command modules
- Created aitbc-cli wrapper for clean execution

##  Operational Status
- 5/5 AITBC services running successfully
- All health checks passing
- Central virtual environment fully functional
- Requirements management streamlined
- Documentation accurate and up-to-date

## 🎯 Technical Achievements
- Eliminated 7 redundant requirements.txt files
- Reduced service startup failures from 34+ to 0
- Established modular dependency management
- Created reusable migration tooling
- Standardized Debian root deployment practices

This represents a complete infrastructure modernization with improved reliability,
maintainability, and operational efficiency.
2026-03-29 11:52:37 +02:00

175 lines
6.2 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Deploy Enhanced Genesis Block with New Features
"""
import sys
import os
import subprocess
import yaml
from datetime import datetime
def load_genesis_config(config_path):
"""Load genesis configuration"""
with open(config_path, 'r') as f:
return yaml.safe_load(f)
def deploy_to_container(container_name, genesis_config):
"""Deploy genesis block to container"""
print(f"🚀 Deploying enhanced genesis to {container_name}...")
# Copy genesis file to container
subprocess.run([
'scp',
'/home/oib/windsurf/aitbc/genesis_enhanced_devnet.yaml',
f'{container_name}:/opt/aitbc/genesis_enhanced_devnet.yaml'
], check=True)
# Stop blockchain services
print(f"⏹️ Stopping blockchain services on {container_name}...")
subprocess.run([
'ssh', container_name,
'sudo systemctl stop aitbc-blockchain-node.service aitbc-blockchain-rpc.service'
], check=False) # Don't fail if services aren't running
# Clear existing blockchain data
print(f"🧹 Clearing existing blockchain data on {container_name}...")
subprocess.run([
'ssh', container_name,
'sudo rm -f /var/lib/aitbc/data/chain.db'
], check=False)
# Initialize new genesis
print(f"🔧 Initializing enhanced genesis on {container_name}...")
result = subprocess.run([
'ssh', container_name,
'cd /opt/aitbc/apps/blockchain-node && python create_genesis.py --config /opt/aitbc/genesis_enhanced_devnet.yaml'
], capture_output=True, text=True)
if result.returncode == 0:
print(f"✅ Genesis initialization successful on {container_name}")
print(f"Output: {result.stdout}")
else:
print(f"❌ Genesis initialization failed on {container_name}")
print(f"Error: {result.stderr}")
return False
# Start blockchain services
print(f"▶️ Starting blockchain services on {container_name}...")
subprocess.run([
'ssh', container_name,
'sudo systemctl start aitbc-blockchain-node.service aitbc-blockchain-rpc.service'
], check=True)
# Wait for services to start
import time
time.sleep(5)
# Verify genesis block
print(f"🔍 Verifying genesis block on {container_name}...")
result = subprocess.run([
'ssh', container_name,
'curl -s http://localhost:8005/rpc/head'
], capture_output=True, text=True)
if result.returncode == 0:
print(f"✅ Genesis verification successful on {container_name}")
print(f"Response: {result.stdout}")
return True
else:
print(f"❌ Genesis verification failed on {container_name}")
print(f"Error: {result.stderr}")
return False
def enable_new_services(container_name):
"""Enable new enhanced services"""
print(f"🔧 Enabling enhanced services on {container_name}...")
services = [
'aitbc-explorer.service',
'aitbc-marketplace-enhanced.service',
]
for service in services:
try:
subprocess.run([
'ssh', container_name,
f'sudo systemctl enable {service} && sudo systemctl start {service}'
], check=True)
print(f"{service} enabled and started")
except subprocess.CalledProcessError:
print(f"⚠️ {service} not available, skipping")
def verify_features(container_name):
"""Verify new features are working"""
print(f"🧪 Verifying enhanced features on {container_name}...")
# Check blockchain height (should be 0 for fresh genesis)
result = subprocess.run([
'ssh', container_name,
'curl -s http://localhost:8005/rpc/head | jq ".height"'
], capture_output=True, text=True)
if result.returncode == 0 and result.stdout.strip() == '0':
print("✅ Genesis block height verified (0)")
else:
print(f"⚠️ Unexpected blockchain height: {result.stdout}")
# Check if explorer is accessible
result = subprocess.run([
'ssh', container_name,
'curl -s -o /dev/null -w "%{http_code}" http://localhost:8016'
], capture_output=True, text=True)
if result.returncode == 0 and result.stdout.strip() == '200':
print("✅ Blockchain Explorer accessible")
else:
print(f"⚠️ Explorer not accessible (HTTP {result.stdout})")
def main():
"""Main deployment function"""
print("🌟 AITBC Enhanced Genesis Block Deployment")
print("=" * 50)
# Load genesis configuration
genesis_config = load_genesis_config('/home/oib/windsurf/aitbc/genesis_enhanced_devnet.yaml')
print(f"📋 Chain ID: {genesis_config['genesis']['chain_id']}")
print(f"📋 Chain Type: {genesis_config['genesis']['chain_type']}")
print(f"📋 Purpose: {genesis_config['genesis']['purpose']}")
print(f"📋 Features: {', '.join(genesis_config['genesis']['features'].keys())}")
print()
# Deploy to containers
containers = ['aitbc-cascade', 'aitbc1-cascade']
success_count = 0
for container in containers:
print(f"\n🌐 Processing {container}...")
if deploy_to_container(container, genesis_config):
enable_new_services(container)
verify_features(container)
success_count += 1
print("-" * 40)
# Summary
print(f"\n📊 Deployment Summary:")
print(f"✅ Successful deployments: {success_count}/{len(containers)}")
print(f"🔗 Chain ID: {genesis_config['genesis']['chain_id']}")
print(f"🕐 Deployment time: {datetime.now().isoformat()}")
if success_count == len(containers):
print("🎉 All deployments successful!")
else:
print("⚠️ Some deployments failed - check logs above")
print("\n🔗 Next Steps:")
print("1. Test the new AI Trading Engine: curl http://localhost:8010/health")
print("2. Check AI Surveillance: curl http://localhost:8011/status")
print("3. View Advanced Analytics: curl http://localhost:8012/metrics")
print("4. Access Blockchain Explorer: http://localhost:8016")
print("5. Test CLI commands: aitbc --test-mode wallet list")
if __name__ == "__main__":
main()