chore: standardize configuration, logging, and error handling across blockchain node and coordinator API

- Add infrastructure.md and workflow files to .gitignore to prevent sensitive info leaks
- Change blockchain node mempool backend default from memory to database for persistence
- Refactor blockchain node logger with StructuredLogFormatter and AuditLogger (consistent with coordinator)
- Add structured logging fields: service, module, function, line number
- Unify coordinator config with Database
This commit is contained in:
oib
2026-02-13 22:39:43 +01:00
parent 0cbd2b507c
commit 06e48ef34b
196 changed files with 4660 additions and 20090 deletions

20
docs/3_miners/0_readme.md Normal file
View File

@@ -0,0 +1,20 @@
# Miner Documentation
Provide GPU resources to the AITBC network and earn tokens.
## Reading Order
| # | File | What you learn |
|---|------|----------------|
| 1 | [1_quick-start.md](./1_quick-start.md) | Get mining in 5 minutes |
| 2 | [2_registration.md](./2_registration.md) | Register GPU with the network |
| 3 | [3_job-management.md](./3_job-management.md) | Accept and complete jobs |
| 4 | [4_earnings.md](./4_earnings.md) | Track and withdraw earnings |
| 5 | [5_gpu-setup.md](./5_gpu-setup.md) | GPU drivers, CUDA, optimization |
| 6 | [6_monitoring.md](./6_monitoring.md) | Dashboards, alerts, health checks |
| 7 | [7_api-miner.md](./7_api-miner.md) | REST API endpoints for integration |
## Related
- [CLI Guide](../0_getting_started/3_cli.md) — Command-line reference
- [Client Docs](../2_clients/0_readme.md) — If you also want to submit jobs

View File

@@ -0,0 +1,37 @@
# Miner Quick Start
**5 minutes** — Register your GPU and start earning AITBC tokens.
## Prerequisites
- NVIDIA GPU with 16GB+ VRAM (V100, A100, RTX 3090+)
- Python 3.10+, CUDA drivers installed
- 50GB+ storage, stable internet
## 1. Install & Configure
```bash
pip install -e . # from monorepo root
aitbc config set coordinator_url http://localhost:8000
export AITBC_API_KEY=your-key
```
## 2. Register & Start
```bash
aitbc miner register --name my-gpu --gpu v100 --count 1
aitbc miner poll # start accepting jobs
```
## 3. Verify
```bash
aitbc miner status # GPU status + earnings
aitbc wallet balance # check token balance
```
## Next
- [2_registration.md](./2_registration.md) — Advanced registration options
- [3_job-management.md](./3_job-management.md) — Job acceptance and completion
- [5_gpu-setup.md](./5_gpu-setup.md) — GPU driver and CUDA setup

View File

@@ -0,0 +1,80 @@
# Miner Registration
Register your miner with the AITBC network.
## Requirements
### Hardware Requirements
| Resource | Minimum | Recommended |
|----------|---------|-------------|
| GPU VRAM | 8GB | 16GB+ |
| RAM | 16GB | 32GB+ |
| Storage | 50GB | 100GB+ |
| Bandwidth | 10 Mbps | 100 Mbps |
### Supported GPUs
- NVIDIA V100 (16GB/32GB)
- NVIDIA A100 (40GB/80GB)
- NVIDIA RTX 3090 (24GB)
- NVIDIA RTX 4090 (24GB)
## Registration
### Basic Registration
```bash
aitbc miner register --name my-miner --gpu v100 --count 1
```
### Advanced Registration
```bash
aitbc miner register \
--name my-miner \
--gpu a100 \
--count 4 \
--location us-east \
--price 0.10 \
--max-concurrent 4
```
### Flags Reference
| Flag | Description |
|------|-------------|
| `--name` | Miner name |
| `--gpu` | GPU type (v100, a100, rtx3090, rtx4090) |
| `--count` | Number of GPUs |
| `--location` | Geographic location |
| `--price` | Price per GPU/hour in AITBC |
| `--max-concurrent` | Maximum concurrent jobs |
## Verification
```bash
aitbc miner status
```
Shows:
- Registration status
- GPU availability
- Current jobs
## Update Registration
```bash
aitbc miner update --price 0.12 --max-concurrent 8
```
## De-register
```bash
aitbc miner deregister --confirm
```
## Next
- [Job Management](./3_job-management.md) — Job management
- [Earnings](./4_earnings.md) — Earnings tracking
- [GPU Setup](./5_gpu-setup.md) — GPU configuration

View File

@@ -0,0 +1,96 @@
# Job Management
Accept and complete jobs on the AITBC network.
## Overview
Jobs are assigned to miners based on GPU availability, price, and reputation.
## Accept Jobs
### Manual Acceptance
```bash
aitbc miner jobs --available
aitbc miner accept --job-id <JOB_ID>
```
### Auto-Accept
```bash
aitbc miner auto-accept enable --max-concurrent 4
```
### Auto-Accept Settings
```bash
# Set GPU requirements
aitbc miner auto-accept --gpu v100 --gpu-count 1-4
# Set price range
aitbc miner auto-accept --min-price 0.08 --max-price 0.12
```
## Job States
| State | Description |
|-------|-------------|
| assigned | Job assigned, waiting to start |
| starting | Preparing environment |
| running | Executing job |
| uploading | Uploading results |
| completed | Job finished successfully |
| failed | Job error occurred |
## Monitor Jobs
### Check Status
```bash
aitbc miner job-status --job-id <JOB_ID>
```
### Watch Progress
```bash
aitbc miner watch --job-id <JOB_ID>
```
### List Active Jobs
```bash
aitbc miner jobs --active
```
## Complete Jobs
### Manual Completion
```bash
aitbc miner complete --job-id <JOB_ID>
```
### Upload Results
```bash
aitbc miner upload --job-id <JOB_ID> --path ./results
```
## Handle Failures
### Retry Job
```bash
aitbc miner retry --job-id <JOB_ID>
```
### Report Issue
```bash
aitbc miner report --job-id <JOB_ID> --reason "gpu-error"
```
## Next
- [Earnings](./4_earnings.md) — Earnings tracking
- [GPU Setup](./5_gpu-setup.md) — GPU configuration
- [Monitoring](./6_monitoring.md) - Monitor your miner

View File

@@ -0,0 +1,66 @@
# Earnings & Payouts
Track and manage your mining earnings.
## Earnings Overview
```bash
aitbc miner earnings
```
Shows:
- Total earned
- Pending balance
- Last payout
## Earnings Breakdown
| Source | Description |
|--------|-------------|
| job_completion | Payment for completed jobs |
| bonus | Performance bonuses |
| referral | Referral rewards |
## Payout Schedule
| Plan | Schedule | Minimum |
|------|----------|---------|
| Automatic | Daily | 10 AITBC |
| Manual | On request | 1 AITBC |
## Request Payout
```bash
aitbc wallet withdraw --amount 100 --address <WALLET_ADDRESS>
```
## Earnings History
```bash
aitbc miner earnings --history --days 30
```
## Performance Metrics
```bash
aitbc miner stats
```
Shows:
- Success rate
- Average completion time
- Total jobs completed
- Earnings per GPU/hour
## Tax Reporting
```bash
aitbc miner earnings --export --year 2026
```
Export for tax purposes.
## Next
- [Job Management](./3_job-management.md) — Job management
- [Monitoring](./6_monitoring.md) - Monitor your miner
- [GPU Setup](./5_gpu-setup.md) — GPU configuration

View File

@@ -0,0 +1,111 @@
# GPU Setup & Configuration
Configure and optimize your GPU setup for mining.
## Prerequisites
### Driver Installation
```bash
# Ubuntu/Debian
sudo apt install nvidia-driver-535
# Verify installation
nvidia-smi
```
### CUDA Installation
```bash
# Download CUDA from NVIDIA
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update
sudo apt-get install cuda-toolkit-12-3
```
## Configuration
### Miner Config
Create `~/.aitbc/miner.yaml`:
```yaml
gpu:
type: v100
count: 1
cuda_devices: 0
performance:
max_memory_percent: 90
max_gpu_temp: 80
power_limit: 250
jobs:
max_concurrent: 4
timeout_grace: 300
```
### Environment Variables
```bash
export CUDA_VISIBLE_DEVICES=0
export NVIDIA_VISIBLE_DEVICES=all
export AITBC_GPU_MEMORY_LIMIT=0.9
```
## Optimization
### Memory Settings
```yaml
performance:
tensor_cores: true
fp16: true # Use half precision
max_memory_percent: 90
```
### Thermal Management
```yaml
thermal:
target_temp: 70
max_temp: 85
fan_curve:
- temp: 50
fan: 30
- temp: 70
fan: 60
- temp: 85
fan: 100
```
## Troubleshooting
### GPU Not Detected
```bash
# Check driver
nvidia-smi
# Check CUDA
nvcc --version
# Restart miner
aitbc miner restart
```
### Temperature Issues
```bash
# Monitor temperature
nvidia-smi -l 1
# Check cooling
ipmitool sdr list | grep Temp
```
## Next
- [Quick Start](./1_quick-start.md) — Get started
- [Monitoring](./6_monitoring.md) - Monitor your miner
- [Job Management](./3_job-management.md) — Job management

View File

@@ -0,0 +1,110 @@
# Monitoring & Alerts
Monitor your miner performance and set up alerts.
## Real-time Monitoring
### Dashboard
```bash
aitbc miner dashboard
```
Shows:
- GPU utilization
- Memory usage
- Temperature
- Active jobs
- Earnings rate
### CLI Stats
```bash
aitbc miner stats
```
### Prometheus Metrics
```bash
# Enable metrics endpoint
aitbc miner metrics --port 9090
```
Available at: http://localhost:9090/metrics
## Alert Configuration
### Set Alerts
```bash
# GPU temperature alert
aitbc miner alert --metric temp --threshold 85 --action notify
# Memory usage alert
aitbc miner alert --metric memory --threshold 90 --action throttle
# Job failure alert
aitbc miner alert --metric failures --threshold 3 --action pause
```
### Alert Types
| Type | Description |
|------|-------------|
| temp | GPU temperature |
| memory | GPU memory usage |
| utilization | GPU utilization |
| jobs | Job success/failure rate |
| earnings | Earnings below threshold |
### Alert Actions
| Action | Description |
|--------|-------------|
| notify | Send notification |
| throttle | Reduce job acceptance |
| pause | Stop accepting jobs |
| restart | Restart miner |
## Log Management
### View Logs
```bash
# Recent logs
aitbc miner logs --tail 100
# Filter by level
aitbc miner logs --level error
# Filter by job
aitbc miner logs --job-id <JOB_ID>
```
### Log Rotation
```bash
# Configure log rotation
aitbc miner logs --rotate --max-size 100MB --keep 5
```
## Health Checks
```bash
# Run health check
aitbc miner health
# Detailed health report
aitbc miner health --detailed
```
Shows:
- GPU health
- Driver status
- Network connectivity
- Storage availability
## Next
- [Quick Start](./1_quick-start.md) — Get started
- [GPU Setup](./5_gpu-setup.md) — GPU configuration
- [Job Management](./3_job-management.md) — Job management

View File

@@ -0,0 +1,141 @@
# Miner API Reference
Complete API reference for miner operations.
## Endpoints
### Register Miner
```
POST /v1/miners
```
**Request Body:**
```json
{
"name": "my-miner",
"gpu_type": "v100",
"gpu_count": 1,
"location": "us-east",
"price_per_hour": 0.05,
"max_concurrent": 4
}
```
**Response:**
```json
{
"miner_id": "miner_xyz789",
"api_key": "key_abc123",
"status": "pending"
}
```
### Update Miner
```
PUT /v1/miners/{miner_id}
```
### Heartbeat
```
POST /v1/miners/{miner_id}/heartbeat
```
**Response:**
```json
{
"status": "ok",
"jobs_assigned": 0,
"queue_length": 5
}
```
### List Available Jobs
```
GET /v1/miners/{miner_id}/jobs/available
```
**Response:**
```json
{
"jobs": [
{
"job_id": "job_abc123",
"model": "gpt2",
"gpu_type": "v100",
"gpu_count": 1,
"estimated_time": 600,
"price": 0.05
}
]
}
```
### Accept Job
```
POST /v1/miners/{miner_id}/jobs/{job_id}/accept
```
### Complete Job
```
POST /v1/miners/{miner_id}/jobs/{job_id}/complete
```
**Request Body:**
```json
{
"result_hash": "sha256:abc123...",
"metrics": {
"execution_time_seconds": 600,
"gpu_time_seconds": 600
}
}
```
### Get Miner Stats
```
GET /v1/miners/{miner_id}/stats
```
**Response:**
```json
{
"total_jobs": 100,
"success_rate": 0.98,
"average_completion_time": 600,
"earnings": 50.5,
"earnings_per_gpu_hour": 0.05
}
```
## Error Codes
| Code | Description |
|------|-------------|
| 400 | Invalid request |
| 401 | Unauthorized |
| 404 | Miner/job not found |
| 409 | Job already assigned |
| 422 | Validation error |
## Rate Limits
- 60 requests/minute
- 10 job operations/minute
## Next
- [Quick Start](./1_quick-start.md) — Get started
- [Job Management](./3_job-management.md) — Job management
- [Monitoring](./6_monitoring.md) - Monitor your miner