tribewarez-pot-o
PoT-O (Proof of Tensor Optimizations) - On-chain Solana program for validating tensor-based computational proofs and distributing mining rewards.
Part of the Tribewarez programs workspace and PoT-O ecosystem.
Overview
The tribewarez-pot-o program implements Proof of Tensor Optimizations on Solana, enabling miners to submit computational proofs that are validated on-chain. It manages:
- Miner registration - Track and authorize miners
- Proof submission - Accept computational proof submissions
- Proof validation - Verify tensor network computations on-chain
- Reward distribution - Award tokens to successful miners
- Difficulty adjustment - Maintain target block rate
This is the core mining program in the PoT-O ecosystem, working alongside staking, vault, and swap programs for a complete DeFi platform.
Key Features
✨ Proof of Tensor Optimizations
Validators run tensor network computations offline and submit proofs on-chain. The program verifies the computation was performed correctly using cryptographic commitments and merkle proofs.
🔐 Secure Miner Registration
Register miners on-chain with authority validation. Only registered miners can submit valid proofs. Support for multiple authority signatures for governance.
💰 Configurable Reward Distribution
Flexible reward structure supporting multiple token types. Rewards can be:
- Distributed per proof validation
- Adjusted via governance
- Split among protocol, stakers, and miners
📊 Dynamic Difficulty Adjustment
Automatic difficulty adjustment based on submission rate to maintain consistent block validation times (~2.5 minutes per proof).
🔄 Integration Ready
Works seamlessly with tribewarez-staking for reward distribution and tribewarez-swap for liquidity provision.
Architecture Overview
┌─────────────────────────────────────────────────────┐
│ Miner Submits Proof Off-Chain │
└─────────────────┬───────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────┐
│ Miner Account Lookup & Validation (on-chain) │
│ - Check miner is registered │
│ - Check authority signature │
└─────────────────┬───────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────┐
│ Tensor Network Proof Validation (on-chain) │
│ - Verify computation hash │
│ - Check merkle proof path │
│ - Validate against current difficulty │
└─────────────────┬───────────────────────────────────┘
│
▼ Success
┌─────────────────────────────────────────────────────┐
│ Reward Distribution │
│ - Mint/transfer reward tokens │
│ - Update miner statistics │
│ - Record block (for difficulty adjustment) │
└─────────────────────────────────────────────────────┘
Data Structures
MinerAccount
Tracks individual miner information and statistics.
DifficultyState
Global state for difficulty adjustment and mining statistics.
Instructions
1. Initialize Program
Sets up difficulty state and initializes program authority.
Accounts:
difficulty_state(write) - Global difficulty trackingpayer(signer) - Transaction payer
Parameters: None
2. Register Miner
Register a new miner account.
Accounts:
miner_account(write) - New miner PDAauthority(signer) - Miner's authoritypayer(signer) - Transaction payer
Parameters: None
3. Submit Proof
Submit a tensor computation proof for validation.
Accounts:
miner_account(read) - Miner's accountdifficulty_state(read) - Current difficultyauthority(signer) - Miner's authority signature
Parameters:
computation_hash: [u8; 32]- Hash of computation resultproof_path: Vec<[u8; 32]>- Merkle proof pathnonce: u64- Proof nonce
4. Claim Rewards
Claim accumulated rewards from validated proofs.
Accounts:
miner_account(write) - Miner's accountreward_token_account(write) - Miner's reward token accounttoken_mint(read) - Reward token mintauthority(signer) - Miner's authority
Parameters:
amount: u64- Reward amount to claim
5. Adjust Difficulty
Update difficulty based on recent block times.
Accounts:
difficulty_state(write) - Difficulty stateauthority(signer) - Program authority (DAO governance)
Parameters:
new_difficulty: u64- New difficulty target
Configuration
Difficulty Parameters
pub const TARGET_BLOCK_TIME: u64 = 150; // ~2.5 minutes in slots
pub const DIFFICULTY_ADJUSTMENT_INTERVAL: u64 = 2016; // Blocks
pub const MAX_DIFFICULTY_INCREASE: f64 = 1.25; // 25% max per adjustment
pub const MAX_DIFFICULTY_DECREASE: f64 = 0.75; // 25% max per adjustment
Reward Structure
pub const REWARD_PER_VALID_PROOF: u64 = 10_000_000; // Amount in smallest units
pub const REWARD_DECAY_RATE: f64 = 0.995; // Per block decay
Usage Examples
Register as a Miner
// Off-chain: Create your authority keypair
let authority = new;
// On-chain: Call register_miner instruction
// This creates your MinerAccount PDA
Submit a Proof
// Off-chain: Compute tensor network and generate proof
let computation = compute_tensor_network;
let proof_hash = keccak256;
let merkle_proof = generate_merkle_proof;
// On-chain: Submit proof
// Program validates proof against current difficulty
// If valid, rewards are awarded to your account
Claim Rewards
// On-chain: Retrieve accumulated rewards
// Tokens are transferred to your reward token account
// Miner statistics are updated
Testing
Run tests locally:
# Build and test
# Test from workspace root
# Test with logging
RUST_LOG=debug
Test coverage includes:
- Miner registration and authority checks
- Proof submission and validation
- Difficulty adjustment calculations
- Reward distribution and claims
- Error handling for invalid proofs
Security Considerations
✅ Authority Validation
All instructions that modify state require proper authority signatures. Miners can only interact with their own accounts.
✅ Proof Verification
Proofs are validated using cryptographic commitments. A valid proof demonstrates computation was actually performed (not just guessed).
✅ Difficulty Protection
Difficulty adjustment is bounded to prevent rapid changes. Gradual adjustments maintain mining incentives.
✅ Reward Limits
Reward amounts are pre-configured and validated before distribution. No unchecked minting or transfers.
✅ State Consistency
Miner statistics are updated atomically with reward distribution, preventing state inconsistencies.
Performance Characteristics
- Proof Submission: ~0.5 CUs (compute units) - minimal on-chain computation
- Reward Distribution: ~1-2 CUs - simple token transfer
- Difficulty Adjustment: ~0.5 CUs - arithmetic only
- Total Per Block: ~2-3 CUs out of 1.4M available
Proof validation work is done off-chain by validators, making on-chain operations very efficient.
Integration with Other Programs
With tribewarez-staking
Miners can delegate staking rewards to staking pools. Rewards from PoT-O are compatible with pool reward token configuration.
With tribewarez-swap
Miners can trade rewards on the AMM. Liquidity pools support reward token pairs.
With tribewarez-vault
Miners can lock up rewards in vaults with time-locks for governance participation.
Deployment
See DEPLOYMENT_GUIDE.md for detailed devnet/testnet deployment instructions.
Quick deployment from workspace root:
API Documentation
Complete API documentation is available on docs.rs.
For trait-based service integration, see SERVICE_API_REFERENCE.md.
Contributing
Contributions welcome! Please follow:
- Conventional commit messages (feat:, fix:, docs:, test:)
- 80%+ test coverage for new code
- Clear documentation for public APIs
- Security audit for state-modifying code
License
MIT - See LICENSE for details.
Related Programs
- tribewarez-staking - Staking pool management
- tribewarez-vault - Escrow and treasury
- tribewarez-swap - AMM token swaps
- pot-o-validator - Off-chain validator daemon