refactor: migrate blockchain CLI commands to use centralized config and update port assignments

- Replace load_multichain_config() with ctx.obj['config'] in all blockchain commands
- Update blockchain RPC port from 8003 to 8006 throughout CLI
- Add blockchain_rpc_url and wallet_url fields to Config class with environment variable support
- Update node status command to use new port logic (8006 for primary, 8026 for dev)
- Update installation docs to reflect new blockchain RPC port (8006)
- Update
This commit is contained in:
oib
2026-03-06 10:25:57 +01:00
parent 1511e7e7f5
commit a302da73a9
14 changed files with 1754 additions and 110 deletions

View File

@@ -47,15 +47,18 @@ Internet → aitbc.bubuit.net (HTTPS :443)
└──────────────────────────────────────────────┘
```
## Port Logic Implementation (March 4, 2026)
## Port Logic Implementation (Updated March 6, 2026)
### **Core Services (8000-8003)**
### **Core Services (8000-8002)**
- **Port 8000**: Coordinator API ✅ PRODUCTION READY
- **Port 8001**: Exchange API ✅ PRODUCTION READY
- **Port 8002**: Blockchain Node (internal) ✅ PRODUCTION READY
- **Port 8003**: Blockchain RPC ✅ PRODUCTION READY
- **Port 8002**: Wallet Service ✅ PRODUCTION READY (aitbc-wallet.service - localhost + containers)
### **Enhanced Services (8010-8017)**
### **Blockchain Services (8005-8006)**
- **Port 8005**: Primary Blockchain Node ✅ PRODUCTION READY (aitbc-blockchain-node.service - localhost + containers)
- **Port 8006**: Primary Blockchain RPC ✅ PRODUCTION READY (aitbc-blockchain-rpc.service - localhost + containers)
### **Level 2 Services (8010-8017) - NEW STANDARD**
- **Port 8010**: Multimodal GPU Service ✅ PRODUCTION READY (CPU-only mode)
- **Port 8011**: GPU Multimodal Service ✅ PRODUCTION READY (CPU-only mode)
- **Port 8012**: Modality Optimization Service ✅ PRODUCTION READY
@@ -65,8 +68,33 @@ Internet → aitbc.bubuit.net (HTTPS :443)
- **Port 8016**: Web UI Service ✅ PRODUCTION READY
- **Port 8017**: Geographic Load Balancer ✅ PRODUCTION READY
### **Mock & Test Services (8020-8029)**
- **Port 8020**: Mock Coordinator API ✅ TESTING READY
- **Port 8021**: Coordinator API (dev) ✅ TESTING READY
- **Port 8022**: Test Blockchain Node (localhost) ✅ TESTING READY
- **Port 8023**: Mock Exchange API ✅ TESTING READY
- **Port 8024**: Mock Blockchain RPC ✅ TESTING READY
- **Port 8025**: Development Blockchain Node ✅ TESTING READY (aitbc-blockchain-node-dev.service)
- **Port 8026**: Development Blockchain RPC ✅ TESTING READY (aitbc-blockchain-rpc-dev.service)
- **Port 8027**: Load Testing Endpoint ✅ TESTING READY
- **Port 8028**: Integration Test API ✅ TESTING READY
- **Port 8029**: Performance Monitor ✅ TESTING READY
### **Container Services (8080-8089) - LEGACY**
- **Port 8080**: Container Coordinator API (aitbc) ⚠️ LEGACY - Use port 8000-8003 range
- **Port 8081**: Container Blockchain Node 1 ⚠️ LEGACY - Use port 8010+ range
- **Port 8082**: Container Exchange API ⚠️ LEGACY - Use port 8010+ range
- **Port 8083**: Container Wallet Daemon ⚠️ LEGACY - Use port 8010+ range
- **Port 8084**: Container Blockchain Node 2 ⚠️ LEGACY - Use port 8010+ range
- **Port 8085**: Container Explorer UI ⚠️ LEGACY - Use port 8010+ range
- **Port 8086**: Container Marketplace ⚠️ LEGACY - Use port 8010+ range
- **Port 8087**: Container Miner Dashboard ⚠️ LEGACY - Use port 8010+ range
- **Port 8088**: Container Load Balancer ⚠️ LEGACY - Use port 8010+ range
- **Port 8089**: Container Debug API ⚠️ LEGACY - Use port 8010+ range
### **Legacy Ports (Decommissioned)**
- **Port 8080**: No longer used by AITBC
- **Port 8003**: Previously Primary Blockchain RPC - Decommissioned (moved to port 8006)
- **Port 8090**: No longer used by AITBC
- **Port 9080**: Successfully decommissioned
- **Port 8009**: No longer in use
@@ -644,3 +672,117 @@ WALLET_ENCRYPTION_KEY=<key>
HOST=0.0.0.0 # For container access
PORT=8010-8017 # Enhanced services port range
```
### Container Access & Port Logic (Updated March 6, 2026)
#### **SSH-Based Container Access**
```bash
# Access aitbc container
ssh aitbc-cascade
# Access aitbc1 container
ssh aitbc1-cascade
# Check services in containers
ssh aitbc-cascade 'systemctl list-units | grep aitbc-'
ssh aitbc1-cascade 'systemctl list-units | grep aitbc-'
# Debug specific services
ssh aitbc-cascade 'systemctl status aitbc-coordinator-api'
ssh aitbc1-cascade 'systemctl status aitbc-wallet'
```
#### **Port Distribution Strategy - NEW STANDARD**
```bash
# === NEW STANDARD PORT LOGIC ===
# Core Services (8000-8003) - NEW STANDARD
- Port 8000: Coordinator API (local) ✅ NEW STANDARD
- Port 8001: Exchange API (local) ✅ NEW STANDARD
- Port 8002: Blockchain Node (local) ✅ NEW STANDARD
- Port 8003: Blockchain RPC (local) ✅ NEW STANDARD
# Blockchain Services (8004-8005) - PRODUCTION READY
- Port 8004: Primary Blockchain Node ✅ PRODUCTION READY (aitbc-blockchain-node.service)
- Port 8005: Blockchain RPC 2 ✅ PRODUCTION READY
# Level 2 Services (8010-8017) - NEW STANDARD
- Port 8010: Multimodal GPU Service ✅ NEW STANDARD
- Port 8011: GPU Multimodal Service ✅ NEW STANDARD
- Port 8012: Modality Optimization Service ✅ NEW STANDARD
- Port 8013: Adaptive Learning Service ✅ NEW STANDARD
- Port 8014: Marketplace Enhanced Service ✅ NEW STANDARD
- Port 8015: OpenClaw Enhanced Service ✅ NEW STANDARD
- Port 8016: Web UI Service ✅ NEW STANDARD
- Port 8017: Geographic Load Balancer ✅ NEW STANDARD
# Mock & Test Services (8020-8029) - NEW STANDARD
- Port 8020: Mock Coordinator API ✅ NEW STANDARD
- Port 8021: Coordinator API (dev) ✅ NEW STANDARD
- Port 8022: Test Blockchain Node (localhost) ✅ NEW STANDARD
- Port 8025: Development Blockchain Node ✅ NEW STANDARD (aitbc-blockchain-node-dev.service)
- Port 8026-8029: Additional testing services ✅ NEW STANDARD
# === LEGACY PORTS (DEPRECATED) ===
# Legacy Container Services (8080-8089) - DEPRECATED
- Port 8080-8089: All container services ⚠️ DEPRECATED - Use 8000+ and 8010+ ranges
```
#### **Service Naming Convention**
```bash
# === STANDARDIZED SERVICE NAMES ===
# Primary Production Services:
✅ aitbc-blockchain-node.service (port 8005) - Primary blockchain node
✅ aitbc-blockchain-rpc.service (port 8006) - Primary blockchain RPC (localhost + containers)
✅ aitbc-coordinator-api.service (port 8000) - Main coordinator API
✅ aitbc-exchange-api.service (port 8001) - Exchange API
✅ aitbc-wallet.service (port 8002) - Wallet Service (localhost + containers)
# Development/Test Services:
✅ aitbc-blockchain-node-dev.service (port 8025) - Development blockchain node
✅ aitbc-blockchain-rpc-dev.service (port 8026) - Development blockchain RPC
✅ aitbc-coordinator-api-dev.service (port 8021) - Development coordinator API
# Container Locations:
✅ localhost (at1): Primary services + development services
✅ aitbc container: Primary services + development services
✅ aitbc1 container: Primary services + development services
```
#### **Port Conflict Resolution**
```bash
# Updated port assignments - NO CONFLICTS:
# Local services use 8000-8003 range (core services)
# Blockchain services use 8004-8005 range (primary blockchain nodes)
# Level 2 services use 8010-8017 range (enhanced services)
# Mock & test services use 8020-8029 range (development services)
# Check port usage
netstat -tlnp | grep -E ":(800[0-5]|801[0-7]|802[0-9])"
ssh aitbc-cascade 'netstat -tlnp | grep -E ":(800[0-5]|801[0-7]|802[0-9])"
ssh aitbc1-cascade 'netstat -tlnp | grep -E ":(800[0-5]|801[0-7]|802[0-9])"
# Service Management Commands:
# Primary services:
systemctl status aitbc-blockchain-node.service # localhost
systemctl status aitbc-blockchain-rpc.service # localhost (port 8006)
systemctl status aitbc-wallet.service # localhost (port 8002)
ssh aitbc-cascade 'systemctl status aitbc-blockchain-node.service' # aitbc container
ssh aitbc1-cascade 'systemctl status aitbc-blockchain-node.service' # aitbc1 container
# Wallet services:
ssh aitbc-cascade 'systemctl status aitbc-wallet.service' # port 8002
ssh aitbc1-cascade 'systemctl status aitbc-wallet.service' # port 8002
# RPC services:
ssh aitbc-cascade 'systemctl status aitbc-blockchain-rpc.service' # port 8006
ssh aitbc1-cascade 'systemctl status aitbc-blockchain-rpc.service' # port 8006
ssh aitbc-cascade 'systemctl status aitbc-blockchain-rpc-dev.service' # port 8026
ssh aitbc1-cascade 'systemctl status aitbc-blockchain-rpc-dev.service' # port 8026
# Development services:
ssh aitbc-cascade 'systemctl status aitbc-blockchain-node-dev.service'
ssh aitbc1-cascade 'systemctl status aitbc-blockchain-node-dev.service'
```

View File

@@ -1,8 +1,10 @@
# AITBC Platform Deployment Guide
# AITBC Server Deployment Guide
## Overview
This guide provides comprehensive deployment instructions for the AITBC (AI Trading Blockchain Compute) platform, including infrastructure requirements, service configurations, and troubleshooting procedures. **Updated for the new port logic implementation (8000-8003, 8010-8017) and production-ready codebase.**
This guide provides comprehensive deployment instructions for the **aitbc server** (primary container), including infrastructure requirements, service configurations, and troubleshooting procedures. **Updated for the new port logic implementation (8000-8002, 8005-8006) and production-ready codebase.**
**Note**: This documentation is specific to the aitbc server. For aitbc1 server documentation, see [aitbc1.md](./aitbc1.md).
## System Requirements
@@ -21,12 +23,14 @@ This guide provides comprehensive deployment instructions for the AITBC (AI Trad
- **Database**: SQLite (default) or PostgreSQL (production)
### **Network Requirements**
- **Core Services Ports**: 8000-8003 (must be available)
- **Core Services Ports**: 8000-8002 (must be available)
- Port 8000: Coordinator API
- Port 8001: Exchange API
- Port 8002: Blockchain Node (internal)
- Port 8003: Blockchain RPC
- **Enhanced Services Ports**: 8010-8017 (optional - not required for CPU-only deployment)
- Port 8002: Wallet Service
- **Blockchain Services Ports**: 8005-8006 (must be available)
- Port 8005: Primary Blockchain Node
- Port 8006: Primary Blockchain RPC
- **Level 2 Services Ports**: 8010-8017 (optional - not required for CPU-only deployment)
- Note: Enhanced services disabled for aitbc server (no GPU access)
- Port 8010: Multimodal GPU (CPU-only mode) - DISABLED
- Port 8011: GPU Multimodal (CPU-only mode) - DISABLED
@@ -36,9 +40,80 @@ This guide provides comprehensive deployment instructions for the AITBC (AI Trad
- Port 8015: OpenClaw Enhanced - DISABLED
- Port 8016: Web UI - DISABLED
- Port 8017: Geographic Load Balancer - DISABLED
- **Firewall**: Managed by firehol on at1 host (container networking handled by incus)
- **Mock & Test Services Ports**: 8020-8029 (development and testing)
- Port 8025: Development Blockchain Node
- Port 8026: Development Blockchain RPC
- **Legacy Container Ports**: 8080-8089 (deprecated - use new port ranges)
- **Firewall**: Managed by firehol on at1 host (container networking handled by incus)
- **SSL/TLS**: Recommended for production deployments
### **Container Access & SSH Management (Updated March 6, 2026)**
#### **SSH-Based Container Access**
```bash
# Access aitbc server (primary container)
ssh aitbc-cascade
# Check aitbc server status
ssh aitbc-cascade 'systemctl status'
# List AITBC services on aitbc server
ssh aitbc-cascade 'systemctl list-units | grep aitbc-'
```
#### **Service Management via SSH**
```bash
# Start/stop services on aitbc server
ssh aitbc-cascade 'sudo systemctl start aitbc-coordinator-api'
ssh aitbc-cascade 'sudo systemctl stop aitbc-wallet'
# Check service logs on aitbc server
ssh aitbc-cascade 'sudo journalctl -f -u aitbc-coordinator-api'
# Debug service issues on aitbc server
ssh aitbc-cascade 'sudo systemctl status aitbc-coordinator-api'
ssh aitbc-cascade 'sudo systemctl status aitbc-wallet'
# Check blockchain services on aitbc server
ssh aitbc-cascade 'sudo systemctl status aitbc-blockchain-node'
ssh aitbc-cascade 'sudo systemctl status aitbc-blockchain-rpc'
# Check development services on aitbc server
ssh aitbc-cascade 'sudo systemctl status aitbc-blockchain-node-dev'
ssh aitbc-cascade 'sudo systemctl status aitbc-blockchain-rpc-dev'
```
#### **Port Distribution Strategy (Updated March 6, 2026)**
```bash
# NEW SUSTAINABLE PORT LOGIC
# Core Services (8000-8002):
- Port 8000: Coordinator API (localhost + containers)
- Port 8001: Exchange API (localhost + containers)
- Port 8002: Wallet Service (localhost + containers)
# Blockchain Services (8005-8006):
- Port 8005: Primary Blockchain Node (localhost + containers)
- Port 8006: Primary Blockchain RPC (localhost + containers)
# Level 2 Services (8010-8017):
- Port 8010-8017: Enhanced services (DISABLED for CPU-only deployment)
# Mock & Test Services (8020-8029):
- Port 8025: Development Blockchain Node (localhost + containers)
- Port 8026: Development Blockchain RPC (containers)
# Legacy Ports (8080-8089):
- Port 8080-8089: DEPRECATED - use new port ranges above
# Service Naming Convention:
✅ aitbc-blockchain-node.service (port 8005)
✅ aitbc-blockchain-rpc.service (port 8006)
✅ aitbc-wallet.service (port 8002)
✅ aitbc-blockchain-node-dev.service (port 8025)
✅ aitbc-blockchain-rpc-dev.service (port 8026)
```
## Architecture Overview
```

View File

@@ -1,16 +1,18 @@
# AITBC1 Deployment Notes
# AITBC1 Server Deployment Guide
## Overview
This document contains specific deployment notes and considerations for deploying the AITBC platform on the **aitbc** server. These notes complement the general deployment guide with server-specific configurations and troubleshooting. **Updated for optimized CPU-only deployment with enhanced services disabled.**
This document contains specific deployment notes and considerations for deploying the AITBC platform on the **aitbc1 server** (secondary container). These notes complement the general deployment guide with server-specific configurations and troubleshooting. **Updated for optimized CPU-only deployment with enhanced services disabled.**
**Note**: This documentation is specific to the aitbc1 server. For aitbc server documentation, see [aitbc.md](./aitbc.md).
## Server Specifications
### **aitbc Server Details**
- **Hostname**: aitbc (container)
- **IP Address**: 10.1.223.1 (container IP)
- **Operating System**: Debian 13 Trixie (primary development environment)
- **Access Method**: SSH via aitbc-cascade proxy
### **aitbc1 Server Details**
- **Hostname**: aitbc1 (container)
- **IP Address**: 10.1.223.2 (container IP)
- **Operating System**: Debian 13 Trixie (secondary development environment)
- **Access Method**: SSH via aitbc1-cascade proxy
- **GPU Access**: None (CPU-only mode)
- **Miner Service**: Not needed
- **Enhanced Services**: Disabled (optimized deployment)
@@ -20,13 +22,107 @@ This document contains specific deployment notes and considerations for deployin
### **Network Architecture**
```
Internet → aitbc-cascade (Proxy) → aitbc (Container)
SSL Termination Application Server
Port 443/80 Port 8000-8003 (Core Services Only)
Internet → aitbc1-cascade (Proxy) → aitbc1 (Container)
SSH Access Application Server
Port 22/443 Port 8000-8002 (Core Services)
Port 8005-8006 Blockchain Services
Port 8025-8026 Development Services
```
**Note**: Enhanced services ports 8010-8017 are disabled for CPU-only deployment
### **SSH-Based Container Access (Updated March 6, 2026)**
#### **Primary Access Methods**
```bash
# Access aitbc1 server (secondary container)
ssh aitbc1-cascade
# Check aitbc1 server connectivity
ssh aitbc1-cascade 'echo "Container accessible"'
```
#### **Service Management via SSH**
```bash
# List all AITBC services on aitbc1 server
ssh aitbc1-cascade 'systemctl list-units | grep aitbc-'
# Check specific service status on aitbc1 server
ssh aitbc1-cascade 'systemctl status aitbc-coordinator-api'
ssh aitbc1-cascade 'systemctl status aitbc-wallet'
# Start/stop services on aitbc1 server
ssh aitbc1-cascade 'sudo systemctl start aitbc-coordinator-api'
ssh aitbc1-cascade 'sudo systemctl stop aitbc-wallet'
# View service logs on aitbc1 server
ssh aitbc1-cascade 'sudo journalctl -f -u aitbc-coordinator-api'
ssh aitbc1-cascade 'sudo journalctl -f -u aitbc-blockchain-node'
# Check blockchain services on aitbc1 server
ssh aitbc1-cascade 'sudo systemctl status aitbc-blockchain-node'
ssh aitbc1-cascade 'sudo systemctl status aitbc-blockchain-rpc'
# Check development services on aitbc1 server
ssh aitbc1-cascade 'sudo systemctl status aitbc-blockchain-node-dev'
ssh aitbc1-cascade 'sudo systemctl status aitbc-blockchain-rpc-dev'
```
#### **Port Distribution & Conflict Resolution (Updated March 6, 2026)**
```bash
# NEW SUSTAINABLE PORT LOGIC - NO CONFLICTS
# Core Services (8000-8002):
- Port 8000: Coordinator API (localhost + containers)
- Port 8001: Exchange API (localhost + containers)
- Port 8002: Wallet Service (localhost + containers)
# Blockchain Services (8005-8006):
- Port 8005: Primary Blockchain Node (localhost + containers)
- Port 8006: Primary Blockchain RPC (localhost + containers)
# Level 2 Services (8010-8017):
- Port 8010-8017: Enhanced services (DISABLED for CPU-only deployment)
# Mock & Test Services (8020-8029):
- Port 8025: Development Blockchain Node (localhost + containers)
- Port 8026: Development Blockchain RPC (containers)
# Legacy Ports (8080-8089):
- Port 8080-8089: DEPRECATED - use new port ranges above
# Service Naming Convention:
✅ aitbc-blockchain-node.service (port 8005)
✅ aitbc-blockchain-rpc.service (port 8006)
✅ aitbc-wallet.service (port 8002)
✅ aitbc-blockchain-node-dev.service (port 8025)
✅ aitbc-blockchain-rpc-dev.service (port 8026)
# Resolution Strategy:
# 1. New port logic eliminates all conflicts
# 2. Sequential port assignment for related services
# 3. Clear separation between production and development services
```
#### **Debug Container Service Issues**
```bash
# Debug coordinator API port conflict
ssh aitbc-cascade 'sudo systemctl status aitbc-coordinator-api'
ssh aitbc-cascade 'sudo journalctl -u aitbc-coordinator-api -n 20'
# Debug wallet service issues
ssh aitbc-cascade 'sudo systemctl status aitbc-wallet'
ssh aitbc-cascade 'sudo journalctl -u aitbc-wallet -n 20'
# Check port usage in containers
ssh aitbc-cascade 'sudo netstat -tlnp | grep :800'
ssh aitbc1-cascade 'sudo netstat -tlnp | grep :800'
# Test service endpoints
ssh aitbc-cascade 'curl -s http://localhost:8001/health'
ssh aitbc1-cascade 'curl -s http://localhost:8002/health'
```
## Pre-Deployment Checklist
### **✅ Server Preparation**
@@ -334,19 +430,19 @@ else
echo "Database: ❌ (Missing)"
fi
# Container access test
# Container access test for aitbc1 server
echo -e "\nContainer Access Test:"
curl -s -o /dev/null -w "%{http_code}" "http://10.1.223.1:8017/health" | grep -q "200" && echo "Container Access: ✅" || echo "Container Access: ❌"
curl -s -o /dev/null -w "%{http_code}" "http://10.1.223.2:8017/health" | grep -q "200" && echo "Container Access: ✅" || echo "Container Access: ❌"
EOF
chmod +x /opt/aitbc/scripts/monitor-aitbc.sh
```
## Backup Strategy for aitbc
## Backup Strategy for aitbc1
### **Automated Backup Script**
```bash
# /opt/aitbc/scripts/backup-aitbc.sh
# /opt/aitbc/scripts/backup-aitbc1.sh
#!/bin/bash
BACKUP_DIR="/opt/aitbc/backups"
DATE=$(date +%Y%m%d_%H%M%S)