How tig-foundation/tig-monorepo works
Purpose and Top-Level Entry Points
TIG is a monorepo implementing an optimisable proof-of-work network: innovators submit challenge solvers; benchmarkers execute them, produce proofs/runtime signatures, and protocol logic validates rewards. Rust is the primary systems language, with CUDA for GPU challenges, Python for benchmark orchestration, Solidity for the token, and Angular for the operational dashboard.
Primary executable entry points are tig-runtime/src/main.rs (single-nonce execution), tig-verifier/src/main.rs (solution/proof verification), and benchmarker processes at tig-benchmarker/master/main.py and tig-benchmarker/slave/main.py.
Shared Domain and Protocol Layer
Shared Rust types define challenge instances, solutions, configuration, and protocol-facing data. Core utilities provide deterministic hashing, serialization, Merkle trees, Ethereum support, and numerical helpers.
• tig-structs/src/core.rs
• tig-structs/src/config.rs
• tig-utils/src/merkle_tree.rs
• tig-protocol/src/contracts/benchmarks.rs
• tig-protocol/src/contracts/opow.rs
Protocol contracts organize algorithms, benchmarks, players, rewards, and OPoW state transitions; this is the boundary between benchmark evidence and consensus/reward accounting.
Challenge Definition and Evaluation Boundary
Eight challenge domains implement deterministic problem generation, validation, scoring, and baseline solvers. They are selected by challenge ID/type and form the contract that algorithm implementations must satisfy. CPU and GPU workloads coexist; GPU domains include CUDA kernels.
• tig-challenges/src/lib.rs
• tig-challenges/src/satisfiability/mod.rs
• tig-challenges/src/vector_search/mod.rs
• tig-challenges/src/hypergraph/kernels.cu
• tig-challenges/src/neuralnet_optimizer/nn/mod.rs
The central flow is nonce/input → challenge instance → submitted solver → candidate solution → challenge validation/score and measured execution signature/fuel.
Algorithm Submission Library
tig-algorithms is a registry of versioned, challenge-specific solver submissions. Domain modules expose implementations; individual solver directories isolate alternative algorithms and track-specialized strategies. Published archives in lib/ are distributable algorithm artifacts.
• tig-algorithms/src/lib.rs
• tig-algorithms/src/vehicle_routing/mod.rs
• tig-algorithms/src/vehicle_routing/hgs_advance/solver.rs
• tig-algorithms/src/job_scheduling/adaptive_js/solver.rs
• tig-algorithms/lib/vector_search/
GPU-capable submissions pair Rust dispatch/wrappers with CUDA source, such as tig-algorithms/src/hypergraph/sigma_freud_v8/mod.rs and its track-specific kernels.
Compilation and Isolated Runtime
The binary crate wraps an algorithm into a shared-object ABI and provides CUDA framework support. Runtime loads/executes that compiled algorithm for one nonce, producing fuel consumption and a runtime signature; verifier independently checks the resulting solution or Merkle proof.
• tig-binary/src/entry_point_template.rs
• tig-binary/src/lib.rs
• tig-binary/src/framework.cu
• tig-runtime/src/main.rs
• tig-verifier/src/main.rs
Build scripts under tig-binary/scripts/ establish the Rust/CUDA-to-.so packaging boundary; runtime Docker images enforce the challenge-specific execution environment.
Distributed Benchmarker Control Plane
A Python master/slave system schedules benchmark jobs, fetches data, manages algorithm submissions and precommits, and persists operational state in PostgreSQL. Slaves execute challenge runtime containers and return benchmark/proof results to the master.
• tig-benchmarker/master/master/job_manager.py
• tig-benchmarker/master/master/slave_manager.py
• tig-benchmarker/master/master/precommit_manager.py
• tig-benchmarker/slave/main.py
• tig-benchmarker/master/master/sql.py
Deployment is Docker Compose-oriented: tig-benchmarker/master.yml composes master, PostgreSQL, UI, and Nginx; tig-benchmarker/slave.yml provisions worker orchestration plus runtime images.
External Interfaces and Operations
The benchmarker dashboard is an Angular client behind Nginx, consuming benchmarker APIs. Ethereum/Base-chain integration is represented by protocol/token code and Rust Ethereum utilities. Docker images are published through GitHub Packages for amd64 and arm64; GPU workloads additionally require CUDA-capable runtime environments.
• tig-benchmarker/ui/src/app/services/tig-apis.service.ts
• tig-benchmarker/nginx/nginx.conf
• tig-token/TIGToken.sol
• tig-token/TokenLocker.sol
• tig-utils/src/eth.rs
Main entry points: main.py Benchmarker master · lib.rs Challenge evaluation · main.rs Single-nonce runtime · opow.rs OPoW protocol contracts
Components 18
Domain & Protocol
- Shared domain types · Challenge, solution, configuration, and protocol data.
tig-structs/src/core.rs - Deterministic utilities · Hashing, serialization, Merkle, numerical, and Ethereum helpers.
tig-utils/src/merkle_tree.rs - Challenge evaluation · Eight deterministic domains generate, validate, and score solutions.
tig-challenges/src/lib.rs - Challenge CUDA kernels
tig-challenges/src/hypergraph/kernels.cu - OPoW protocol contracts · Transforms benchmark evidence into consensus and reward state.
tig-protocol/src/contracts/opow.rs
Solver Packaging
- Solver submission registry · Versioned challenge-specific solver implementations.
tig-algorithms/src/lib.rs - Specialized solver · Track-specialized algorithm implementation.
tig-algorithms/src/vehicle_routing/hgs_advance/solver.rs - Published solver archives · Distributable solver submissions.
Execution & Verification
- Shared-object ABI wrapper · Packages a solver behind the runtime shared-object ABI.
tig-binary/src/lib.rs - CUDA runtime framework
tig-binary/src/framework.cu - Single-nonce runtime · Executes a compiled solver and emits fuel and runtime signature.
tig-runtime/src/main.rs - Solution/proof verifier · Independently validates solutions or Merkle proofs.
tig-verifier/src/main.rs
Benchmarker Control Plane
- Benchmarker master · Schedules jobs and coordinates submissions, precommits, and workers.
tig-benchmarker/master/main.py - Benchmarker slave · Runs challenge runtime containers and returns results.
tig-benchmarker/slave/main.py - Operational state · Persists benchmarker state.
tig-benchmarker/master/master/sql.py
External Operations
- Operations dashboard
tig-benchmarker/ui/src/app/services/tig-apis.service.ts - Dashboard gateway
tig-benchmarker/nginx/nginx.conf - TIG token contracts · On-chain token and locking interface.
tig-token/TIGToken.sol
Connections 21
- Shared domain types → Challenge evaluation: instances and solutions
- Deterministic utilities → Challenge evaluation: deterministic primitives
- Challenge CUDA kernels → Challenge evaluation: GPU domains
- Challenge evaluation → Solver submission registry: solver contract
- Solver submission registry → Specialized solver: contains
- Solver submission registry → Published solver archives: publishes
- Specialized solver → Shared-object ABI wrapper: wrapped for execution
- Shared-object ABI wrapper → CUDA runtime framework: GPU support
- Shared-object ABI wrapper → Single-nonce runtime: loads shared object
- Single-nonce runtime → Challenge evaluation: candidate solution
- Single-nonce runtime → Solution/proof verifier: solution, signature, proof
- Solution/proof verifier → OPoW protocol contracts: validated evidence
- Deterministic utilities → OPoW protocol contracts: Merkle and Ethereum support
- OPoW protocol contracts → TIG token contracts: reward/token integration
- Benchmarker master → Benchmarker slave: schedules benchmark jobs
- Benchmarker slave → Single-nonce runtime: executes runtime containers
- Benchmarker slave → Benchmarker master: benchmark and proof results
- Benchmarker master → Operational state: persists state
- Operations dashboard → Dashboard gateway: served through
- Dashboard gateway → Benchmarker master: benchmarker API
- Benchmarker master → OPoW protocol contracts: submits benchmark evidence