-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Basilica Marketplace System: Complete Technical Specification
Executive Summary
The Basilica Marketplace is a centralized cloud-deployed service enabling demand-driven compute allocation through competitive bidding. The system operates independently from validators as an AWS-hosted service (similar to billing and payments), using PostgreSQL for centralized state management and webhook-based communication with miners.
Critical Architectural Principles:
- Marketplace is a standalone AWS service (NOT embedded in validators)
- Only the highest-stake validator can publish demand signals
- PostgreSQL database (centralized, NOT per-validator SQLite)
- Webhook-based communication with miners (concurrent, fast-reply)
- Deployed in same ECS cluster as API, billing, and payments services
System Architecture Overview
1. Service Topology
┌──────────────────────────────────────────────────────────────────────────┐
│ AWS ECS Cluster │
│ (basilica-{env}-v3-cluster) │
├──────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐ │
│ │ Basilica API │ │ Billing │ │ Payments │ │
│ │ Gateway │ │ Service │ │ Service │ │
│ ├──────────────────┤ ├──────────────────┤ ├──────────────────┤ │
│ │ HTTP: 8000 │ │ HTTP: 8080 │ │ HTTP: 8082 │ │
│ │ (REST API) │ │ gRPC: 50051 │ │ gRPC: 50061 │ │
│ │ │ │ Metrics: 9090 │ │ Metrics: 9092 │ │
│ └──────────────────┘ └──────────────────┘ └──────────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────────────────┐ │
│ │ Marketplace Service (NEW) │ │
│ │ │ │
│ │ ┌──────────────────┐ ┌──────────────────┐ │ │
│ │ │ HTTP REST API │ │ gRPC Service │ │ │
│ │ │ (Port 8083) │ │ (Port 50062) │ │ │
│ │ │ Miner bids & │ │ Validator demand│ │ │
│ │ │ registrations │ │ signal RPCs │ │ │
│ │ └──────────────────┘ └──────────────────┘ │ │
│ │ │ │
│ │ Metrics: 9093 (Prometheus) │ │
│ │ │ │
│ │ Background Services: │ │
│ │ • Demand Signal Monitor (leader-elected, 60s lease) │ │
│ │ • Webhook Dispatcher (concurrent fanout, 50 workers) │ │
│ │ • Bid Collector & Validator (batch processing) │ │
│ │ • Allocation Tracker (status monitoring) │ │
│ │ • Trust Score Calculator (periodic updates) │ │
│ │ • DLQ Retry Processor (exponential backoff) │ │
│ └──────────────────────────────────────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────────────────┐
│ RDS Aurora PostgreSQL Serverless v2 │
│ (Single cluster, multiple databases) │
├──────────────────────────────────────────────────────────────────────────┤
│ • basilica_v3_api (API Gateway database) │
│ • basilica_v3_billing (Billing service - 26 migrations) │
│ • basilica_v3_payments (Payments service - 3 migrations) │
│ • basilica_v3_marketplace (NEW - Marketplace service) │
│ Tables: demand_signals, bids, allocations, miner_webhooks, │
│ webhook_deliveries, trust_scores, miner_stats, │
│ pricing_history, marketplace_audit, webhook_failures │
└──────────────────────────────────────────────────────────────────────────┘
External Integrations:
├─ Validators (geo-distributed, SQLite local state)
│ └─> gRPC client → Marketplace (publish demand signals, accept bids)
│ Endpoint: marketplace-v3.basilica-{env}-v3.local:50062
│
├─ Miners (geo-distributed)
│ └─> HTTP webhooks ← Marketplace (demand signal notifications)
│ └─> HTTP REST API → Marketplace (bid submission, registration)
│ Endpoint: https://marketplace.basilica.ai/api/v1
│
└─ Bittensor Metagraph (Finney, netuid 39)
└─> Query validator stakes → Determine highest-stake validator
Cache: 5-minute TTL, 4-minute background refresh
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request