This document provides a complete guide for running a validator on the Affine subnet (Subnet 120).
- Overview
- Prerequisites
- Environment Setup
- Running Methods
- CLI Reference
- Monitoring & Maintenance
- Troubleshooting
The main responsibilities of an Affine validator are:
- Fetch Weights: Get the latest normalized weights from the backend API
- Apply Burn Mechanism: Allocate a percentage of weights to UID 0 based on configuration
- Set On-Chain: Submit weights to the Bittensor blockchain
Validators no longer need to run evaluation or scoring logic directly. All complex computations are handled by backend services.
- Bittensor Wallet: Validator hotkey registered to Subnet 120
- API Access: Ability to access the Affine backend API
- Sufficient TAO: To pay for on-chain transaction fees
# Install uv package manager
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone and install Affine
git clone https://github.com/AffineFoundation/affine.git
cd affine
uv venv && source .venv/bin/activate && uv pip install -e .
# Verify installation
afCopy and edit the .env file:
cp .env.example .envEdit .env file with required variables:
# Bittensor wallet configuration (required)
BT_WALLET_COLD=your_coldkey_name
BT_WALLET_HOT=your_hotkey_name
# Subtensor configuration
SUBTENSOR_ENDPOINT=finney
SUBTENSOR_FALLBACK=wss://lite.sub.latent.to:443
# Validator configuration (optional)
NETUID=120 # Subnet ID| Variable | Description | Default | Required |
|---|---|---|---|
BT_WALLET_COLD |
Coldkey name | - | Yes |
BT_WALLET_HOT |
Hotkey name | - | Yes |
SUBTENSOR_ENDPOINT |
Subtensor node address | finney |
No |
SUBTENSOR_FALLBACK |
Fallback Subtensor address | - | No |
NETUID |
Subnet ID | 120 |
No |
Run the validator with Docker and Watchtower for automatic updates:
# Start validator (with auto-update)
docker-compose down && docker-compose pull && docker-compose up -d && docker-compose logs -fDocker Commands:
# Restart containers (handle OOM and other issues)
docker compose up -d --force-recreate
# View logs
docker compose logs -f
# Stop services
docker compose down
# Run with local build
docker compose -f docker-compose.yml -f docker-compose.local.yml down --remove-orphans
docker compose -f docker-compose.yml -f docker-compose.local.yml up -d --build --remove-orphans
docker compose -f docker-compose.yml -f docker-compose.local.yml logs -fExecute one weight setting and exit:
af servers validatorSet environment variable SERVICE_MODE=true and run:
# Set environment variable
export SERVICE_MODE=true
# Start validator service
af servers validatorOr specify directly on startup:
SERVICE_MODE=true af servers validator# Specify network and wallet
af servers validator --network finney --wallet-name mywallet --hotkey-name myhotkey --netuid 120
# Use verbose logging
af -vv servers validator
# Use TRACE level logging
af -vvv servers validatorCreate a systemd service file for auto-start and auto-restart:
# Create service file
sudo nano /etc/systemd/system/affine-validator.serviceService file content:
[Unit]
Description=Affine Validator Service
After=network.target
[Service]
Type=simple
User=your_username
WorkingDirectory=/path/to/affine
Environment="PATH=/path/to/affine/.venv/bin:/usr/bin"
Environment="SERVICE_MODE=true"
EnvironmentFile=/path/to/affine/.env
ExecStart=/path/to/affine/.venv/bin/af servers validator
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.targetEnable and start the service:
# Reload systemd
sudo systemctl daemon-reload
# Enable auto-start on boot
sudo systemctl enable affine-validator
# Start service
sudo systemctl start affine-validator
# View status
sudo systemctl status affine-validator
# View logs
journalctl -u affine-validator -faf servers validator [OPTIONS]Options:
--netuid <NETUID>: Subnet ID (default: fromNETUIDenv var or 120)--wallet-name <NAME>: Wallet name (default: fromBT_WALLET_COLDenv var)--hotkey-name <NAME>: Hotkey name (default: fromBT_WALLET_HOTenv var)--network <NETWORK>: Network name (default: fromSUBTENSOR_NETWORKenv var or finney)-v, -vv, -vvv: Increase logging verbosity (INFO, DEBUG, TRACE)
Examples:
# Run with environment variables
af servers validator
# Specify all parameters
af servers validator --netuid 120 --wallet-name mywallet --hotkey-name myhotkey --network finney
# Use DEBUG logging
af -vv servers validator
# Single run (default)
af servers validator
# Service mode
SERVICE_MODE=true af servers validatorValidators can also use query commands to monitor network status:
# View latest weights
af get-weights
# View top 10 miners
af get-scores --top 10
# View full ranking table
af get-rank
# View specific miner info
af get-miner <UID>The validator periodically prints status information:
============================================================
Validator Service Status
============================================================
Running: True
Total Runs: 48
Successful: 45
Failed: 3
Success Rate: 93.8%
Weight Setter:
Total Sets: 45
Failed Sets: 0
Last Set: 1732766400
============================================================
- Success Rate: Weight setting success rate, should stay above 90%
- Total Runs: Total number of runs
- Failed Sets: Number of failed weight settings
Adjust logging verbosity as needed:
# CRITICAL: Only critical errors
af servers validator
# INFO: Basic information (-v)
af -v servers validator
# DEBUG: Detailed debug information (-vv)
af -vv servers validator
# TRACE: Most detailed trace information (-vvv)
af -vvv servers validator# Real-time log viewing
docker compose logs -f
# View last 100 lines
docker compose logs --tail=100
# View specific service logs
docker compose logs -f validatorCause: Backend API may be temporarily unavailable or under maintenance.
Solutions:
- Check network connection
- Verify API endpoint is accessible
- Wait a few minutes and retry
- Check Discord for maintenance notifications
Cause: May be on-chain transaction failure or wallet configuration error.
Solutions:
- Confirm wallet configuration is correct
- Check wallet has sufficient TAO for transaction fees
- Verify hotkey is registered to the subnet
- Check subtensor connection is normal
- Use
-vvor-vvvto view detailed error messages
Solutions:
# Recreate containers
docker compose up -d --force-recreate
# Or use CLI
af deploy validator --recreateVerification Steps:
-
View logs to confirm no errors:
docker compose logs -f
-
Check weights are successfully set on-chain:
af get-weights
-
Monitor success rate should stay above 90%
Minimum Configuration:
- CPU: 2 cores
- Memory: 4GB
- Storage: 20GB
- Network: Stable internet connection
Validators don't require GPUs as all computation is done on the backend.
Single Run Mode (Default):
- Execute one weight setting and exit
- Suitable for use with cron or systemd for scheduled runs
SERVICE_MODE=falseor not set
Service Mode:
- Continuous operation, periodically setting weights at intervals
- Suitable for Docker deployment or long-term running
SERVICE_MODE=true
Docker Method:
docker-compose down && docker-compose pull && docker-compose up -dLocal Method:
cd affine
git pull
uv pip install -e .Watchtower Auto-Update: The Docker Compose configuration includes Watchtower, which automatically pulls the latest image and restarts services.
- Main Documentation - Affine project overview
- Miner Guide - Mining guide
- FAQ - Frequently Asked Questions
- Bittensor Documentation - Official Bittensor documentation