Conversation
- Add mesh_peer_count() and topic_peer_count() to monitor mesh status - Add refresh_subscription() to force SUBSCRIBE exchange with peers - Add repair_mesh_if_needed() that runs every 10s to fix empty mesh - Trigger subscription refresh when new platform validator is identified - IMPORTANT: Do NOT use add_explicit_peer - it makes peers bypass mesh! - Fixes issue where validators joining existing network don't form mesh
…aim/Lease - Add crates/platform-server with REST API, WebSocket, PostgreSQL - Implement Control Plane API (validators, challenges, config) - Implement Data API with Claim/Lease anti-duplication mechanism - Add Rule Engine for server-side enforcement - Add observability with Sentry integration and audit trail - Add mechanism_id and emission_weight to ChallengeConfig - Add docker-compose.server.yml for subnet owner deployment - Add Dockerfile.server with optimized multi-stage build Architecture per README spec: - Platform Server is single source of truth - Challenges access DB only via Data API - Deterministic weights via /get_weights endpoint - Full audit trail for all data access
- Add api_key and api_provider fields to submission model - Add total_cost_usd tracking for LLM inference costs - Update schema with new columns for centralized API key storage - Update all submission queries to include new fields - Add update_submission_cost() for accumulating inference costs
- Add ws_transport.rs with WebSocket server for broker - Support JWT authentication for WebSocket connections - container-broker supports both Unix socket and WebSocket - Options: --ws-port (default 8090), --ws-only to disable Unix socket - Environment: BROKER_WS_PORT, BROKER_JWT_SECRET Challenge containers connect via WebSocket without socket mounting.
- Add secure-container-runtime as validator-node dependency
- Start WebSocket broker alongside validator (port 8090 default)
- Add --broker-port and --broker-jwt-secret CLI options
- Pass CONTAINER_BROKER_WS_URL and CONTAINER_BROKER_JWT to challenges
- Challenges spawn sandbox containers via WebSocket broker
- No Docker socket needed for challenge containers
Architecture:
validator-node → container broker (ws://0.0.0.0:8090)
→ challenges connect via WebSocket
→ sandbox containers spawned by broker
- challenge-orchestrator/evaluator.rs: remove fixed EvaluateRequest/Response, use generic JSON passthrough (challenge-agnostic) - platform-server/challenge_proxy.rs: increase timeout 30s -> 600s for long evaluations
- Remove hardcoded CHALLENGE_ID/CHALLENGE_URL requirements
- Add challenges table with full metadata (docker_image, resources, etc.)
- Implement ChallengeManager for dynamic container lifecycle
- Add REST API for challenge CRUD: /api/v1/challenges
- Dynamic routing: /api/v1/challenges/{id}/* proxies to containers
- Load challenges from DB on startup, manage via API
- Default owner hotkey: 5GziQCcRpN8NCJktX343brnfuVe3w6gUYieeStXPD1Dag2At
- Server can start with zero challenges (fully dynamic)
Challenge servers may default to different ports (e.g., 8081). Force PORT=8080 since orchestrator expects all challenges on 8080.
- Add --platform-server CLI option for centralized orchestration - Add PlatformServerClient for fetching weights from platform-server - In CommitWindowOpen, prefer platform-server weights over local calculation - Fallback to local weights if platform-server is unavailable
- Create bins/platform with subcommands: server, validator, version
- Server mode: runs platform-server with full orchestration
- Validator mode: delegates to validator-node binary (same args)
- Single Docker image can run both modes:
docker run platform server [OPTIONS]
docker run platform validator --secret-key <KEY> [OPTIONS]
This enables using a single Docker image for both subnet owner (server)
and validators, simplifying deployment and CI/CD pipelines.
- Add /api/v1/submissions endpoints for agent submission - Add /api/v1/evaluations endpoints for evaluation recording - Use simplified registration request (no signature required for dev) - All core APIs now available in unified binary
Validators use existing docker-compose without changes: - ENTRYPOINT: validator-node - Default: --data-dir /data --platform-server https://chain.platform.network - Reads VALIDATOR_SECRET_KEY from environment automatically
debian:bookworm-slim has older glibc which causes: GLIBC_2.38 not found GLIBC_2.39 not found Ubuntu 24.04 has the required glibc version.
No hardcoded challenges - fully dynamic:
- Register via POST /api/v1/challenges
- Start via POST /api/v1/challenges/{id}/start
- Stop via POST /api/v1/challenges/{id}/stop
Supports both formats: - postgresql://host:5432 (base URL) - postgresql://host:5432/postgres (full URL with db name)
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughIntroduces a centralized Platform Server as a new Rust crate with comprehensive HTTP APIs, PostgreSQL database integration, WebSocket support, role-based authentication, dynamic challenge orchestration, and task management. Simultaneously introduces a unified platform binary that dispatches to either server or validator modes via CLI. Extends the challenge SDK with new platform client and server modules, modernizing from P2P to centralized architecture. Updates validator-node integration to communicate with the platform server. Adds WebSocket transport to secure container runtime. Refreshes Docker infrastructure, CI/CD workflows, and dependency configurations. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Challenge Client
participant Server as Platform Server
participant DB as Database
participant Broker as Container Broker
participant Validator as Validator Node
rect rgb(200, 220, 255)
Note over Client,Validator: Authentication & Registration
Client->>Server: POST /api/v1/auth<br/>(hotkey, timestamp, signature)
Server->>DB: verify_signature() & check owner
DB-->>Server: valid
Server->>DB: create session (UUID token)
Server-->>Client: AuthResponse (token, session_id)
end
rect rgb(220, 200, 255)
Note over Server,DB: Submission & Task Management
Client->>Server: POST /api/v1/submissions<br/>(miner_hotkey, source_code)
Server->>DB: compute_agent_hash()
Server->>DB: create_submission()
DB-->>Server: submission_id
Server->>Server: broadcast SubmissionEvent
Server-->>Client: SubmitAgentResponse (id, agent_hash)
end
rect rgb(220, 255, 220)
Note over Validator,Server: Task Claim & Evaluation Workflow
Validator->>Server: POST /api/v1/data/tasks/claim<br/>(validator_hotkey)
Server->>DB: claim_task() atomic check
DB-->>Server: TaskLease granted
Server->>Server: broadcast TaskClaimedEvent
Server-->>Validator: task_id, submission_id, data
Validator->>Broker: establish WebSocket connection
Broker->>Validator: challenge execution environment
Validator->>Broker: submit evaluation result
Broker-->>Validator: ack
Validator->>Server: POST /api/v1/data/results<br/>(agent_hash, score, results)
Server->>DB: create_evaluation()
Server->>DB: update_leaderboard()
Server->>Server: broadcast EvaluationEvent
Server-->>Validator: evaluation_id
end
rect rgb(255, 240, 200)
Note over Client,Server: Leaderboard & Network State Query
Client->>Server: GET /api/v1/leaderboard?limit=100
Server->>DB: get_leaderboard(100)
DB-->>Server: Vec\<LeaderboardEntry\>
Server-->>Client: JSON array (rank, agent_hash, score)
Client->>Server: GET /api/v1/challenges/network-state
Server->>DB: multi-query (epoch, stake, validators)
DB-->>Server: aggregated state
Server-->>Client: NetworkStateEvent JSON
end
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (59)
Comment |
* feat(p2p-consensus): add bootstrap nodes config and peer count methods - Add DEFAULT_BOOTSTRAP_NODES constant for production bootstrap peers - Update production() config to use DEFAULT_BOOTSTRAP_NODES - Export DEFAULT_BOOTSTRAP_NODES from lib.rs - Add len() and is_empty() methods to PeerMapping - Add connected_peer_count() and has_min_peers() to P2PNetwork * feat(p2p): add Bittensor block linking to ChainState - Add bittensor_block and bittensor_block_hash fields to ChainState - Add link_to_bittensor_block() and linked_block() methods - Update Default impl with zero-initialized fields - Link state to Bittensor block on NewBlock events * feat(challenge-sdk): add P2P submission storage and evaluation status support - Add StoreSubmission, RequestEvaluationStatus, EvaluationStatusResponse message types - Add ValidatorEvaluationResult struct for tracking validator evaluations - Add store_submission() method to P2PChallengeClient for distributed storage - Add get_evaluation_status() method to query submission evaluation progress - Update decentralized runner to handle new message types - Add comprehensive tests for new message types and methods - Export ValidatorEvaluationResult from lib.rs and prelude * refactor: make centralized server optional, add deprecation notices for P2P migration * docs: add P2P decentralized mode documentation * feat: add Docker configs for decentralized P2P mode * style: format code with cargo fmt
…tence (#2) * feat: add challenges directory structure and workspace configuration * feat: add challenge-registry crate for challenge lifecycle management Create new platform-challenge-registry crate with: - Challenge discovery and registration - Version management (semver-based) - Lifecycle state machine (registered/starting/running/stopping/stopped) - Health monitoring with configurable checks - State persistence and hot-reload support - Migration planning for version upgrades Modules: - registry: Main registry with CRUD operations - lifecycle: State machine for challenge states - health: Health monitoring and status tracking - state: State snapshots for hot-reload - discovery: Challenge discovery from various sources - migration: Version migration planning - version: Semantic versioning support - error: Registry-specific error types * feat(core): add checkpoint system for state persistence * feat: add restoration system for checkpoint recovery * feat(rpc-server): add health check endpoints for rolling updates * docs: add challenge integration guide * test: add integration tests for checkpoint and restoration system * feat: add graceful shutdown with checkpoint persistence - Add ShutdownHandler struct for checkpoint management - Create periodic checkpoints every 5 minutes - Save final checkpoint on graceful shutdown (Ctrl+C) - Persist evaluation state for hot-reload recovery This enables validators to update without losing evaluation progress.
This PR introduces the centralized Platform Server architecture, enabling dynamic challenge management and unified validator deployment.
Summary by CodeRabbit
New Features
Infrastructure
✏️ Tip: You can customize this high-level summary in your review settings.