network: add hub registration, Redis persistence, and federated mesh join protocol
Some checks failed
CLI Tests / test-cli (push) Has been cancelled
Integration Tests / test-service-integration (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
Security Scanning / security-scan (push) Has been cancelled
Documentation Validation / validate-docs (push) Has been cancelled
API Endpoint Tests / test-api-endpoints (push) Has been cancelled
Systemd Sync / sync-systemd (push) Has been cancelled

- Change default P2P port from 7070 to 8001 in config and .env.example
- Add redis_url configuration option for hub persistence (default: redis://localhost:6379)
- Implement DNS-based hub registration/unregistration via HTTPS API endpoints
- Add Redis persistence for hub registrations with 1-hour TTL
- Add island join request/response protocol with member list and blockchain credentials
- Add GPU marketplace tracking (offers, bids, providers) in hub manager
- Add
This commit is contained in:
aitbc
2026-04-13 11:47:34 +02:00
parent fefa6c4435
commit d72945f20c
42 changed files with 3802 additions and 1022 deletions

View File

@@ -29,10 +29,9 @@ echo ""
echo "🔧 Core Services (8000-8009):"
check_service "Coordinator API" "http://localhost:8000/health"
check_service "Exchange API" "http://localhost:8001/api/health"
check_service "Marketplace API" "http://localhost:8002/health"
check_service "Marketplace API" "http://localhost:8007/health"
check_service "Wallet API" "http://localhost:8003/health"
check_service "Explorer" "http://localhost:8004/health"
check_service "Web UI" "http://localhost:8007/health"
# Check blockchain node and RPC
echo ""

View File

@@ -109,9 +109,9 @@ class P2PDiscovery:
"""Add bootstrap node for initial connection"""
self.bootstrap_nodes.append((address, port))
def generate_node_id(self, address: str, port: int, public_key: str) -> str:
"""Generate unique node ID from address, port, and public key"""
content = f"{address}:{port}:{public_key}"
def generate_node_id(self, hostname: str, address: str, port: int, public_key: str) -> str:
"""Generate unique node ID from hostname, address, port, and public key"""
content = f"{hostname}:{address}:{port}:{public_key}"
return hashlib.sha256(content.encode()).hexdigest()
async def start_discovery(self):
@@ -2343,17 +2343,18 @@ class TestP2PDiscovery:
def test_generate_node_id(self):
"""Test node ID generation"""
hostname = "node1.example.com"
address = "127.0.0.1"
port = 8000
public_key = "test_public_key"
node_id = self.discovery.generate_node_id(address, port, public_key)
node_id = self.discovery.generate_node_id(hostname, address, port, public_key)
assert isinstance(node_id, str)
assert len(node_id) == 64 # SHA256 hex length
# Test consistency
node_id2 = self.discovery.generate_node_id(address, port, public_key)
node_id2 = self.discovery.generate_node_id(hostname, address, port, public_key)
assert node_id == node_id2
def test_add_bootstrap_node(self):
@@ -2367,17 +2368,18 @@ class TestP2PDiscovery:
def test_generate_node_id_consistency(self):
"""Test node ID generation consistency"""
hostname = "node2.example.com"
address = "192.168.1.1"
port = 9000
public_key = "test_key"
node_id1 = self.discovery.generate_node_id(address, port, public_key)
node_id2 = self.discovery.generate_node_id(address, port, public_key)
node_id1 = self.discovery.generate_node_id(hostname, address, port, public_key)
node_id2 = self.discovery.generate_node_id(hostname, address, port, public_key)
assert node_id1 == node_id2
# Different inputs should produce different IDs
node_id3 = self.discovery.generate_node_id("192.168.1.2", port, public_key)
node_id3 = self.discovery.generate_node_id(hostname, "192.168.1.2", port, public_key)
assert node_id1 != node_id3
def test_get_peer_count_empty(self):

View File

@@ -1,61 +0,0 @@
#!/usr/bin/env python3
"""
Simple FastAPI service for AITBC Web UI (Port 8016)
"""
import sys
import os
sys.path.insert(0, '/opt/aitbc/apps/coordinator-api/src')
import uvicorn
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from fastapi.responses import HTMLResponse
app = FastAPI(title='AITBC Web UI Service', version='1.0.0')
@app.get('/health')
def health():
return {
'status': 'ok',
'service': 'web-ui',
'port': 8016,
'python_version': sys.version.split()[0]
}
@app.get('/')
def root():
return HTMLResponse("""
<!DOCTYPE html>
<html>
<head>
<title>AITBC Web UI</title>
<style>
body { font-family: Arial, sans-serif; margin: 40px; }
.container { max-width: 800px; margin: 0 auto; }
.header { text-align: center; color: #333; }
.status { background: #e8f5e8; padding: 20px; border-radius: 5px; }
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🚀 AITBC Web UI</h1>
<p>Port 8016 - Enhanced Services Interface</p>
</div>
<div class="status">
<h2>🎯 Service Status</h2>
<p>✅ Web UI: Running on port 8016</p>
<p>✅ Coordinator API: Running on port 8000</p>
<p>✅ Exchange API: Running on port 8001</p>
<p>✅ Blockchain RPC: Running on port 8003</p>
<p>✅ Enhanced Services: Running on ports 8010-8016</p>
</div>
</div>
</body>
</html>
""")
if __name__ == '__main__':
port = int(os.environ.get('PORT', 8016))
uvicorn.run(app, host='0.0.0.0', port=port)

View File

@@ -228,10 +228,9 @@ echo ""
echo "🔧 Core Services (8000-8009):"
check_service "Coordinator API" "http://localhost:8000/health"
check_service "Exchange API" "http://localhost:8001/api/health"
check_service "Marketplace API" "http://localhost:8002/health"
check_service "Marketplace API" "http://localhost:8007/health"
check_service "Wallet API" "http://localhost:8003/health"
check_service "Explorer" "http://localhost:8004/health"
check_service "Web UI" "http://localhost:8007/health"
# Check blockchain node and RPC
echo ""
@@ -282,12 +281,12 @@ start_services() {
log "Starting AITBC services..."
# Try systemd first
if systemctl start aitbc-wallet aitbc-coordinator-api aitbc-exchange-api aitbc-blockchain-node aitbc-blockchain-rpc aitbc-gpu aitbc-marketplace aitbc-openclaw aitbc-ai aitbc-learning aitbc-explorer aitbc-web-ui aitbc-agent-coordinator aitbc-agent-registry aitbc-multimodal aitbc-modality-optimization 2>/dev/null; then
if systemctl start aitbc-wallet aitbc-coordinator-api aitbc-exchange-api aitbc-blockchain-node aitbc-blockchain-rpc aitbc-gpu aitbc-marketplace aitbc-openclaw aitbc-ai aitbc-learning aitbc-explorer aitbc-agent-coordinator aitbc-agent-registry aitbc-multimodal aitbc-modality-optimization 2>/dev/null; then
log "Services started via systemd"
sleep 5
# Check if services are running
if systemctl is-active --quiet aitbc-wallet aitbc-coordinator-api aitbc-exchange-api aitbc-blockchain-node aitbc-blockchain-rpc aitbc-gpu aitbc-marketplace aitbc-openclaw aitbc-ai aitbc-learning aitbc-explorer aitbc-web-ui aitbc-agent-coordinator aitbc-agent-registry aitbc-multimodal aitbc-modality-optimization; then
if systemctl is-active --quiet aitbc-wallet aitbc-coordinator-api aitbc-exchange-api aitbc-blockchain-node aitbc-blockchain-rpc aitbc-gpu aitbc-marketplace aitbc-openclaw aitbc-ai aitbc-learning aitbc-explorer aitbc-agent-coordinator aitbc-agent-registry aitbc-multimodal aitbc-modality-optimization; then
success "Services started successfully via systemd"
else
warning "Some systemd services failed, falling back to manual startup"

View File

@@ -17,12 +17,11 @@ echo "Multimodal GPU (8010): $(curl -s http://localhost:8010/health | jq -r .sta
echo "GPU Multimodal (8011): $(curl -s http://localhost:8011/health | jq -r .status 2>/dev/null || echo 'FAIL')"
echo "Modality Optimization (8012): $(curl -s http://localhost:8012/health | jq -r .status 2>/dev/null || echo 'FAIL')"
echo "Adaptive Learning (8013): $(curl -s http://localhost:8013/health | jq -r .status 2>/dev/null || echo 'FAIL')"
echo "Web UI (8016): $(curl -s http://localhost:8016/health | jq -r .status 2>/dev/null || echo 'FAIL')"
echo "Geographic Load Balancer (8017): $(curl -s http://localhost:8017/health | jq -r .status 2>/dev/null || echo 'FAIL')"
echo ""
echo "📊 Port Usage:"
sudo netstat -tlnp | grep -E ":(8000|8001|8003|8010|8011|8012|8013|8016|8017)" | sort
sudo netstat -tlnp | grep -E ":(8000|8001|8003|8010|8011|8012|8013|8017)" | sort
echo ""
echo "✅ All services tested!"

View File

@@ -6,7 +6,7 @@ set -euo pipefail
echo "=== 🧪 AITBC Comprehensive Services Test ==="
echo "Date: $(date)"
echo "Testing all services with new port logic (8000-8003, 8010-8016)"
echo "Testing all services with new port logic (8000-8003, 8010-8015)"
echo ""
# Colors for output
@@ -82,7 +82,6 @@ test_service "Multimodal GPU (8010)" "http://localhost:8010/health" '"service":"
test_service "GPU Multimodal (8011)" "http://localhost:8011/health" '"service":"gpu-multimodal"'
test_service "Modality Optimization (8012)" "http://localhost:8012/health" '"service":"modality-optimization"'
test_service "Adaptive Learning (8013)" "http://localhost:8013/health" '"service":"adaptive-learning"'
test_service "Web UI (8016)" "http://localhost:8016/health" '"service":"web-ui"'
echo ""
echo "🔧 Service Features Testing"
@@ -106,7 +105,6 @@ test_port "8010" "Multimodal GPU"
test_port "8011" "GPU Multimodal"
test_port "8012" "Modality Optimization"
test_port "8013" "Adaptive Learning"
test_port "8016" "Web UI"
echo ""
echo "📊 Test Results Summary"

View File

@@ -143,7 +143,7 @@ check_network() {
echo -e "\n📋 Checking Network Requirements..."
# Check if required ports are available
REQUIRED_PORTS=(8000 8001 8002 8003 8010 8011 8012 8013 8014 8015 8016)
REQUIRED_PORTS=(8000 8001 8003 8007 8008 8010 8011 8012 8013 8014 8015)
OCCUPIED_PORTS=()
for port in "${REQUIRED_PORTS[@]}"; do