This document outlines the peer-to-peer (P2P) networking architecture for CIRO Network, detailing the transition from a centralized coordinator model to a fully decentralized compute marketplace built on libp2p.
Job Clients β HTTP API β Coordinator β Database β HTTP API β Workers
β β β
[REST API] [In-Memory Pool] [Registration]
[Task Queue] [Capability Match]
- Single Point of Failure: Coordinator centralization
- Limited Scalability: HTTP-based communication bottleneck
- No Direct Worker Communication: Everything routes through coordinator
- Static Discovery: Workers must know coordinator endpoints
- No Fault Tolerance: If coordinator fails, entire network stops
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CIRO P2P Network β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β Worker A βββββΊβ Worker B βββββΊβ Worker C β β
β β (libp2p) β β (libp2p) β β (libp2p) β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β β β β
β βββββββββββββββββββΌββββββββββββββββββ β
β β β
β βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββ β
β β Gossip Protocol β β
β β β’ Job Distribution β β’ Capability Broadcasting β β
β β β’ Result Collection β β’ Reputation Updates β β
β β β’ Network Health β β’ Blockchain State Sync β β
β βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββ β
β β DHT-Based Discovery β β
β β β’ Peer Finding β β’ Capability Indexing β β
β β β’ Bootstrap Nodes β β’ Network Topology β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Starknet Integration β β
β β β’ Job Contracts β β’ Payment Settlement β β
β β β’ Worker Staking β β’ Reputation Storage β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Decentralized: No single point of failure
- Scalable: Direct peer-to-peer communication
- Fault Tolerant: Network continues operating with node failures
- Efficient: Reduced latency through direct connections
- Cost Effective: No need for centralized infrastructure
- Transport: TCP, WebSocket, QUIC
- Security: Noise protocol encryption
- Multiplexing: Yamux for connection efficiency
- Identity: Ed25519 keys for peer authentication
- Kademlia DHT: Distributed hash table for peer finding
- Bootstrap Nodes: Initial network entry points
- Capability Indexing: Find peers by specific capabilities
- Network Topology: Maintain network structure view
- Job Distribution: Broadcast available jobs
- Worker Capabilities: Announce worker specifications
- Result Collection: Aggregate computation results
- Network Health: Monitor peer status and reputation
- Job Contracts: On-chain job registration and escrow
- Payment Settlement: Automated payment distribution
- Reputation Storage: Long-term reputation tracking
- Dispute Resolution: Smart contract-based arbitration
1. Job Submission
Client β Network β Gossip Broadcast
2. Worker Discovery
Network β DHT Lookup β Capability Matching
3. Job Assignment
Bidding Process β Worker Selection β Task Distribution
4. Execution
Worker β Compute β Result Generation
5. Result Collection
Result β Gossip β Aggregation β Verification
6. Settlement
Blockchain β Payment β Reputation Update
// rust-node/src/network/
βββ p2p.rs // Core P2P networking layer
βββ discovery.rs // DHT-based peer discovery
βββ gossip.rs // Gossip protocol implementation
βββ worker_registry.rs // Worker capability management
βββ job_distribution.rs // Decentralized job distribution
βββ result_collector.rs // Result aggregation system
βββ reputation.rs // Network health & reputationpub struct P2PNetwork {
swarm: libp2p::Swarm<CiroBehaviour>,
local_peer_id: PeerId,
bootstrap_peers: Vec<PeerId>,
capability_index: HashMap<String, Vec<PeerId>>,
}
pub struct GossipMessage {
JobAnnouncement(JobAnnouncement),
WorkerCapabilities(WorkerCapabilities),
JobResult(JobResult),
ReputationUpdate(ReputationUpdate),
}- Maintain existing centralized coordinator
- Add P2P capabilities alongside current system
- Allow gradual worker migration to P2P
- P2P becomes primary job distribution method
- Centralized coordinator as fallback
- Monitor network health and performance
- Remove centralized coordinator dependency
- Pure P2P operation
- Enhanced fault tolerance and scalability
- Latency: <100ms for job distribution
- Discovery: <5s to find suitable workers
- Throughput: 100+ jobs/second network capacity
- Uptime: >99.9% network availability
- Network Size: 1000+ concurrent workers
- Concurrent Jobs: 500+ simultaneous executions
- Data Efficiency: Minimal gossip overhead
- Connection Stability: Resilient to network churn
- Peer Authentication: Ed25519 cryptographic identity
- Transport Encryption: Noise protocol for all communications
- Reputation System: Prevent malicious actor participation
- Rate Limiting: Protect against DoS attacks
- Stake Requirements: Workers must stake tokens to participate
- Slashing Conditions: Penalize malicious or poor performance
- Dispute Resolution: Smart contract arbitration system
- Payment Security: Escrow-based payment protection
- Cross-Chain Support: Multi-blockchain job execution
- Zero-Knowledge Proofs: Verifiable computation results
- Dynamic Pricing: Market-based job pricing
- Mobile Workers: Smartphone-based compute participation
- Network Topology: Optimize peer connections for efficiency
- Caching Strategies: Intelligent result and model caching
- Load Balancing: Advanced job distribution algorithms
- Edge Computing: Geographically distributed compute
This architecture document serves as the foundation for implementing CIRO Network's transition to a fully decentralized compute marketplace. Regular updates will be made as the implementation progresses.