refactor: migrate P2P network from Redis gossip to direct TCP mesh architecture
- Replaced Redis-based P2P with direct TCP connections for decentralized mesh networking - Added handshake protocol with node_id exchange for peer authentication - Implemented bidirectional connection management (inbound/outbound streams) - Added peer dialing loop to continuously reconnect to initial peers - Added ping/pong keepalive mechanism to maintain active connections - Prevented duplicate connections through endpoint
This commit is contained in:
@@ -115,13 +115,13 @@ check_system_readiness() {
|
||||
# Check CLI availability
|
||||
if [ ! -f "$CLI_PATH" ]; then
|
||||
print_error "AITBC CLI not found at $CLI_PATH"
|
||||
((issues++))
|
||||
(( issues += 1 )) || true
|
||||
else
|
||||
print_success "AITBC CLI found"
|
||||
fi
|
||||
|
||||
# Check service availability
|
||||
local services=("8000:Exchange" "8001:Coordinator" "8006:Genesis-Node" "8007:Follower-Node")
|
||||
local services=("8001:Exchange" "8000:Coordinator" "8006:Genesis-Node" "8006:Follower-Node")
|
||||
for service in "${services[@]}"; do
|
||||
local port=$(echo "$service" | cut -d: -f1)
|
||||
local name=$(echo "$service" | cut -d: -f2)
|
||||
@@ -131,7 +131,7 @@ check_system_readiness() {
|
||||
print_success "$name service (port $port) is accessible"
|
||||
else
|
||||
print_warning "$name service (port $port) may not be running"
|
||||
((issues++))
|
||||
(( issues += 1 )) || true
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -140,7 +140,7 @@ check_system_readiness() {
|
||||
print_success "Ollama service is running"
|
||||
else
|
||||
print_warning "Ollama service may not be running (needed for Stage 3)"
|
||||
((issues++))
|
||||
(( issues += 1 )) || true
|
||||
fi
|
||||
|
||||
# Check log directory
|
||||
@@ -152,7 +152,7 @@ check_system_readiness() {
|
||||
# Check training scripts
|
||||
if [ ! -d "$SCRIPT_DIR" ]; then
|
||||
print_error "Training scripts directory not found: $SCRIPT_DIR"
|
||||
((issues++))
|
||||
(( issues += 1 )) || true
|
||||
fi
|
||||
|
||||
if [ $issues -eq 0 ]; then
|
||||
@@ -250,7 +250,7 @@ run_complete_training() {
|
||||
print_progress $stage "Starting"
|
||||
|
||||
if run_stage $stage; then
|
||||
((completed_stages++))
|
||||
((completed_stages+=1))
|
||||
print_success "Stage $stage completed successfully"
|
||||
|
||||
# Ask if user wants to continue
|
||||
@@ -310,7 +310,7 @@ review_progress() {
|
||||
for stage in {1..5}; do
|
||||
local log_file="$LOG_DIR/training_stage${stage}.log"
|
||||
if [ -f "$log_file" ] && grep -q "completed successfully" "$log_file"; then
|
||||
((completed++))
|
||||
(( completed += 1 )) || true
|
||||
echo "✅ Stage $stage: Completed"
|
||||
else
|
||||
echo "❌ Stage $stage: Not completed"
|
||||
|
||||
@@ -43,7 +43,7 @@ genesis_block_initialization() {
|
||||
NODE_URL="http://localhost:8006" cli_cmd "blockchain genesis" || print_warning "Genesis block inspection failed"
|
||||
|
||||
print_status "Initializing blockchain on Follower Node..."
|
||||
if NODE_URL="http://localhost:8007" cli_cmd "blockchain init --force"; then
|
||||
if NODE_URL="http://aitbc1:8006" cli_cmd "blockchain init --force"; then
|
||||
print_success "Blockchain initialized on Follower Node"
|
||||
else
|
||||
print_warning "Blockchain may already be initialized on Follower Node"
|
||||
@@ -56,11 +56,11 @@ genesis_block_initialization() {
|
||||
print_warning "Genesis Node RPC (port 8006) is not accessible"
|
||||
fi
|
||||
|
||||
print_status "Verifying RPC connectivity to Follower Node (port 8007)..."
|
||||
if curl -s http://localhost:8007/rpc/info > /dev/null 2>&1; then
|
||||
print_success "Follower Node RPC (port 8007) is accessible"
|
||||
print_status "Verifying RPC connectivity to Follower Node (port 8006 on aitbc1)..."
|
||||
if curl -s http://aitbc1:8006/rpc/info > /dev/null 2>&1; then
|
||||
print_success "Follower Node RPC (port 8006 on aitbc1) is accessible"
|
||||
else
|
||||
print_warning "Follower Node RPC (port 8007) is not accessible"
|
||||
print_warning "Follower Node RPC (port 8006 on aitbc1) is not accessible"
|
||||
fi
|
||||
|
||||
print_status "Verifying Follower Node RPC also runs on port 8006..."
|
||||
|
||||
@@ -156,13 +156,13 @@ node_specific_blockchain() {
|
||||
NODE_URL="http://localhost:8006" $CLI_PATH blockchain info 2>/dev/null || print_warning "Genesis node blockchain info not available"
|
||||
log "Genesis node blockchain operations tested"
|
||||
|
||||
print_status "Testing Follower Node blockchain operations (port 8007)..."
|
||||
NODE_URL="http://localhost:8007" $CLI_PATH blockchain info 2>/dev/null || print_warning "Follower node blockchain info not available"
|
||||
print_status "Testing Follower Node blockchain operations (port 8006 on aitbc1)..."
|
||||
NODE_URL="http://aitbc1:8006" $CLI_PATH blockchain info 2>/dev/null || print_warning "Follower node blockchain info not available"
|
||||
log "Follower node blockchain operations tested"
|
||||
|
||||
print_status "Comparing blockchain heights between nodes..."
|
||||
GENESIS_HEIGHT=$(NODE_URL="http://localhost:8006" $CLI_PATH blockchain height 2>/dev/null | grep -o '[0-9]*' | head -1 || echo "0")
|
||||
FOLLOWER_HEIGHT=$(NODE_URL="http://localhost:8007" $CLI_PATH blockchain height 2>/dev/null | grep -o '[0-9]*' | head -1 || echo "0")
|
||||
FOLLOWER_HEIGHT=$(NODE_URL="http://aitbc1:8006" $CLI_PATH blockchain height 2>/dev/null | grep -o '[0-9]*' | head -1 || echo "0")
|
||||
|
||||
print_status "Genesis height: $GENESIS_HEIGHT, Follower height: $FOLLOWER_HEIGHT"
|
||||
log "Node comparison: Genesis=$GENESIS_HEIGHT, Follower=$FOLLOWER_HEIGHT"
|
||||
|
||||
@@ -217,13 +217,13 @@ node_specific_ai() {
|
||||
NODE_URL="http://localhost:8006" $CLI_PATH ai --job --submit --type inference --prompt "Genesis node test" 2>/dev/null || print_warning "Genesis node AI job submission failed"
|
||||
log "Genesis node AI operations tested"
|
||||
|
||||
print_status "Testing AI operations on Follower Node (port 8007)..."
|
||||
NODE_URL="http://localhost:8007" $CLI_PATH ai --job --submit --type parallel --prompt "Follower node test" 2>/dev/null || print_warning "Follower node AI job submission failed"
|
||||
print_status "Testing AI operations on Follower Node (port 8006 on aitbc1)..."
|
||||
NODE_URL="http://aitbc1:8006" $CLI_PATH ai --job --submit --type parallel --prompt "Follower node test" 2>/dev/null || print_warning "Follower node AI job submission failed"
|
||||
log "Follower node AI operations tested"
|
||||
|
||||
print_status "Comparing AI service availability between nodes..."
|
||||
GENESIS_STATUS=$(NODE_URL="http://localhost:8006" $CLI_PATH ai --service --status --name coordinator 2>/dev/null || echo "unavailable")
|
||||
FOLLOWER_STATUS=$(NODE_URL="http://localhost:8007" $CLI_PATH ai --service --status --name coordinator 2>/dev/null || echo "unavailable")
|
||||
FOLLOWER_STATUS=$(NODE_URL="http://aitbc1:8006" $CLI_PATH ai --service --status --name coordinator 2>/dev/null || echo "unavailable")
|
||||
|
||||
print_status "Genesis AI services: $GENESIS_STATUS"
|
||||
print_status "Follower AI services: $FOLLOWER_STATUS"
|
||||
|
||||
@@ -192,13 +192,13 @@ node_specific_marketplace() {
|
||||
NODE_URL="http://localhost:8006" $CLI_PATH marketplace --list 2>/dev/null || print_warning "Genesis node marketplace not available"
|
||||
log "Genesis node marketplace operations tested"
|
||||
|
||||
print_status "Testing marketplace on Follower Node (port 8007)..."
|
||||
NODE_URL="http://localhost:8007" $CLI_PATH marketplace --list 2>/dev/null || print_warning "Follower node marketplace not available"
|
||||
print_status "Testing marketplace on Follower Node (port 8006 on aitbc1)..."
|
||||
NODE_URL="http://aitbc1:8006" $CLI_PATH marketplace --list 2>/dev/null || print_warning "Follower node marketplace not available"
|
||||
log "Follower node marketplace operations tested"
|
||||
|
||||
print_status "Comparing marketplace data between nodes..."
|
||||
GENESIS_ITEMS=$(NODE_URL="http://localhost:8006" $CLI_PATH marketplace --list 2>/dev/null | wc -l || echo "0")
|
||||
FOLLOWER_ITEMS=$(NODE_URL="http://localhost:8007" $CLI_PATH marketplace --list 2>/dev/null | wc -l || echo "0")
|
||||
FOLLOWER_ITEMS=$(NODE_URL="http://aitbc1:8006" $CLI_PATH marketplace --list 2>/dev/null | wc -l || echo "0")
|
||||
|
||||
print_status "Genesis marketplace items: $GENESIS_ITEMS"
|
||||
print_status "Follower marketplace items: $FOLLOWER_ITEMS"
|
||||
@@ -260,7 +260,7 @@ cross_node_coordination() {
|
||||
log "Genesis node economic data generated"
|
||||
|
||||
# Generate economic data on follower node
|
||||
NODE_URL="http://localhost:8007" $CLI_PATH economics --market --analyze 2>/dev/null || print_warning "Follower node economic analysis failed"
|
||||
NODE_URL="http://aitbc1:8006" $CLI_PATH economics --market --analyze 2>/dev/null || print_warning "Follower node economic analysis failed"
|
||||
log "Follower node economic data generated"
|
||||
|
||||
# Test economic coordination
|
||||
|
||||
@@ -95,7 +95,7 @@ multi_node_coordination() {
|
||||
print_status "5.2 Multi-Node Coordination"
|
||||
|
||||
print_status "Checking cluster status across all nodes..."
|
||||
$CLI_PATH cluster --status --nodes aitbc,aitbc1 2>/dev/null || print_warning "Cluster status command not available"
|
||||
$CLI_PATH cluster status 2>/dev/null || print_warning "Cluster status command not available"
|
||||
log "Cluster status across nodes checked"
|
||||
|
||||
print_status "Syncing all nodes..."
|
||||
@@ -111,7 +111,7 @@ multi_node_coordination() {
|
||||
log "Failover coordination on Genesis node tested"
|
||||
|
||||
print_status "Testing recovery coordination on Follower Node..."
|
||||
NODE_URL="http://localhost:8007" $CLI_PATH cluster --coordinate --action recovery 2>/dev/null || print_warning "Recovery coordination failed"
|
||||
NODE_URL="http://aitbc1:8006" $CLI_PATH cluster --coordinate --action recovery 2>/dev/null || print_warning "Recovery coordination failed"
|
||||
log "Recovery coordination on Follower node tested"
|
||||
|
||||
print_success "5.2 Multi-Node Coordination completed"
|
||||
@@ -122,7 +122,7 @@ performance_optimization() {
|
||||
print_status "5.3 Performance Optimization"
|
||||
|
||||
print_status "Running comprehensive performance benchmark..."
|
||||
$CLI_PATH performance --benchmark --suite comprehensive 2>/dev/null || print_warning "Performance benchmark command not available"
|
||||
$CLI_PATH performance benchmark 2>/dev/null || print_warning "Performance benchmark command not available"
|
||||
log "Comprehensive performance benchmark executed"
|
||||
|
||||
print_status "Optimizing for low latency..."
|
||||
@@ -323,7 +323,7 @@ final_certification_exam() {
|
||||
|
||||
# Test 1: Basic operations
|
||||
if $CLI_PATH --version > /dev/null 2>&1; then
|
||||
((TESTS_PASSED++))
|
||||
(( TESTS_PASSED += 1 )) || true
|
||||
log "Certification test 1 (CLI version): PASSED"
|
||||
else
|
||||
log "Certification test 1 (CLI version): FAILED"
|
||||
@@ -331,7 +331,7 @@ final_certification_exam() {
|
||||
|
||||
# Test 2: Wallet operations
|
||||
if $CLI_PATH wallet balance "$WALLET_NAME" > /dev/null 2>&1; then
|
||||
((TESTS_PASSED++))
|
||||
(( TESTS_PASSED += 1 )) || true
|
||||
log "Certification test 2 (Wallet balance): PASSED"
|
||||
else
|
||||
log "Certification test 2 (Wallet balance): FAILED"
|
||||
@@ -339,7 +339,7 @@ final_certification_exam() {
|
||||
|
||||
# Test 3: Blockchain operations
|
||||
if $CLI_PATH blockchain info > /dev/null 2>&1; then
|
||||
((TESTS_PASSED++))
|
||||
(( TESTS_PASSED += 1 )) || true
|
||||
log "Certification test 3 (Blockchain info): PASSED"
|
||||
else
|
||||
log "Certification test 3 (Blockchain info): FAILED"
|
||||
@@ -347,7 +347,7 @@ final_certification_exam() {
|
||||
|
||||
# Test 4: AI operations
|
||||
if $CLI_PATH ai status > /dev/null 2>&1; then
|
||||
((TESTS_PASSED++))
|
||||
(( TESTS_PASSED += 1 )) || true
|
||||
log "Certification test 4 (AI status): PASSED"
|
||||
else
|
||||
log "Certification test 4 (AI status): FAILED"
|
||||
@@ -355,47 +355,47 @@ final_certification_exam() {
|
||||
|
||||
# Test 5: Marketplace operations
|
||||
if $CLI_PATH market list > /dev/null 2>&1; then
|
||||
((TESTS_PASSED++))
|
||||
(( TESTS_PASSED += 1 )) || true
|
||||
log "Certification test 5 (Marketplace list): PASSED"
|
||||
else
|
||||
log "Certification test 5 (Marketplace list): FAILED"
|
||||
fi
|
||||
|
||||
# Test 6: Economic operations
|
||||
if $CLI_PATH economics --model --type cost-optimization > /dev/null 2>&1; then
|
||||
((TESTS_PASSED++))
|
||||
if $CLI_PATH simulate price > /dev/null 2>&1; then
|
||||
(( TESTS_PASSED += 1 )) || true
|
||||
log "Certification test 6 (Economic modeling): PASSED"
|
||||
else
|
||||
log "Certification test 6 (Economic modeling): FAILED"
|
||||
fi
|
||||
|
||||
# Test 7: Analytics operations
|
||||
if $CLI_PATH analytics --report --type performance > /dev/null 2>&1; then
|
||||
((TESTS_PASSED++))
|
||||
if $CLI_PATH analytics blocks > /dev/null 2>&1; then
|
||||
(( TESTS_PASSED += 1 )) || true
|
||||
log "Certification test 7 (Analytics report): PASSED"
|
||||
else
|
||||
log "Certification test 7 (Analytics report): FAILED"
|
||||
fi
|
||||
|
||||
# Test 8: Automation operations
|
||||
if $CLI_PATH automate --workflow --name test-workflow > /dev/null 2>&1; then
|
||||
((TESTS_PASSED++))
|
||||
if $CLI_PATH workflow create --name test > /dev/null 2>&1; then
|
||||
(( TESTS_PASSED += 1 )) || true
|
||||
log "Certification test 8 (Automation workflow): PASSED"
|
||||
else
|
||||
log "Certification test 8 (Automation workflow): FAILED"
|
||||
fi
|
||||
|
||||
# Test 9: Cluster operations
|
||||
if $CLI_PATH cluster --status --nodes aitbc,aitbc1 > /dev/null 2>&1; then
|
||||
((TESTS_PASSED++))
|
||||
if $CLI_PATH cluster status > /dev/null 2>&1; then
|
||||
(( TESTS_PASSED += 1 )) || true
|
||||
log "Certification test 9 (Cluster status): PASSED"
|
||||
else
|
||||
log "Certification test 9 (Cluster status): FAILED"
|
||||
fi
|
||||
|
||||
# Test 10: Performance operations
|
||||
if $CLI_PATH performance --benchmark --suite comprehensive > /dev/null 2>&1; then
|
||||
((TESTS_PASSED++))
|
||||
if $CLI_PATH performance benchmark > /dev/null 2>&1; then
|
||||
(( TESTS_PASSED += 1 )) || true
|
||||
log "Certification test 10 (Performance benchmark): PASSED"
|
||||
else
|
||||
log "Certification test 10 (Performance benchmark): FAILED"
|
||||
|
||||
@@ -17,13 +17,13 @@ export WALLET_NAME="${WALLET_NAME:-openclaw-trainee}"
|
||||
export WALLET_PASSWORD="${WALLET_PASSWORD:-trainee123}"
|
||||
export TRAINING_TIMEOUT="${TRAINING_TIMEOUT:-300}"
|
||||
export GENESIS_NODE="http://localhost:8006"
|
||||
export FOLLOWER_NODE="http://localhost:8007"
|
||||
export FOLLOWER_NODE="http://aitbc1:8006"
|
||||
|
||||
# Service endpoints
|
||||
export SERVICES=(
|
||||
"8000:Coordinator"
|
||||
"8006:Genesis-Node"
|
||||
"8007:Follower-Node"
|
||||
"8006:Follower-Node"
|
||||
"11434:Ollama"
|
||||
)
|
||||
|
||||
@@ -186,7 +186,7 @@ check_all_services() {
|
||||
local name=$(echo "$service" | cut -d: -f2)
|
||||
|
||||
if ! check_service "$port" "$name"; then
|
||||
((failed++))
|
||||
(( failed += 1 )) || true
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -230,7 +230,7 @@ benchmark_with_retry() {
|
||||
local success=false
|
||||
|
||||
while [[ $attempt -lt $max_retries ]] && [[ "$success" == "false" ]]; do
|
||||
((attempt++))
|
||||
(( attempt += 1 )) || true
|
||||
|
||||
if eval "$cmd" &>/dev/null; then
|
||||
success=true
|
||||
@@ -379,12 +379,12 @@ check_prerequisites_full() {
|
||||
|
||||
# Check CLI
|
||||
if ! check_cli; then
|
||||
((errors++)) || true
|
||||
(( errors += 1 )) || true || true
|
||||
fi
|
||||
|
||||
# Check services
|
||||
if ! check_all_services; then
|
||||
((errors++)) || true
|
||||
(( errors += 1 )) || true || true
|
||||
fi
|
||||
|
||||
# Check log directory
|
||||
@@ -392,7 +392,7 @@ check_prerequisites_full() {
|
||||
print_status "Creating log directory..."
|
||||
mkdir -p "$LOG_DIR" || {
|
||||
print_error "Cannot create log directory"
|
||||
((errors++)) || true
|
||||
(( errors += 1 )) || true || true
|
||||
}
|
||||
fi
|
||||
|
||||
@@ -427,7 +427,7 @@ init_progress() {
|
||||
# Update progress
|
||||
update_progress() {
|
||||
local step_name="$1"
|
||||
((CURRENT_STEP++))
|
||||
(( CURRENT_STEP += 1 )) || true
|
||||
|
||||
local elapsed=$(( $(date +%s) - STEP_START_TIME ))
|
||||
local percent=$((CURRENT_STEP * 100 / TOTAL_STEPS))
|
||||
@@ -447,7 +447,7 @@ cli_cmd() {
|
||||
local attempt=0
|
||||
|
||||
while [[ $attempt -lt $max_retries ]]; do
|
||||
((attempt++))
|
||||
(( attempt += 1 )) || true
|
||||
|
||||
if $CLI_PATH $cmd 2>/dev/null; then
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user