[FEATURE] Unify validator's three validation flows to reduce duplication
Problem Statement
The validator currently performs validation through three separate flows that have significant duplication:
- Discovery Flow - Fetches miners from Bittensor metagraph
- Scoring Flow - Verifies miners and calculates scores
- Weight Setting Flow - Sets weights based on scores
Each flow independently fetches metagraph data, processes miner information, and manages state. This leads to:
- Redundant network calls to Bittensor
- Duplicate miner data processing logic
- Inconsistent state management
- Higher resource usage
- Maintenance burden
Proposed Solution
Create a unified validation pipeline with shared components:
- Unified Metagraph Service - Single source for miner data with caching
- Centralized Miner Repository - One place for all miner state
- Event-Driven Architecture - Components communicate via events
- Shared Validation Utilities - Common logic extracted
- Single Scheduler - Manages all timed operations
Component
Validator
Priority Level
High
Checklist
Phase 1: Extract Shared Components
Phase 2: Implement Event System
Phase 3: Unify Data Layer
Phase 4: Simplify Scheduling
Phase 5: Testing and Migration
Implementation Ideas
Example unified flow:
1. SchedulerService triggers discovery every N minutes
2. MinerRegistryService fetches/caches metagraph
3. Discovery emits batch of MinerDiscovered events
4. Verification consumes events, performs checks
5. Verification emits VerificationComplete events
6. Weight setter aggregates results
7. On block interval, weight setter submits to chain
Additional Context
Current duplication examples:
- Metagraph fetched 3+ times per cycle
- Endpoint validation logic in 2 files
- Miner data transformed multiple times
- Database queries overlap significantly
Expected benefits:
- 50% reduction in network calls
- Better resource utilization
- Easier to add new validation types
- Improved debugging and monitoring
- Cleaner, more maintainable code
Related Files
crates/validator/src/miner_prover/discovery.rs
crates/validator/src/miner_prover/verification.rs
crates/validator/src/bittensor_core/weight_setter.rs
crates/validator/src/miner_prover/scheduler.rs
[FEATURE] Unify validator's three validation flows to reduce duplication
Problem Statement
The validator currently performs validation through three separate flows that have significant duplication:
Each flow independently fetches metagraph data, processes miner information, and manages state. This leads to:
Proposed Solution
Create a unified validation pipeline with shared components:
Component
Validator
Priority Level
High
Checklist
Phase 1: Extract Shared Components
MinerRegistryServicein validatoris_invalid_endpoint()to common locationEndpointValidatorstructUnifiedMinerProfilestructPhase 2: Implement Event System
Phase 3: Unify Data Layer
MinerRepositorytraitPhase 4: Simplify Scheduling
SchedulerServicePhase 5: Testing and Migration
Implementation Ideas
Example unified flow:
Additional Context
Current duplication examples:
Expected benefits:
Related Files
crates/validator/src/miner_prover/discovery.rscrates/validator/src/miner_prover/verification.rscrates/validator/src/bittensor_core/weight_setter.rscrates/validator/src/miner_prover/scheduler.rs