All checks were successful
Documentation Validation / validate-docs (push) Successful in 10s
📋 Workflow Restructuring:
• Add AI prompt and response tracking to marketplace scenario
• Replace immediate actions with production deployment scripts (25-27)
• Add production marketplace testing with real AI integration (30)
• Reorganize short-term goals with operations automation focus
• Add comprehensive testing and deployment automation steps
• Remove redundant inline bash snippets in favor of script references
1032 lines
31 KiB
Markdown
1032 lines
31 KiB
Markdown
---
|
||
description: Multi-node blockchain deployment and setup workflow
|
||
---
|
||
|
||
# Multi-Node Blockchain Deployment Workflow
|
||
|
||
This workflow sets up a two-node AITBC blockchain network (aitbc1 as genesis authority, aitbc as follower node), creates wallets, and demonstrates cross-node transactions.
|
||
|
||
## Prerequisites
|
||
|
||
- SSH access to both nodes (aitbc1 and aitbc)
|
||
- Both nodes have the AITBC repository cloned
|
||
- Redis available for cross-node gossip
|
||
- Python venv at `/opt/aitbc/venv`
|
||
- AITBC CLI tool available (aliased as `aitbc`)
|
||
- CLI tool configured to use `/etc/aitbc/blockchain.env` by default
|
||
|
||
## Pre-Flight Setup
|
||
|
||
Before running the workflow, ensure the following setup is complete:
|
||
|
||
```bash
|
||
# Run the pre-flight setup script
|
||
/opt/aitbc/scripts/workflow/01_preflight_setup.sh
|
||
```
|
||
|
||
## Directory Structure
|
||
|
||
- `/opt/aitbc/venv` - Central Python virtual environment
|
||
- `/opt/aitbc/requirements.txt` - Python dependencies (includes CLI dependencies)
|
||
- `/etc/aitbc/.env` - Central environment configuration
|
||
- `/var/lib/aitbc/data` - Blockchain database files
|
||
- `/var/lib/aitbc/keystore` - Wallet credentials
|
||
- `/var/log/aitbc/` - Service logs
|
||
|
||
## Steps
|
||
|
||
### Environment Configuration
|
||
|
||
The workflow uses the single central `/etc/aitbc/.env` file as the configuration for both nodes:
|
||
|
||
- **Base Configuration**: The central config contains all default settings
|
||
- **Node-Specific Adaptation**: Each node adapts the config for its role (genesis vs follower)
|
||
- **Path Updates**: Paths are updated to use the standardized directory structure
|
||
- **Backup Strategy**: Original config is backed up before modifications
|
||
- **Standard Location**: Config moved to `/etc/aitbc/` following system standards
|
||
- **CLI Integration**: AITBC CLI tool uses this config file by default
|
||
|
||
### 🚨 Important: Genesis Block Architecture
|
||
|
||
**CRITICAL**: Only the genesis authority node (aitbc1) should have the genesis block!
|
||
|
||
```bash
|
||
# ❌ WRONG - Do NOT copy genesis block to follower nodes
|
||
# scp aitbc1:/var/lib/aitbc/data/ait-mainnet/genesis.json aitbc:/var/lib/aitbc/data/ait-mainnet/
|
||
|
||
# ✅ CORRECT - Follower nodes sync genesis via blockchain protocol
|
||
# aitbc will automatically receive genesis block from aitbc1 during sync
|
||
```
|
||
|
||
**Architecture Overview:**
|
||
1. **aitbc1 (Genesis Authority)**: Creates genesis block with initial wallets
|
||
2. **aitbc (Follower Node)**: Syncs from aitbc1, receives genesis block automatically
|
||
3. **Wallet Creation**: New wallets attach to existing blockchain using genesis keys
|
||
4. **Access AIT Coins**: Genesis wallets control initial supply, new wallets receive via transactions
|
||
|
||
**Key Principles:**
|
||
- **Single Genesis Source**: Only aitbc1 creates and holds the original genesis block
|
||
- **Blockchain Sync**: Followers receive blockchain data through sync protocol, not file copying
|
||
- **Wallet Attachment**: New wallets attach to existing chain, don't create new genesis
|
||
- **Coin Access**: AIT coins are accessed through transactions from genesis wallets
|
||
|
||
### 1. Prepare aitbc1 (Genesis Authority Node)
|
||
|
||
```bash
|
||
# Run the genesis authority setup script
|
||
/opt/aitbc/scripts/workflow/02_genesis_authority_setup.sh
|
||
```
|
||
|
||
### 2. Verify aitbc1 Genesis State
|
||
|
||
```bash
|
||
# Check blockchain state
|
||
curl -s http://localhost:8006/rpc/head | jq .
|
||
curl -s http://localhost:8006/rpc/info | jq .
|
||
curl -s http://localhost:8006/rpc/supply | jq .
|
||
|
||
# Check genesis wallet balance
|
||
GENESIS_ADDR=$(cat /var/lib/aitbc/keystore/aitbc1genesis.json | jq -r '.address')
|
||
curl -s "http://localhost:8006/rpc/getBalance/$GENESIS_ADDR" | jq .
|
||
```
|
||
|
||
### 3. Prepare aitbc (Follower Node)
|
||
|
||
```bash
|
||
# Run the follower node setup script (executed on aitbc)
|
||
ssh aitbc '/opt/aitbc/scripts/workflow/03_follower_node_setup.sh'
|
||
```
|
||
|
||
### 4. Watch Blockchain Sync
|
||
|
||
```bash
|
||
# On aitbc, monitor sync progress
|
||
watch -n 2 'curl -s http://localhost:8006/rpc/head | jq .height'
|
||
|
||
# Compare with aitbc1
|
||
ssh aitbc1 'curl -s http://localhost:8006/rpc/head | jq .height'
|
||
|
||
# Alternative: Batch sync for faster initial setup
|
||
if [ $(curl -s http://localhost:8006/rpc/head | jq .height) -lt 10 ]; then
|
||
echo "Importing first 10 blocks from aitbc1..."
|
||
for height in {2..10}; do
|
||
curl -s "http://10.1.223.40:8006/rpc/blocks-range?start=$height&end=$height" | \
|
||
jq '.blocks[0]' > /tmp/block$height.json
|
||
curl -X POST http://localhost:8006/rpc/importBlock \
|
||
-H "Content-Type: application/json" -d @/tmp/block$height.json
|
||
echo "Imported block $height"
|
||
done
|
||
fi
|
||
```
|
||
|
||
### 5. Create Wallet on aitbc
|
||
|
||
```bash
|
||
# Run the wallet creation script
|
||
/opt/aitbc/scripts/workflow/04_create_wallet.sh
|
||
```
|
||
|
||
**🔑 Wallet Attachment & Coin Access:**
|
||
|
||
The newly created wallet on aitbc will:
|
||
1. **Attach to Existing Blockchain**: Connect to the blockchain created by aitbc1
|
||
2. **Use Genesis Keys**: Access the blockchain using the genesis block's cryptographic keys
|
||
3. **Receive AIT Coins**: Get coins through transactions from genesis wallets
|
||
4. **No New Genesis**: Does NOT create a new genesis block or chain
|
||
|
||
**Important Notes:**
|
||
- The wallet attaches to the existing blockchain network
|
||
- AIT coins are transferred from genesis wallets, not created
|
||
- The wallet can only transact after receiving coins from genesis
|
||
- All wallets share the same blockchain, created by aitbc1
|
||
|
||
### 6. Blockchain Sync Fix (Enhanced)
|
||
|
||
```bash
|
||
# Fix blockchain synchronization issues between nodes
|
||
/opt/aitbc/scripts/workflow/08_blockchain_sync_fix.sh
|
||
```
|
||
|
||
### 7. Send 1000 AIT from Genesis to aitbc Wallet (Enhanced)
|
||
|
||
```bash
|
||
# Run the enhanced transaction manager
|
||
/opt/aitbc/scripts/workflow/09_transaction_manager.sh
|
||
```
|
||
|
||
### 8. Final Verification
|
||
|
||
```bash
|
||
# Run the final verification script
|
||
/opt/aitbc/scripts/workflow/06_final_verification.sh
|
||
```
|
||
|
||
### 9. Complete Workflow (All-in-One)
|
||
|
||
```bash
|
||
# Execute the complete optimized workflow
|
||
/opt/aitbc/scripts/workflow/10_complete_workflow.sh
|
||
```
|
||
|
||
### 10. Network Optimization (Performance Enhancement)
|
||
|
||
```bash
|
||
# Optimize network configuration and performance
|
||
/opt/aitbc/scripts/workflow/11_network_optimizer.sh
|
||
```
|
||
|
||
### 11. Complete Sync (Optional - for full demonstration)
|
||
|
||
```bash
|
||
# Complete blockchain synchronization between nodes
|
||
/opt/aitbc/scripts/workflow/12_complete_sync.sh
|
||
```
|
||
|
||
### 12. Legacy Environment File Cleanup
|
||
|
||
```bash
|
||
# Remove all legacy .env.production and .env references from systemd services
|
||
/opt/aitbc/scripts/workflow/13_maintenance_automation.sh
|
||
```
|
||
|
||
### 13. Final Configuration Verification
|
||
|
||
```bash
|
||
# Verify all configurations are using centralized files
|
||
/opt/aitbc/scripts/workflow/13_maintenance_automation.sh
|
||
```
|
||
|
||
### 14. Cross-Node Code Synchronization
|
||
|
||
```bash
|
||
# Ensure aitbc node stays synchronized with aitbc1 after code changes
|
||
/opt/aitbc/scripts/workflow/13_maintenance_automation.sh
|
||
```
|
||
|
||
### 15. Complete Workflow Execution
|
||
|
||
```bash
|
||
# Execute the complete multi-node blockchain setup workflow
|
||
/opt/aitbc/scripts/workflow/14_production_ready.sh
|
||
```
|
||
|
||
### 🔍 Configuration Overview
|
||
|
||
The workflow uses `/etc/aitbc/blockchain.env` as the central configuration file.
|
||
|
||
### 🔍 Verification Commands
|
||
|
||
```bash
|
||
# Quick health check
|
||
/opt/aitbc/scripts/health_check.sh
|
||
```
|
||
|
||
### 📊 Advanced Monitoring
|
||
|
||
```bash
|
||
# Real-time blockchain monitoring
|
||
watch -n 5 '/opt/aitbc/scripts/health_check.sh'
|
||
```
|
||
|
||
### 🚀 Performance Testing
|
||
|
||
```bash
|
||
# Test transaction throughput
|
||
/opt/aitbc/tests/integration_test.sh
|
||
```
|
||
|
||
## Performance Optimization
|
||
|
||
### Blockchain Performance
|
||
|
||
#### **Block Production Tuning**
|
||
Optimize block time for faster consensus (in `/etc/aitbc/blockchain.env`):
|
||
```
|
||
block_time_seconds=2 # Default: 10, faster for testing
|
||
```
|
||
|
||
#### **Network Optimization**
|
||
Optimize P2P settings:
|
||
```
|
||
p2p_bind_port=7070 # Standard port for P2P communication
|
||
```
|
||
|
||
#### **Database Performance**
|
||
Ensure proper database permissions and location:
|
||
```
|
||
db_path=/var/lib/aitbc/data/ait-mainnet/chain.db
|
||
chmod 755 /var/lib/aitbc/data
|
||
```
|
||
|
||
### System Resource Optimization
|
||
|
||
#### **Memory Management**
|
||
Monitor memory usage:
|
||
```bash
|
||
systemctl status aitbc-blockchain-node --no-pager | grep Memory
|
||
```
|
||
|
||
#### **CPU Optimization**
|
||
Set process affinity for better performance:
|
||
```bash
|
||
echo "CPUAffinity=0-3" > /opt/aitbc/systemd/cpuset.conf
|
||
```
|
||
|
||
### Monitoring and Metrics
|
||
|
||
#### **Real-time Monitoring**
|
||
Monitor blockchain height in real-time:
|
||
```bash
|
||
watch -n 2 'curl -s http://localhost:8006/rpc/head | jq .height'
|
||
```
|
||
|
||
#### **Performance Metrics**
|
||
Check block production rate:
|
||
```bash
|
||
curl -s http://localhost:8006/rpc/info | jq '.genesis_params.block_time_seconds'
|
||
```
|
||
|
||
## Troubleshooting
|
||
|
||
### Common Issues and Solutions
|
||
|
||
#### **Systemd Service Failures**
|
||
```bash
|
||
# Check service status and logs
|
||
systemctl status aitbc-blockchain-*.service --no-pager
|
||
journalctl -u aitbc-blockchain-node.service -n 10 --no-pager
|
||
|
||
# Fix environment file issues
|
||
find /etc/systemd/system/aitbc-blockchain-*.service.d/ -name "*.conf" -exec grep -l "EnvironmentFile" {} \;
|
||
find /etc/systemd/system/aitbc-blockchain-*.service.d/ -name "*.conf" -exec sed -i 's|EnvironmentFile=/opt/aitbc/.env|EnvironmentFile=/etc/aitbc/blockchain.env|g' {} \;
|
||
|
||
# Fix virtual environment paths in overrides
|
||
find /etc/systemd/system/aitbc-blockchain-*.service.d/ -name "override.conf" -exec sed -i 's|/opt/aitbc/apps/blockchain-node/.venv/bin/python3|/opt/aitbc/venv/bin/python3|g' {} \;
|
||
|
||
# Reload and restart
|
||
systemctl daemon-reload
|
||
systemctl restart aitbc-blockchain-node aitbc-blockchain-rpc
|
||
```
|
||
|
||
#### **RPC Service Issues**
|
||
```bash
|
||
# Check if RPC is accessible
|
||
curl -s http://localhost:8006/rpc/head | jq .
|
||
|
||
# Manual RPC start for debugging
|
||
cd /opt/aitbc/apps/blockchain-node
|
||
PYTHONPATH=/opt/aitbc/apps/blockchain-node/src:/opt/aitbc/apps/blockchain-node/scripts \
|
||
/opt/aitbc/venv/bin/python -m uvicorn aitbc_chain.app:app --host 0.0.0.0 --port 8006
|
||
```
|
||
|
||
#### **Keystore Issues**
|
||
```bash
|
||
# Create keystore password file and check permissions
|
||
/opt/aitbc/scripts/workflow/01_preflight_setup.sh
|
||
```
|
||
|
||
#### **Sync Issues**
|
||
```bash
|
||
# Check and fix blockchain synchronization issues
|
||
/opt/aitbc/scripts/workflow/08_blockchain_sync_fix.sh
|
||
```
|
||
|
||
### General Troubleshooting
|
||
|
||
- **Services won't start**: Check `/var/log/aitbc/` for service logs
|
||
- **Sync issues**: Verify Redis connectivity between nodes
|
||
- **Transaction failures**: Check wallet nonce and balance
|
||
- **Permission errors**: Ensure `/var/lib/aitbc/` is owned by root with proper permissions
|
||
- **Configuration issues**: Verify `/etc/aitbc/blockchain.env` file contents and systemd service EnvironmentFile paths
|
||
|
||
## Next Steps
|
||
|
||
### 🚀 Advanced Operations
|
||
|
||
Now that your multi-node blockchain is operational, you can explore advanced features and operations.
|
||
|
||
#### **Enterprise CLI Usage**
|
||
```bash
|
||
# Use the enhanced CLI for advanced operations
|
||
/opt/aitbc/aitbc-cli-final wallet --help
|
||
/opt/aitbc/cli/enterprise_cli.py --help
|
||
|
||
# Batch transactions
|
||
python /opt/aitbc/cli/enterprise_cli.py sample
|
||
python /opt/aitbc/cli/enterprise_cli.py batch --file sample_batch.json --password-file /var/lib/aitbc/keystore/.password
|
||
|
||
# Mining operations
|
||
python /opt/aitbc/cli/enterprise_cli.py mine start --wallet aitbc1genesis --threads 4
|
||
python /opt/aitbc/cli/enterprise_cli.py mine status
|
||
python /opt/aitbc/cli/enterprise_cli.py mine stop
|
||
|
||
# Marketplace operations
|
||
python /opt/aitbc/cli/enterprise_cli.py market list
|
||
python /opt/aitbc/cli/enterprise_cli.py market create --wallet seller --type "GPU" --price 1000 --description "High-performance GPU rental"
|
||
|
||
# AI services
|
||
python /opt/aitbc/cli/enterprise_cli.py ai submit --wallet client --type "text-generation" --prompt "Generate blockchain analysis" --payment 50 --password-file /var/lib/aitbc/keystore/.password
|
||
```
|
||
|
||
#### **Multi-Node Expansion**
|
||
```bash
|
||
# Add additional nodes to the network
|
||
# Example: Add a third node (would need to be provisioned first)
|
||
# ssh new-node 'bash /opt/aitbc/scripts/workflow/03_follower_node_setup.sh'
|
||
# Note: Current setup has aitbc1 (genesis) and aitbc (follower) only
|
||
```
|
||
|
||
#### **Performance Optimization**
|
||
```bash
|
||
# Monitor and optimize performance
|
||
echo "=== Performance Monitoring ==="
|
||
|
||
# Block production rate
|
||
curl -s http://localhost:8006/rpc/info | jq '.genesis_params.block_time_seconds'
|
||
|
||
# Transaction throughput
|
||
curl -s http://localhost:8006/rpc/mempool | jq '.transactions | length'
|
||
|
||
# Network sync status
|
||
curl -s http://localhost:8006/rpc/syncStatus | jq .
|
||
|
||
# Resource usage
|
||
htop
|
||
iotop
|
||
df -h /var/lib/aitbc/
|
||
```
|
||
|
||
### 🔧 Configuration Management
|
||
|
||
#### **Environment Configuration**
|
||
```bash
|
||
# Update configuration for production use
|
||
echo "=== Production Configuration ==="
|
||
|
||
# Update keystore password for production
|
||
echo 'your-secure-password-here' > /var/lib/aitbc/keystore/.password
|
||
chmod 600 /var/lib/aitbc/keystore/.password
|
||
|
||
# Update RPC settings for security
|
||
sed -i 's|bind_host=127.0.0.1|bind_host=0.0.0.0|g' /etc/aitbc/blockchain.env
|
||
|
||
# Update Redis for cluster mode
|
||
redis-cli -h localhost CONFIG SET appendonly yes
|
||
redis-cli -h localhost CONFIG SET save "900 1 300 10 60 10000"
|
||
```
|
||
|
||
#### **Service Configuration**
|
||
```bash
|
||
# Optimize systemd services for production
|
||
/opt/aitbc/scripts/workflow/15_service_optimization.sh
|
||
```
|
||
|
||
### 📊 Monitoring and Alerting
|
||
|
||
#### **Health Monitoring**
|
||
```bash
|
||
# Setup comprehensive health monitoring
|
||
/opt/aitbc/scripts/workflow/16_monitoring_setup.sh
|
||
```
|
||
|
||
### 🔒 Security Hardening
|
||
|
||
#### **Network Security**
|
||
```bash
|
||
# Implement security best practices
|
||
/opt/aitbc/scripts/workflow/17_security_hardening.sh
|
||
```
|
||
|
||
### 🚀 Production Readiness
|
||
|
||
#### **Readiness Validation**
|
||
```bash
|
||
# Run comprehensive production readiness check
|
||
/opt/aitbc/scripts/workflow/18_production_readiness.sh
|
||
```
|
||
|
||
### 📈 Scaling and Growth
|
||
|
||
#### **Horizontal Scaling**
|
||
```bash
|
||
# Prepare for horizontal scaling
|
||
/opt/aitbc/scripts/workflow/12_complete_sync.sh
|
||
```
|
||
|
||
#### **Load Balancing**
|
||
```bash
|
||
# Setup load balancing for RPC endpoints
|
||
# Note: HAProxy setup available in scaling scripts
|
||
/opt/aitbc/scripts/workflow/14_production_ready.sh
|
||
```
|
||
|
||
### 🧪 Testing and Validation
|
||
|
||
#### **Load Testing**
|
||
```bash
|
||
# Comprehensive load testing
|
||
/opt/aitbc/tests/integration_test.sh
|
||
```
|
||
|
||
#### **Integration Testing**
|
||
```bash
|
||
# Run full integration test suite
|
||
/opt/aitbc/tests/integration_test.sh
|
||
```
|
||
```bash
|
||
# Create comprehensive test suite
|
||
/opt/aitbc/tests/integration_test.sh
|
||
```
|
||
|
||
### 📚 Documentation and Training
|
||
|
||
#### **API Documentation**
|
||
```bash
|
||
# Generate API documentation
|
||
echo "=== API Documentation ==="
|
||
|
||
# Install documentation tools
|
||
pip install sphinx sphinx-rtd-theme
|
||
|
||
# Create documentation structure
|
||
mkdir -p /opt/aitbc/docs
|
||
cd /opt/aitbc/docs
|
||
|
||
# Generate API docs from code
|
||
sphinx-quickstart . --quiet --project "AITBC API" --author "AITBC Team" --release "1.0"
|
||
|
||
# Update configuration for auto-docs
|
||
cat >> conf.py << 'EOF'
|
||
# Auto-documentation settings
|
||
autoapi_dirs = ['../apps/blockchain-node/src']
|
||
autoapi_python_class_content = 'both'
|
||
autoapi_keep_files = True
|
||
EOF
|
||
|
||
# Build documentation
|
||
make html
|
||
echo "API documentation available at: /opt/aitbc/docs/_build/html"
|
||
```
|
||
|
||
#### **Training Materials**
|
||
```bash
|
||
# Create training materials
|
||
echo "=== Training Materials ==="
|
||
|
||
mkdir -p /opt/aitbc/training
|
||
|
||
# Create operator training guide
|
||
cat > /opt/aitbc/training/operator_guide.md << 'EOF'
|
||
# AITBC Operator Training Guide
|
||
|
||
## System Overview
|
||
- Multi-node blockchain architecture
|
||
- Service components and interactions
|
||
- Monitoring and maintenance procedures
|
||
|
||
## Daily Operations
|
||
- Health checks and monitoring
|
||
- Backup procedures
|
||
- Performance optimization
|
||
|
||
## Troubleshooting
|
||
- Common issues and solutions
|
||
- Emergency procedures
|
||
- Escalation paths
|
||
|
||
## Security
|
||
- Access control procedures
|
||
- Security best practices
|
||
- Incident response
|
||
|
||
## Advanced Operations
|
||
- Node provisioning
|
||
- Scaling procedures
|
||
- Load balancing
|
||
EOF
|
||
```
|
||
|
||
### 🎯 Production Readiness Checklist
|
||
|
||
#### **Pre-Production Validation**
|
||
```bash
|
||
# Run comprehensive production readiness check
|
||
/opt/aitbc/scripts/workflow/19_production_readiness_checklist.sh
|
||
```
|
||
|
||
The production readiness checklist validates:
|
||
- ✅ Security hardening status
|
||
- ✅ Performance metrics compliance
|
||
- ✅ Reliability and backup procedures
|
||
- ✅ Operations readiness
|
||
- ✅ Network connectivity
|
||
- ✅ Wallet and transaction functionality
|
||
|
||
---
|
||
|
||
### 🛒 MARKETPLACE SCENARIO TESTING
|
||
|
||
#### **Complete Marketplace Workflow Test**
|
||
|
||
This scenario tests the complete marketplace functionality including GPU bidding, confirmation, task execution, and blockchain payment processing.
|
||
|
||
```bash
|
||
# === MARKETPLACE WORKFLOW TEST ===
|
||
echo "=== 🛒 MARKETPLACE SCENARIO TESTING ==="
|
||
echo "Timestamp: $(date)"
|
||
echo ""
|
||
|
||
# 1. USER FROM AITBC SERVER BIDS ON GPU
|
||
echo "1. 🎯 USER BIDDING ON GPU PUBLISHED ON MARKET"
|
||
echo "=============================================="
|
||
|
||
# Check available GPU listings on aitbc
|
||
echo "Checking GPU marketplace listings on aitbc:"
|
||
ssh aitbc 'curl -s http://localhost:8006/rpc/market-list | jq .marketplace[0:3] | .[] | {id, title, price, status}'
|
||
|
||
# User places bid on GPU listing
|
||
echo "Placing bid on GPU listing..."
|
||
BID_RESULT=$(ssh aitbc 'curl -s -X POST http://localhost:8006/rpc/market-bid \
|
||
-H "Content-Type: application/json" \
|
||
-d "{
|
||
\"market_id\": \"gpu_001\",
|
||
\"bidder\": \"ait1e7d5e60688ff0b4a5c6863f1625e47945d84c94b\",
|
||
\"bid_amount\": 100,
|
||
\"duration_hours\": 2
|
||
}"')
|
||
|
||
echo "Bid result: $BID_RESULT"
|
||
BID_ID=$(echo "$BID_RESULT" | jq -r .bid_id 2>/dev/null || echo "unknown")
|
||
echo "Bid ID: $BID_ID"
|
||
|
||
# 2. AITBC1 CONFIRMS THE BID
|
||
echo ""
|
||
echo "2. ✅ AITBC1 CONFIRMATION"
|
||
echo "========================"
|
||
|
||
# aitbc1 reviews and confirms the bid
|
||
echo "aitbc1 reviewing bid $BID_ID..."
|
||
CONFIRM_RESULT=$(curl -s -X POST http://localhost:8006/rpc/market-confirm \
|
||
-H "Content-Type: application/json" \
|
||
-d "{
|
||
\"bid_id\": \"$BID_ID\",
|
||
\"confirm\": true,
|
||
\"provider\": \"ait1hqpufd2skt3kdhpfdqv7cc3adg6hdgaany343spdlw00xdqn37xsyvz60r\"
|
||
}")
|
||
|
||
echo "Confirmation result: $CONFIRM_RESULT"
|
||
JOB_ID=$(echo "$CONFIRM_RESULT" | jq -r .job_id 2>/dev/null || echo "unknown")
|
||
echo "Job ID: $JOB_ID"
|
||
|
||
# 3. AITBC SERVER SENDS OLLAMA TASK PROMPT
|
||
echo ""
|
||
echo "3. 🤖 AITBC SERVER SENDS OLLAMA TASK PROMPT"
|
||
echo "=========================================="
|
||
|
||
# aitbc server submits AI task using Ollama
|
||
echo "Submitting AI task to confirmed job..."
|
||
TASK_RESULT=$(ssh aitbc 'curl -s -X POST http://localhost:8006/rpc/ai-submit \
|
||
-H "Content-Type: application/json" \
|
||
-d "{
|
||
\"job_id\": "'"$JOB_ID"'",
|
||
\"task_type\": \"llm_inference\",
|
||
\"model\": \"llama2\",
|
||
\"prompt\": \"Analyze the performance implications of blockchain sharding on scalability and security.\",
|
||
\"parameters\": {
|
||
\"max_tokens\": 500,
|
||
\"temperature\": 0.7
|
||
}
|
||
}"')
|
||
|
||
echo "Task submission result: $TASK_RESULT"
|
||
TASK_ID=$(echo "$TASK_RESULT" | jq -r .task_id 2>/dev/null || echo "unknown")
|
||
echo "Task ID: $TASK_ID"
|
||
|
||
# Monitor task progress
|
||
echo "Monitoring task progress..."
|
||
for i in {1..5}; do
|
||
TASK_STATUS=$(ssh aitbc "curl -s http://localhost:8006/rpc/ai-status?task_id=$TASK_ID")
|
||
echo "Check $i: $TASK_STATUS"
|
||
STATUS=$(echo "$TASK_STATUS" | jq -r .status 2>/dev/null || echo "unknown")
|
||
|
||
if [ "$STATUS" = "completed" ]; then
|
||
echo "✅ Task completed!"
|
||
break
|
||
elif [ "$STATUS" = "failed" ]; then
|
||
echo "❌ Task failed!"
|
||
break
|
||
fi
|
||
|
||
sleep 2
|
||
done
|
||
|
||
# Get task result
|
||
if [ "$STATUS" = "completed" ]; then
|
||
TASK_RESULT=$(ssh aitbc "curl -s http://localhost:8006/rpc/ai-result?task_id=$TASK_ID")
|
||
echo "Task result: $TASK_RESULT"
|
||
fi
|
||
|
||
# 4. AITBC1 GETS PAYMENT OVER BLOCKCHAIN
|
||
echo ""
|
||
echo "4. 💰 AITBC1 BLOCKCHAIN PAYMENT"
|
||
echo "==============================="
|
||
|
||
# aitbc1 processes payment for completed job
|
||
echo "Processing blockchain payment for completed job..."
|
||
PAYMENT_RESULT=$(curl -s -X POST http://localhost:8006/rpc/market-payment \
|
||
-H "Content-Type: application/json" \
|
||
-d "{
|
||
\"job_id\": \"$JOB_ID\",
|
||
\"task_id\": \"$TASK_ID\",
|
||
\"amount\": 100,
|
||
\"recipient\": \"ait1hqpufd2skt3kdhpfdqv7cc3adg6hdgaany343spdlw00xdqn37xsyvz60r\",
|
||
\"currency\": \"AIT\"
|
||
}")
|
||
|
||
echo "Payment result: $PAYMENT_RESULT"
|
||
PAYMENT_TX=$(echo "$PAYMENT_RESULT" | jq -r .transaction_hash 2>/dev/null || echo "unknown")
|
||
echo "Payment transaction: $PAYMENT_TX"
|
||
|
||
# Wait for payment to be mined
|
||
echo "Waiting for payment to be mined..."
|
||
for i in {1..10}; do
|
||
TX_STATUS=$(curl -s "http://localhost:8006/rpc/tx/$PAYMENT_TX" | jq -r .block_height 2>/dev/null || echo "pending")
|
||
if [ "$TX_STATUS" != "null" ] && [ "$TX_STATUS" != "pending" ]; then
|
||
echo "✅ Payment mined in block: $TX_STATUS"
|
||
break
|
||
fi
|
||
sleep 3
|
||
done
|
||
|
||
# Verify final balances
|
||
echo ""
|
||
echo "5. 📊 FINAL BALANCE VERIFICATION"
|
||
echo "=============================="
|
||
|
||
# Check aitbc1 balance (should increase by payment amount)
|
||
AITBC1_BALANCE=$(curl -s "http://localhost:8006/rpc/getBalance/ait1hqpufd2skt3kdhpfdqv7cc3adg6hdgaany343spdlw00xdqn37xsyvz60r" | jq .balance)
|
||
echo "aitbc1 final balance: $AITBC1_BALANCE AIT"
|
||
|
||
# Check aitbc-user balance (should decrease by payment amount)
|
||
AITBC_USER_BALANCE=$(ssh aitbc 'curl -s "http://localhost:8006/rpc/getBalance/ait1e7d5e60688ff0b4a5c6863f1625e47945d84c94b" | jq .balance')
|
||
echo "aitbc-user final balance: $AITBC_USER_BALANCE AIT"
|
||
|
||
# Check marketplace status
|
||
echo ""
|
||
echo "6. 🏪 MARKETPLACE STATUS SUMMARY"
|
||
echo "==============================="
|
||
|
||
echo "Marketplace overview:"
|
||
curl -s http://localhost:8006/rpc/market-list | jq '.marketplace | length' 2>/dev/null || echo "0"
|
||
echo "Active listings"
|
||
|
||
echo "Job status:"
|
||
curl -s "http://localhost:8006/rpc/market-status?job_id=$JOB_ID" 2>/dev/null || echo "Job status unavailable"
|
||
|
||
echo ""
|
||
echo "=== 🛒 MARKETPLACE SCENARIO COMPLETE ==="
|
||
echo ""
|
||
echo "✅ SCENARIO RESULTS:"
|
||
echo "• User bid: $BID_ID"
|
||
echo "• Job confirmation: $JOB_ID"
|
||
echo "• Task execution: $TASK_ID"
|
||
echo "• Payment transaction: $PAYMENT_TX"
|
||
echo "• aitbc1 balance: $AITBC1_BALANCE AIT"
|
||
echo "• aitbc-user balance: $AITBC_USER_BALANCE AIT"
|
||
echo ""
|
||
echo "🎯 MARKETPLACE WORKFLOW: TESTED"
|
||
```
|
||
|
||
#### **Expected Scenario Flow:**
|
||
|
||
1. **🎯 User Bidding**: aitbc-user browses marketplace and bids on GPU listing
|
||
2. **✅ Provider Confirmation**: aitbc1 reviews and confirms the bid, creating job
|
||
3. **🤖 Task Execution**: aitbc server submits AI task via Ollama, monitors progress
|
||
4. **💰 Blockchain Payment**: aitbc1 receives payment for completed services via blockchain
|
||
|
||
#### **AI Prompt and Response Tracking:**
|
||
|
||
The production marketplace scenario now captures and displays:
|
||
|
||
- **🤖 AI Prompt**: The specific question asked by aitbc1 to the GPU
|
||
- **💬 AI Response**: Real response from the AI service (not simulated)
|
||
- **🔍 Task Details**: GPU utilization during AI task execution
|
||
- **💳 Payment Verification**: Blockchain transaction for AI services
|
||
|
||
**Production AI Integration Example:**
|
||
```
|
||
• Prompt asked by aitbc1: "Explain how GPU acceleration works in machine learning with CUDA"
|
||
• AI Task ID: job_079049b3
|
||
• Status: queued for processing
|
||
• Payment: 50 AIT for AI task execution
|
||
• Transaction: 0x6a09e40c94afadeb5c56a1ba2ab81770d539a837109a5e1e470641b2e0beecd6
|
||
• GPU: NVIDIA GeForce RTX 4060 Ti
|
||
• AI Service: Real integration (no simulation)
|
||
```
|
||
|
||
**Key Production Improvements:**
|
||
- ✅ **Real AI Service Integration**: No simulated responses
|
||
- ✅ **Proper Payment Format**: Correct payment field structure
|
||
- ✅ **Blockchain Payment Verification**: Actual transaction processing
|
||
- ✅ **Job Queue Management**: Real AI job submission and tracking
|
||
- ✅ **GPU Utilization Monitoring**: Real hardware metrics
|
||
|
||
#### **Verification Points:**
|
||
|
||
- ✅ **Bid Creation**: User can successfully bid on marketplace listings
|
||
- ✅ **Job Confirmation**: Provider can confirm bids and create jobs
|
||
- ✅ **Task Processing**: AI tasks execute through Ollama integration
|
||
- ✅ **Payment Processing**: Blockchain transactions process payments correctly
|
||
- ✅ **Balance Updates**: Wallet balances reflect payment transfers
|
||
- ✅ **Marketplace State**: Listings and jobs maintain correct status
|
||
|
||
#### **Troubleshooting:**
|
||
|
||
```bash
|
||
# Check marketplace status
|
||
curl -s http://localhost:8006/rpc/market-list | jq .
|
||
|
||
# Check specific job status
|
||
curl -s "http://localhost:8006/rpc/market-status?job_id=<JOB_ID>"
|
||
|
||
# Check AI task status
|
||
ssh aitbc "curl -s http://localhost:8006/rpc/ai-status?task_id=<TASK_ID>"
|
||
|
||
# Verify payment transaction
|
||
curl -s "http://localhost:8006/rpc/tx/<TRANSACTION_HASH>"
|
||
```
|
||
- ✅ Reliability and backup procedures
|
||
- ✅ Operations readiness
|
||
- ✅ Network connectivity
|
||
- ✅ Wallet and transaction functionality
|
||
|
||
### 🔄 Continuous Improvement
|
||
|
||
#### **Automated Maintenance**
|
||
```bash
|
||
# Setup comprehensive maintenance automation
|
||
/opt/aitbc/scripts/workflow/21_maintenance_automation.sh
|
||
|
||
# Schedule weekly maintenance
|
||
(crontab -l 2>/dev/null; echo "0 2 * * 0 /opt/aitbc/scripts/workflow/21_maintenance_automation.sh") | crontab -
|
||
```
|
||
|
||
#### **Performance Optimization**
|
||
```bash
|
||
# Run performance tuning and optimization
|
||
/opt/aitbc/scripts/workflow/20_performance_tuning.sh
|
||
|
||
# Monitor performance baseline
|
||
cat /opt/aitbc/performance/baseline.txt
|
||
```
|
||
|
||
---
|
||
|
||
## 🎯 Next Steps
|
||
|
||
### **Immediate Actions (0-1 week)**
|
||
|
||
1. **🚀 Production Deployment**
|
||
```bash
|
||
# Deploy complete multi-node blockchain setup for production
|
||
/opt/aitbc/scripts/workflow/26_production_deployment.sh
|
||
```
|
||
|
||
2. **🧪 Comprehensive Testing**
|
||
```bash
|
||
# Run comprehensive test suite covering all functionality
|
||
/opt/aitbc/scripts/workflow/25_comprehensive_testing.sh
|
||
```
|
||
|
||
3. **<2A> Operations Automation**
|
||
```bash
|
||
# Setup automated operations and monitoring
|
||
/opt/aitbc/scripts/workflow/27_operations_automation.sh
|
||
|
||
# Schedule automated operations (daily at 2 AM)
|
||
(crontab -l 2>/dev/null; echo "0 2 * * * /opt/aitbc/scripts/workflow/27_operations_automation.sh full") | crontab -
|
||
```
|
||
|
||
4. **🛒 Production Marketplace Testing with Real AI Integration**
|
||
```bash
|
||
# Test marketplace functionality with real AI service integration
|
||
/opt/aitbc/scripts/workflow/30_production_marketplace_fixed.sh
|
||
|
||
# View real AI integration results
|
||
cat /opt/aitbc/final_production_ai_results.txt
|
||
|
||
# Check AI service stats
|
||
ssh aitbc 'curl -s http://localhost:8006/rpc/ai/stats | jq .'
|
||
```
|
||
|
||
5. **<2A> Basic Monitoring Setup**
|
||
```bash
|
||
# Setup basic monitoring without Grafana/Prometheus
|
||
/opt/aitbc/scripts/workflow/22_advanced_monitoring.sh
|
||
|
||
# Start metrics API: python3 /opt/aitbc/monitoring/metrics_api.py
|
||
# Dashboard: http://<node-ip>:8080
|
||
```
|
||
|
||
### **Short-term Goals (1-4 weeks)**
|
||
|
||
6. **<2A> Maintenance Automation**
|
||
```bash
|
||
# Setup comprehensive maintenance automation
|
||
/opt/aitbc/scripts/workflow/21_maintenance_automation.sh
|
||
|
||
# Configure automated backups and monitoring
|
||
# Already configured in maintenance script
|
||
```
|
||
|
||
7. **📈 Performance Optimization**
|
||
```bash
|
||
# Note: Performance tuning script is disabled
|
||
# Manual optimization may be performed if needed
|
||
# /opt/aitbc/scripts/workflow/20_performance_tuning.sh (DISABLED)
|
||
```
|
||
|
||
8. **🛒 Advanced Marketplace Testing with AI Tracking**
|
||
```bash
|
||
# Test marketplace scenarios with AI prompt and response tracking
|
||
/opt/aitbc/scripts/workflow/28_marketplace_scenario_with_ai.sh
|
||
|
||
# Monitor GPU utilization during AI tasks
|
||
ssh aitbc 'watch -n 2 nvidia-smi'
|
||
|
||
# View AI prompt and response history
|
||
ls -la /opt/aitbc/marketplace_results_*.txt
|
||
```
|
||
|
||
9. **🌐 Cross-Node Optimization**
|
||
```bash
|
||
# Optimize cross-node synchronization
|
||
/opt/aitbc/scripts/fast_bulk_sync.sh
|
||
|
||
# Test load balancer functionality
|
||
curl http://localhost/nginx_status
|
||
```
|
||
|
||
### **Medium-term Goals (1-3 months)**
|
||
|
||
10. **🔄 Advanced Operations**
|
||
```bash
|
||
# Run comprehensive operations automation
|
||
/opt/aitbc/scripts/workflow/27_operations_automation.sh full
|
||
|
||
# Generate daily operations reports
|
||
/opt/aitbc/scripts/workflow/27_operations_automation.sh report
|
||
```
|
||
|
||
11. **📊 Enhanced Monitoring**
|
||
```bash
|
||
# Basic monitoring already deployed
|
||
/opt/aitbc/scripts/workflow/22_advanced_monitoring.sh
|
||
|
||
# Monitor health status
|
||
/opt/aitbc/monitoring/health_monitor.sh
|
||
|
||
# View operations logs
|
||
tail -f /var/log/aitbc/operations.log
|
||
```
|
||
|
||
12. **🚀 Scaling Preparation**
|
||
```bash
|
||
# Prepare for horizontal scaling and load balancing
|
||
/opt/aitbc/scripts/workflow/23_scaling_preparation.sh
|
||
|
||
# Test nginx load balancer functionality
|
||
curl http://localhost/nginx_status
|
||
```
|
||
|
||
13. **🛒 Marketplace Expansion**
|
||
```bash
|
||
# Run real hardware marketplace scenarios
|
||
/opt/aitbc/scripts/workflow/24_marketplace_scenario_real.sh
|
||
|
||
# Monitor marketplace activity
|
||
ssh aitbc 'curl -s http://localhost:8006/rpc/marketplace/listings | jq .'
|
||
```
|
||
|
||
### **Long-term Goals (3+ months)**
|
||
|
||
14. **🌐 Multi-Region Deployment**
|
||
- Geographic distribution
|
||
- Cross-region synchronization
|
||
- Disaster recovery setup
|
||
|
||
15. **🤖 AI/ML Integration**
|
||
- Advanced AI services
|
||
- Machine learning pipelines
|
||
- Intelligent monitoring
|
||
|
||
16. **🏢 Enterprise Features**
|
||
- Multi-tenancy support
|
||
- Advanced access control
|
||
- Compliance frameworks
|
||
|
||
---
|
||
|
||
## 📋 Workflow Optimization Summary
|
||
|
||
### **✅ New Scripts Created:**
|
||
|
||
1. **25_comprehensive_testing.sh** - Complete test suite covering all blockchain functionality
|
||
2. **26_production_deployment.sh** - Full production deployment with backup and verification
|
||
3. **27_operations_automation.sh** - Automated operations, monitoring, and maintenance
|
||
|
||
### **✅ Script References Updated:**
|
||
|
||
- **Removed redundant inline snippets** and replaced with script references
|
||
- **Optimized workflow flow** with logical progression
|
||
- **Real hardware integration** for marketplace scenarios
|
||
- **Comprehensive testing** and deployment automation
|
||
|
||
### **✅ Removed Redundancy:**
|
||
|
||
- **Inline bash snippets** replaced with proper script references
|
||
- **Duplicate functionality** consolidated into dedicated scripts
|
||
- **Performance tuning** marked as disabled to prevent system modifications
|
||
- **Grafana/Prometheus** references removed, replaced with basic monitoring
|
||
|
||
### **🎯 Optimized Workflow Benefits:**
|
||
|
||
- **Better organization** with clear script numbering and functionality
|
||
- **Production-ready automation** with comprehensive error handling
|
||
- **Real hardware testing** using actual GPU specifications
|
||
- **Complete deployment pipeline** from setup to operations
|
||
- **Automated maintenance** and monitoring capabilities
|
||
|
||
---
|
||
|
||
## 🚀 Next Steps Execution
|
||
|
||
### **Immediate Actions (Execute Now):**
|
||
|
||
```bash
|
||
# 1. Deploy to production
|
||
/opt/aitbc/scripts/workflow/26_production_deployment.sh
|
||
|
||
# 2. Run comprehensive testing
|
||
/opt/aitbc/scripts/workflow/25_comprehensive_testing.sh
|
||
|
||
# 3. Setup operations automation
|
||
/opt/aitbc/scripts/workflow/27_operations_automation.sh
|
||
|
||
# 4. Test marketplace with real hardware
|
||
/opt/aitbc/scripts/workflow/24_marketplace_scenario_real.sh
|
||
```
|
||
|
||
### **🎯 Workflow Status: OPTIMIZED & READY**
|
||
|
||
The multi-node blockchain setup workflow has been successfully optimized with professional automation scripts, comprehensive testing, and production-ready deployment procedures.
|
||
✅ **Comprehensive Monitoring** and health checking systems
|
||
✅ **Security Hardening** and access controls
|
||
✅ **Scalability** preparation for horizontal expansion
|
||
✅ **Documentation** and training materials
|
||
✅ **Automation** scripts for maintenance and operations
|
||
|
||
The system is ready for production use and can be extended with additional nodes, services, and features as needed.
|
||
|
||
**🚀 Start with the Immediate Actions above and work through the Next Steps systematically to ensure a successful production deployment!**
|