chore: remove obsolete files and add Solidity build artifacts to .gitignore

- Add ignore patterns for Solidity build artifacts (typechain-types, artifacts, cache)
- Remove unused exchange mock API server (api/exchange_mock_api.py)
- Remove obsolete client-web README placeholder
- Remove deprecated marketplace-ui HTML implementation
```
This commit is contained in:
oib
2026-01-24 15:46:23 +01:00
parent 9b9c5beb23
commit 55ced77928
195 changed files with 951 additions and 30090 deletions

View File

@@ -0,0 +1,477 @@
# Partner Integration Guide
This guide helps third-party services integrate with the AITBC platform for explorers, analytics, and other services.
## Overview
AITBC provides multiple integration points for partners:
- REST APIs for real-time data
- WebSocket streams for live updates
- Export endpoints for bulk data
- Webhook notifications for events
## Getting Started
### 1. Register Your Application
Register your service to get API credentials:
```bash
curl -X POST https://aitbc.bubuit.net/api/v1/partners/register \
-H "Content-Type: application/json" \
-d '{
"name": "Your Service Name",
"description": "Brief description of your service",
"website": "https://yourservice.com",
"contact": "contact@yourservice.com",
"integration_type": "explorer"
}'
```
**Response:**
```json
{
"partner_id": "partner-uuid",
"api_key": "aitbc_xxxxxxxxxxxx",
"api_secret": "secret_xxxxxxxxxxxx",
"rate_limit": {
"requests_per_minute": 1000,
"requests_per_hour": 50000
}
}
```
### 2. Authenticate Requests
Use your API credentials for authenticated requests:
```bash
curl -H "Authorization: Bearer aitbc_xxxxxxxxxxxx" \
https://aitbc.bubuit.net/api/explorer/blocks
```
## API Endpoints
### Blockchain Data
#### Get Latest Blocks
```http
GET /api/explorer/blocks?limit={limit}&offset={offset}
```
**Response:**
```json
{
"blocks": [
{
"hash": "0x123...",
"height": 1000000,
"timestamp": "2025-12-28T18:00:00Z",
"proposer": "0xabc...",
"transaction_count": 150,
"gas_used": "15000000",
"size": 1024000
}
],
"total": 1000000
}
```
#### Get Block Details
```http
GET /api/explorer/blocks/{block_hash}
```
#### Get Transaction
```http
GET /api/explorer/transactions/{tx_hash}
```
#### Get Address Details
```http
GET /api/explorer/addresses/{address}?transactions={true|false}
```
### Marketplace Data
#### Get Active Offers
```http
GET /api/v1/marketplace/offers?status=active&limit={limit}
```
#### Get Bid History
```http
GET /api/v1/marketplace/bids?offer_id={offer_id}
```
#### Get Service Categories
```http
GET /api/v1/marketplace/services/categories
```
### Analytics Data
#### Get Network Stats
```http
GET /api/v1/analytics/network/stats
```
**Response:**
```json
{
"total_blocks": 1000000,
"total_transactions": 50000000,
"active_addresses": 10000,
"network_hashrate": 1500000000000,
"average_block_time": 5.2,
"marketplace_volume": {
"24h": "1500000",
"7d": "10000000",
"30d": "40000000"
}
}
```
#### Get Historical Data
```http
GET /api/v1/analytics/historical?metric={metric}&period={period}&start={timestamp}&end={timestamp}
```
**Metrics:**
- `block_count`
- `transaction_count`
- `active_addresses`
- `marketplace_volume`
- `gas_price`
**Periods:**
- `1h`, `1d`, `1w`, `1m`
## WebSocket Streams
Connect to the WebSocket for real-time updates:
```javascript
const ws = new WebSocket('wss://aitbc.bubuit.net/ws');
// Authenticate
ws.send(JSON.stringify({
type: 'auth',
api_key: 'aitbc_xxxxxxxxxxxx'
}));
// Subscribe to blocks
ws.send(JSON.stringify({
type: 'subscribe',
channel: 'blocks'
}));
// Subscribe to transactions
ws.send(JSON.stringify({
type: 'subscribe',
channel: 'transactions',
filters: {
to_address: '0xabc...'
}
}));
// Handle messages
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log(data);
};
```
### Available Channels
- `blocks` - New blocks
- `transactions` - New transactions
- `marketplace_offers` - New marketplace offers
- `marketplace_bids` - New bids
- `governance` - Governance proposals and votes
## Bulk Data Export
### Export Blocks
```http
POST /api/v1/export/blocks
```
**Request:**
```json
{
"start_block": 900000,
"end_block": 1000000,
"format": "json",
"compression": "gzip"
}
```
**Response:**
```json
{
"export_id": "export-uuid",
"estimated_size": "500MB",
"download_url": "https://aitbc.bubuit.net/api/v1/export/download/export-uuid"
}
```
### Export Transactions
```http
POST /api/v1/export/transactions
```
## Webhooks
Configure webhooks to receive event notifications:
```bash
curl -X POST https://aitbc.bubuit.net/api/v1/webhooks \
-H "Authorization: Bearer aitbc_xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"url": "https://yourservice.com/webhook",
"events": ["block.created", "transaction.confirmed"],
"secret": "your_webhook_secret"
}'
```
**Webhook Payload:**
```json
{
"event": "block.created",
"timestamp": "2025-12-28T18:00:00Z",
"data": {
"block": {
"hash": "0x123...",
"height": 1000000,
"proposer": "0xabc..."
}
},
"signature": "sha256_signature"
}
```
Verify webhook signatures:
```javascript
const crypto = require('crypto');
function verifyWebhook(payload, signature, secret) {
const expected = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expected)
);
}
```
## Rate Limits
API requests are rate-limited based on your partner tier:
| Tier | Requests/Minute | Requests/Hour | Features |
|------|----------------|--------------|----------|
| Basic | 100 | 5,000 | Public data |
| Pro | 1,000 | 50,000 | + WebSocket |
| Enterprise | 10,000 | 500,000 | + Bulk export |
Rate limit headers are included in responses:
```
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1640692800
```
## SDKs and Libraries
### Python SDK
```python
from aitbc_sdk import AITBCClient
client = AITBCClient(
api_key="aitbc_xxxxxxxxxxxx",
base_url="https://aitbc.bubuit.net/api/v1"
)
# Get latest block
block = client.blocks.get_latest()
print(f"Latest block: {block.height}")
# Stream transactions
for tx in client.stream.transactions():
print(f"New tx: {tx.hash}")
```
### JavaScript SDK
```javascript
import { AITBCClient } from 'aitbc-sdk-js';
const client = new AITBCClient({
apiKey: 'aitbc_xxxxxxxxxxxx',
baseUrl: 'https://aitbc.bubuit.net/api/v1'
});
// Get network stats
const stats = await client.analytics.getNetworkStats();
console.log('Network stats:', stats);
// Subscribe to blocks
client.subscribe('blocks', (block) => {
console.log('New block:', block);
});
```
## Explorer Integration Guide
### Display Blocks
```html
<div class="block-list">
{% for block in blocks %}
<div class="block-item">
<a href="/block/{{ block.hash }}">
Block #{{ block.height }}
</a>
<span class="timestamp">{{ block.timestamp }}</span>
<span class="proposer">{{ block.proposer }}</span>
</div>
{% endfor %}
</div>
```
### Transaction Details
```javascript
async function showTransaction(txHash) {
const tx = await client.transactions.get(txHash);
document.getElementById('tx-hash').textContent = tx.hash;
document.getElementById('tx-status').textContent = tx.status;
document.getElementById('tx-from').textContent = tx.from_address;
document.getElementById('tx-to').textContent = tx.to_address;
document.getElementById('tx-amount').textContent = tx.amount;
document.getElementById('tx-gas').textContent = tx.gas_used;
// Show events
const events = await client.transactions.getEvents(txHash);
renderEvents(events);
}
```
### Address Activity
```javascript
async function loadAddress(address) {
const [balance, transactions, tokens] = await Promise.all([
client.addresses.getBalance(address),
client.addresses.getTransactions(address),
client.addresses.getTokens(address)
]);
updateBalance(balance);
renderTransactions(transactions);
renderTokens(tokens);
}
```
## Analytics Integration
### Custom Dashboards
```python
import plotly.graph_objects as go
from aitbc_sdk import AITBCClient
client = AITBCClient(api_key="your_key")
# Get historical data
data = client.analytics.get_historical(
metric='transaction_count',
period='1d',
start='2025-01-01',
end='2025-12-28'
)
# Create chart
fig = go.Figure()
fig.add_trace(go.Scatter(
x=data.timestamps,
y=data.values,
mode='lines',
name='Transactions per Day'
))
fig.show()
```
### Real-time Monitoring
```javascript
const client = new AITBCClient({ apiKey: 'your_key' });
// Monitor network health
client.subscribe('blocks', (block) => {
const blockTime = calculateBlockTime(block);
updateBlockTimeMetric(blockTime);
if (blockTime > 10) {
alert('Block time is high!');
}
});
// Monitor marketplace activity
client.subscribe('marketplace_bids', (bid) => {
updateBidChart(bid);
checkForAnomalies(bid);
});
```
## Best Practices
1. **Caching**: Cache frequently accessed data
2. **Pagination**: Use pagination for large datasets
3. **Error Handling**: Implement proper error handling
4. **Rate Limiting**: Respect rate limits and implement backoff
5. **Security**: Keep API keys secure and use HTTPS
6. **Webhooks**: Verify webhook signatures
7. **Monitoring**: Monitor your API usage and performance
## Support
For integration support:
- Documentation: https://aitbc.bubuit.net/docs/
- API Reference: https://aitbc.bubuit.net/api/v1/docs
- Email: partners@aitbc.io
- Discord: https://discord.gg/aitbc
## Example Implementations
### Block Explorer
- GitHub: https://github.com/aitbc/explorer-example
- Demo: https://explorer.aitbc-example.com
### Analytics Platform
- GitHub: https://github.com/aitbc/analytics-example
- Demo: https://analytics.aitbc-example.com
### Mobile App
- GitHub: https://github.com/aitbc/mobile-example
- iOS: https://apps.apple.com/aitbc-wallet
- Android: https://play.google.com/aitbc-wallet
## Changelog
### v1.2.0 (2025-12-28)
- Added governance endpoints
- Improved WebSocket reliability
- New analytics metrics
### v1.1.0 (2025-12-15)
- Added bulk export API
- Webhook support
- Python SDK improvements
### v1.0.0 (2025-12-01)
- Initial release
- REST API v1
- WebSocket streams
- JavaScript SDK

View File

@@ -0,0 +1,128 @@
# Cascade Skills Framework
## Overview
The Cascade Skills Framework provides a powerful way to automate complex, multi-step workflows in the AITBC project. Skills bundle together scripts, templates, documentation, and procedures that Cascade can intelligently invoke to execute tasks consistently.
## Skills Directory Structure
```
.windsurf/skills/
├── deploy-production/ # Production deployment workflow
│ ├── SKILL.md # Skill definition and documentation
│ ├── pre-deploy-checks.sh # Pre-deployment validation script
│ ├── environment-template.env # Production environment template
│ ├── rollback-steps.md # Emergency rollback procedures
│ └── health-check.py # Post-deployment health verification
└── blockchain-operations/ # Blockchain node management
├── SKILL.md # Skill definition and documentation
├── node-health.sh # Node health monitoring script
├── tx-tracer.py # Transaction debugging tool
├── mining-optimize.sh # GPU mining optimization script
├── sync-monitor.py # Real-time sync monitoring
└── network-diag.py # Network diagnostics tool
```
## Using Skills
### Automatic Invocation
Skills are automatically invoked when Cascade detects relevant keywords or context:
- "deploy production" → triggers deploy-production skill
- "check node status" → triggers blockchain-operations skill
- "debug transaction" → triggers blockchain-operations skill
- "optimize mining" → triggers blockchain-operations skill
### Manual Invocation
You can manually invoke skills by mentioning them directly:
- "Use the deploy-production skill"
- "Run blockchain-operations skill"
## Creating New Skills
1. Create a new directory under `.windsurf/skills/<skill-name>/`
2. Add a `SKILL.md` file with YAML frontmatter:
```yaml
---
name: skill-name
description: Brief description of the skill
version: 1.0.0
author: Cascade
tags: [tag1, tag2, tag3]
---
```
3. Add supporting files (scripts, templates, documentation)
4. Test the skill functionality
5. Commit to repository
## Skill Components
### Required
- **SKILL.md** - Main skill definition with frontmatter
### Optional (but recommended)
- Shell scripts for automation
- Python scripts for complex operations
- Configuration templates
- Documentation files
- Test scripts
## Best Practices
1. **Keep skills focused** on a specific domain or workflow
2. **Include comprehensive documentation** in SKILL.md
3. **Add error handling** to all scripts
4. **Use logging** for debugging and audit trails
5. **Include rollback procedures** for destructive operations
6. **Test thoroughly** before deploying
7. **Version your skills** using semantic versioning
## Example Skill: Deploy-Production
The deploy-production skill demonstrates best practices:
- Comprehensive pre-deployment checks
- Environment configuration template
- Detailed rollback procedures
- Post-deployment health verification
- Clear documentation and usage examples
## Integration with AITBC
Skills integrate seamlessly with AITBC components:
- Coordinator API interactions
- Blockchain node management
- Mining operations
- Exchange and marketplace functions
- Wallet daemon operations
## Recent Success Stories
### Ollama GPU Inference Testing (2026-01-24)
Using the blockchain-operations skill with Ollama testing enhancements:
- Executed end-to-end GPU inference workflow testing
- Fixed coordinator API bug (missing _coerce_float function)
- Verified complete job lifecycle from submission to receipt generation
- Documented comprehensive testing scenarios and automation scripts
- Achieved successful job completion with proper payment calculations
### Service Maintenance (2026-01-21)
Using the blockchain-operations skill framework:
- Successfully diagnosed and fixed all failing AITBC services
- Resolved duplicate service conflicts
- Implemented SSH access for automated management
- Restored full functionality to 7 core services
### Production Deployment (2025-01-19)
Using the deploy-production skill:
- Automated deployment validation
- Environment configuration management
- Health check automation
- Rollback procedure documentation
## Future Enhancements
- Skill marketplace for sharing community skills
- Skill dependencies and composition
- Skill versioning and updates
- Skill testing framework
- Skill analytics and usage tracking

View File

@@ -0,0 +1,633 @@
# AITBC Testing Scenario: Customer-Service Provider Interaction
## Overview
This document outlines a comprehensive testing scenario for customers and service providers interacting on the AITBC platform. This scenario enables end-to-end testing of the complete marketplace workflow using the publicly accessible deployment at https://aitbc.bubuit.net/.
## Prerequisites
### System Requirements
- Modern web browser (Chrome, Firefox, Safari, or Edge)
- Internet connection to access https://aitbc.bubuit.net/
- Terminal/command line access (for API testing)
- Python 3.11+ and virtual environment (for local testing)
- Ollama installed and running (for GPU miner testing)
- systemd (for running miner as service)
### Local Development Setup
For localhost testing, ensure you have:
- AITBC repository cloned to `/home/oib/windsurf/aitbc`
- Virtual environment created: `python3 -m venv .venv`
- Dependencies installed: `source .venv/bin/python -m pip install -e .`
- Bash CLI wrapper: `/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh`
### Services Running
Ensure all AITBC services are accessible via:
- Coordinator API (http://127.0.0.1:18000/)
- Blockchain Node (http://127.0.0.1:19000/)
- Wallet Daemon (http://127.0.0.1:20000/)
- Marketplace UI (http://127.0.0.1:21000/)
- Explorer Web (http://127.0.0.1:22000/)
- Trade Exchange (http://127.0.0.1:23000/)
- Miner Dashboard (http://127.0.0.1:24000/)
## Scenario: GPU Computing Service Marketplace
### Actors
1. **Customer** - Wants to purchase GPU computing power
2. **Service Provider** - Offers GPU computing services
3. **Platform** - AITBC marketplace facilitating the transaction
## Testing Workflow
### Phase 1: Service Provider Setup
#### 1.1 Register as a Service Provider
```bash
# Navigate to marketplace
http://127.0.0.1:21000/
# Click "Become a Provider"
# Fill in provider details:
- Provider Name: "GPUCompute Pro"
- Service Type: "GPU Computing"
- Description: "High-performance GPU computing for AI/ML workloads"
- Pricing Model: "Per Hour"
- Rate: "100 AITBC tokens/hour"
```
#### 1.2 Configure Service Offering
```python
# Example service configuration
service_config = {
"service_id": "gpu-compute-001",
"name": "GPU Computing Service",
"type": "gpu_compute",
"specs": {
"gpu_type": "NVIDIA RTX 4090",
"memory": "24GB",
"cuda_cores": 16384,
"supported_frameworks": ["PyTorch", "TensorFlow", "JAX"]
},
"pricing": {
"rate_per_hour": 100,
"currency": "AITBC"
},
"availability": {
"start_time": "2024-01-01T00:00:00Z",
"end_time": "2024-12-31T23:59:59Z",
"timezone": "UTC"
}
}
```
#### 1.3 Register Service with Coordinator
```bash
# Using bash CLI wrapper
/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh admin-miners
# Or POST to coordinator API directly
curl -X POST http://127.0.0.1:18000/v1/services/register \
-H "Content-Type: application/json" \
-H "X-API-Key: provider-api-key" \
-d @service_config.json
```
### Phase 2: Customer Discovery and Selection
#### 2.1 Browse Available Services
```bash
# Customer navigates to marketplace
http://127.0.0.1:21000/
# Or use CLI to check coordinator status
/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh health
# Filter by:
- Service Category: "GPU Computing"
- Price Range: "50-200 AITBC/hour"
- Availability: "Available Now"
```
#### 2.2 View Service Details
```bash
# Using bash CLI wrapper
/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh browser --receipt-limit 5
# Or GET service details via API
service_id="gpu-compute-001"
curl -X GET "http://127.0.0.1:18000/v1/services/${service_id}" \
-H "X-API-Key: customer-api-key"
```
#### 2.3 Verify Provider Reputation
```bash
# Check provider ratings and reviews
curl -X GET http://127.0.0.1:18000/v1/providers/gpu-compute-pro/reputation
# View transaction history
/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh receipts --limit 10
```
### Phase 3: Service Purchase and Execution
#### 3.1 Purchase Service Credits
```bash
# Navigate to Trade Exchange
http://127.0.0.1:23000/
# Purchase AITBC tokens:
- Amount: 1000 AITBC
- Payment Method: Bitcoin (testnet)
- Exchange Rate: 1 BTC = 100,000 AITBC
# Or check balance via CLI
/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh admin-stats
```
#### 3.2 Create Service Job
```bash
# Using bash CLI wrapper (recommended)
/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh submit inference \
--prompt "Train a ResNet model on ImageNet" \
--model llama3.2:latest \
--ttl 900
# Example output:
# ✅ Job submitted successfully!
# Job ID: 707c75d0910e49e2965196bce0127ba1
# Track job status
/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh status 707c75d0910e49e2965196bce0127ba1
```
Or using Python/curl:
```python
# Create job request
job_request = {
"service_id": "gpu-compute-001",
"customer_id": "customer-123",
"requirements": {
"task_type": "model_training",
"framework": "PyTorch",
"dataset_size": "10GB",
"estimated_duration": "2 hours"
},
"budget": {
"max_cost": 250,
"currency": "AITBC"
}
}
# Submit job
response = requests.post(
"http://127.0.0.1:18000/v1/jobs/create",
json=job_request,
headers={"X-API-Key": "customer-api-key"}
)
job_id = response.json()["job_id"]
```
#### 3.3 Monitor Job Progress
```bash
# Using bash CLI wrapper
/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh status <job_id>
# Or real-time job monitoring via API
curl -X GET http://127.0.0.1:18000/v1/jobs/{job_id}/status
# WebSocket for live updates
ws://127.0.0.1:18000/v1/jobs/{job_id}/stream
# View blockchain transactions
/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh browser --block-limit 5
```
#### 3.4 Receive Results
```bash
# Using bash CLI wrapper to check receipts
/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh receipts --job-id <job_id>
# Or download completed job results via API
response=$(curl -s -X GET "http://127.0.0.1:18000/v1/jobs/{job_id}/results" \
-H "X-API-Key: customer-api-key")
echo "$response" | jq .
# Verify results with receipt
receipt=$(echo "$response" | jq -r .receipt)
# Verify receipt signature with customer public key
```
Or using Python:
```python
import requests
response = requests.get(
f"http://127.0.0.1:18000/v1/jobs/{job_id}/results",
headers={"X-API-Key": "customer-api-key"}
)
# Verify results with receipt
receipt = response.json()["receipt"]
verified = verify_job_receipt(receipt, customer_public_key)
```
### Phase 4: Payment and Settlement
#### 4.1 Automatic Payment Processing
```bash
# Payment automatically processed upon job completion
# Check transaction on blockchain
/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh browser --receipt-limit 1
# Or via RPC API
curl -X POST http://127.0.0.1:19000/api/v1/transaction/get \
-d '{"tx_hash": "0x..."}'
```
#### 4.2 Provider Receives Payment
```bash
# Provider checks wallet balance via CLI
/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh admin-stats
# Or via wallet daemon API
curl -X GET http://127.0.0.1:20000/api/v1/wallet/balance \
-H "X-API-Key: provider-api-key"
# Example output: {"balance": 100.0, "currency": "AITBC"}
```
Or using Python:
```python
# Provider checks wallet balance
balance = wallet_daemon.get_balance(provider_address)
print(f"Received payment: {balance} AITBC")
```
#### 4.3 Rate and Review
```bash
# Customer rates service via API
POST http://127.0.0.1:18000/v1/services/{service_id}/rate
{
"rating": 5,
"review": "Excellent service! Fast execution and great results.",
"customer_id": "customer-123"
}
# Or check provider stats
/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh admin-miners
```
## Testing Scripts
### Automated Test Runner
```python
#!/usr/bin/env python3
"""
AITBC Test Runner for Marketplace
Tests complete customer-provider workflow
"""
import asyncio
import requests
import time
from datetime import datetime
class AITBCTestTester:
def __init__(self):
self.base_url = "http://127.0.0.1"
self.coordinator_url = "http://127.0.0.1:18000"
self.marketplace_url = "http://127.0.0.1:21000"
self.exchange_url = "http://127.0.0.1:23000"
self.cli_path = "/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh"
async def run_full_scenario(self):
"""Run complete customer-provider test scenario"""
print("Starting AITBC Test Scenario...")
# Phase 1: Setup
await self.setup_test_environment()
# Phase 2: Provider Registration
provider_id = await self.register_provider()
# Phase 3: Service Registration
service_id = await self.register_service(provider_id)
# Phase 4: Customer Setup
customer_id = await self.setup_customer()
# Phase 5: Service Discovery
await self.test_service_discovery()
# Phase 6: Job Creation and Execution
job_id = await self.create_and_execute_job(service_id, customer_id)
# Phase 7: Payment and Settlement
await self.test_payment_flow(job_id)
# Phase 8: Review and Rating
await self.test_review_system(service_id, customer_id)
print("Test scenario completed successfully!")
async def setup_test_environment(self):
"""Setup test wallets and accounts"""
print("Setting up test environment...")
# Create test wallets for customer and provider
# Fund test accounts with AITBC tokens
async def register_provider(self):
"""Register a test service provider"""
print("Registering service provider...")
# Implementation here
async def register_service(self, provider_id):
"""Register a test service"""
print("Registering service...")
# Implementation here
async def setup_customer(self):
"""Setup test customer"""
print("Setting up customer...")
# Implementation here
async def test_service_discovery(self):
"""Test service discovery functionality"""
print("Testing service discovery...")
# Implementation here
async def create_and_execute_job(self, service_id, customer_id):
"""Create and execute a test job"""
print("Creating and executing job...")
# Implementation here
return "test-job-123"
async def test_payment_flow(self, job_id):
"""Test payment processing"""
print("Testing payment flow...")
# Implementation here
async def test_review_system(self, service_id, customer_id):
"""Test review and rating system"""
print("Testing review system...")
# Implementation here
if __name__ == "__main__":
tester = AITBCTestTester()
asyncio.run(tester.run_full_scenario())
```
### Manual Testing Checklist
#### Pre-Test Setup
- [ ] All services running and accessible
- [ ] Test wallets created with initial balance
- [ ] SSL certificates configured (if using HTTPS)
- [ ] Browser cache cleared
#### Provider Workflow
- [ ] Provider registration successful
- [ ] Service configuration accepted
- [ ] Service appears in marketplace listings
- [ ] Provider dashboard shows active services
#### Customer Workflow
- [ ] Customer can browse marketplace
- [ ] Service search and filters working
- [ ] Service details display correctly
- [ ] Job submission successful
- [ ] Real-time progress updates working
- [ ] Results download successful
- [ ] Payment processed correctly
#### Post-Transaction
- [ ] Provider receives payment
- [ ] Transaction visible on explorer
- [ ] Review system working
- [ ] Reputation scores updated
## Test Data and Mock Services
### Sample GPU Service Configurations
```json
{
"services": [
{
"id": "gpu-ml-training",
"name": "ML Model Training",
"type": "gpu_compute",
"specs": {
"gpu": "RTX 4090",
"memory": "24GB",
"software": ["PyTorch 2.0", "TensorFlow 2.13"]
},
"pricing": {"rate": 100, "unit": "hour", "currency": "AITBC"}
},
{
"id": "gpu-rendering",
"name": "3D Rendering Service",
"type": "gpu_compute",
"specs": {
"gpu": "RTX 4090",
"memory": "24GB",
"software": ["Blender", "Maya", "3ds Max"]
},
"pricing": {"rate": 80, "unit": "hour", "currency": "AITBC"}
}
]
}
```
### Mock Job Templates
```python
# Machine Learning Training Job
ml_job = {
"type": "ml_training",
"parameters": {
"model": "resnet50",
"dataset": "imagenet",
"epochs": 10,
"batch_size": 32
},
"expected_duration": "2 hours",
"estimated_cost": 200
}
# 3D Rendering Job
render_job = {
"type": "3d_render",
"parameters": {
"scene": "architectural_visualization",
"resolution": "4K",
"samples": 256,
"engine": "cycles"
},
"expected_duration": "3 hours",
"estimated_cost": 240
}
```
## Monitoring and Debugging
### Log Locations
```bash
# Service logs (localhost)
sudo journalctl -u coordinator-api.service -f
sudo journalctl -u aitbc-blockchain.service -f
sudo journalctl -u wallet-daemon.service -f
sudo journalctl -u aitbc-host-gpu-miner.service -f
# Application logs
tail -f /var/log/aitbc/marketplace.log
tail -f /var/log/aitbc/exchange.log
# Virtual environment logs
cd /home/oib/windsurf/aitbc
source .venv/bin/activate
```
### Debug Tools
```bash
# Check service health
/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh health
curl http://127.0.0.1:18000/v1/health
curl http://127.0.0.1:19000/api/v1/health
# Monitor blockchain
curl http://127.0.0.1:19000/api/v1/block/latest
# Check active jobs
/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh admin-jobs
# Verify transactions
/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh browser --tx-limit 5
# Run GPU miner manually for debugging
cd /home/oib/windsurf/aitbc
source .venv/bin/activate
python3 gpu_miner_host.py
# Or as systemd service
sudo systemctl restart aitbc-host-gpu-miner.service
sudo journalctl -u aitbc-host-gpu-miner.service -f
```
## Common Issues and Solutions
### Service Not Accessible
- Check if service is running: `sudo systemctl status [service-name]`
- Verify port is not blocked: `netstat -tlnp | grep [port]`
- Check nginx configuration: `sudo nginx -t`
- For localhost: ensure services are running in Incus container
- Check coordinator API: `/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh health`
### Transaction Failed
- Verify wallet balance: `curl http://127.0.0.1:20000/api/v1/wallet/balance`
- Check gas settings: Ensure sufficient gas for transaction
- Verify network sync: `curl http://127.0.0.1:19000/api/v1/sync/status`
### Job Not Starting
- Check service availability: `curl http://127.0.0.1:18000/v1/services/{id}`
- Verify customer balance: Check wallet has sufficient tokens
- Review job requirements: Ensure they match service capabilities
- Check if miner is running: `sudo systemctl status aitbc-host-gpu-miner.service`
- View miner logs: `sudo journalctl -u aitbc-host-gpu-miner.service -n 50`
- Submit test job: `/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh submit inference --prompt "test" --model llama3.2:latest`
## Performance Testing
### Load Testing Script
```python
"""
Simulate multiple customers and providers
"""
import asyncio
import aiohttp
async def simulate_load(num_customers=10, num_providers=5):
"""Simulate marketplace load"""
async with aiohttp.ClientSession() as session:
# Create providers
providers = []
for i in range(num_providers):
provider = await create_provider(session, f"provider-{i}")
providers.append(provider)
# Create customers and jobs
jobs = []
for i in range(num_customers):
customer = await create_customer(session, f"customer-{i}")
job = await create_job(session, customer, random.choice(providers))
jobs.append(job)
# Monitor execution
await monitor_jobs(session, jobs)
```
## Security Considerations for Testing
### Test Network Isolation
- Use testnet blockchain, not mainnet
- Isolate test wallets from production funds
- Use test API keys, not production keys
### Data Privacy
- Sanitize PII from test data
- Use synthetic data for testing
- Clear test data after completion
## Next Steps
1. **Production Readiness**
- Security audit of test scenarios
- Performance benchmarking
- Documentation review
2. **Expansion**
- Add more service types
- Implement advanced matching algorithms
- Add dispute resolution workflow
3. **Automation**
- CI/CD integration for test scenarios
- Automated regression testing
- Performance monitoring alerts
## Conclusion
This localhost testing scenario provides a comprehensive environment for validating the complete AITBC marketplace workflow. It enables developers and testers to verify all aspects of the customer-provider interaction in a controlled setting before deploying to production.
## Quick Start Commands
```bash
# 1. Setup environment
cd /home/oib/windsurf/aitbc
source .venv/bin/activate
# 2. Check all services
./scripts/aitbc-cli.sh health
# 3. Start GPU miner
sudo systemctl restart aitbc-host-gpu-miner.service
sudo journalctl -u aitbc-host-gpu-miner.service -f
# 4. Submit test job
./scripts/aitbc-cli.sh submit inference --prompt "Hello AITBC" --model llama3.2:latest
# 5. Monitor progress
./scripts/aitbc-cli.sh status <job_id>
./scripts/aitbc-cli.sh browser --receipt-limit 5
```
## Host User Paths
- Repository: `/home/oib/windsurf/aitbc`
- Virtual Environment: `/home/oib/windsurf/aitbc/.venv`
- CLI Wrapper: `/home/oib/windsurf/aitbc/scripts/aitbc-cli.sh`
- GPU Miner Script: `/home/oib/windsurf/aitbc/scripts/gpu/gpu_miner_host.py`
- Systemd Unit: `/etc/systemd/system/aitbc-host-gpu-miner.service`
- Client Scripts: `/home/oib/windsurf/aitbc/home/client/`
- Test Scripts: `/home/oib/windsurf/aitbc/home/`