Peer Service Status
Overall Status: 100% MVD COMPLETE Location: src/Services/Sorcha.Peer.Service/Last Updated: 2026-03-01
Summary
| Component | Status | Notes |
|---|---|---|
| Phase 1-2: Foundation | 100% | Setup, entities, config |
| Phase 3: Core (Hub) | 100% | Connection, replication, heartbeat, push notifications |
| PEER-023: P2P Topology Refactor | 100% | 10 phases, replaced hub model with equal-peer architecture |
| PEER-024: Management & Observability | 100% | REST endpoints, CLI commands, Blazor UI |
| PR #110 Review Fixes | 100% | 12 issues (3 critical, 4 high, 5 medium) |
| Observability | 100% | 7 metrics, 6 traces |
| gRPC Service | 100% | 7 RPCs implemented |
| Register Replication | 100% | Full replication pipeline |
| Live Subscriptions | 100% | Real-time register subscriptions |
| Tests | 504 passing | Unit tests comprehensive |
P2P Architecture (PEER-023 / PEER-024) - COMPLETE
The Peer Service was refactored from a 3-hardcoded-hub-node model to a true P2P topology:
- Equal-peer architecture — all nodes equivalent; seed nodes serve only as bootstrap
- PeerConnectionPool — multi-peer gRPC channel management with idle cleanup
- PeerExchangeService — gossip-style mesh network discovery
- RegisterAdvertisementService — register-aware peering
- RegisterCache + RegisterReplicationService — per-register sync with ForwardOnly/FullReplica modes
- P2P heartbeat — PeerHeartbeatBackgroundService with per-register version exchange
- PeerListManager — migrated from SQLite to PostgreSQL (EF Core)
PR #110 Review Fixes (2026-02-08) - COMPLETE
12 issues from two detailed code reviews resolved:
Critical (3)
- Race condition —
Dictionary<>replaced withConcurrentDictionary<>inRegisterSyncBackgroundService - EF Core migration —
InitialPeerSchemamigration generated forpeerschema (PeerNodes, RegisterSubscriptions, SyncCheckpoints) - Hardcoded password — design-time factory now reads
PEER_DB_CONNECTIONenv var with dev-only fallback
High (4)
- gRPC channel idle timeout — changed from
Timeout.InfiniteTimeSpanto 5 minutes - JWT authentication — added
AuthenticationExtensions.cswithRequireAuthenticated,CanManagePeers,RequireServicepolicies; middleware wired inProgram.cs - RegisterCache eviction — bounded cache with configurable
MaxCachedTransactionsPerRegister(100K) andMaxCachedDocketsPerRegister(10K); oldest entries evicted by version - Replication timeouts — overall
ReplicationTimeoutMinutes(30 min default); batched docket pulls usingDocketPullBatchSize(100 default) instead of unlimited
Medium (5)
- Magic numbers — replaced with
PeerServiceConstants.MaxConsecutiveFailuresBeforeDisconnect(5),MaxConsecutiveFailuresBeforeError(10),GossipExchangePeerCount(3) - Seed node reconnection —
ReconnectDisconnectedSeedNodesAsync()added toPeerConnectionPool, called every heartbeat cycle - gRPC message size limits — 16 MB send/receive limits configured
- EnableDetailedErrors — scoped to development environment only
- Idle connection cleanup — wired into heartbeat loop (every 10th cycle, ~5 min), cleaning connections idle >15 min
Authentication
JWT Bearer authentication via shared ServiceDefaults.AddJwtAuthentication():
| Endpoint | Policy |
|---|---|
| Ban/unban/reset peers | CanManagePeers |
| Subscribe/unsubscribe/purge registers | RequireAuthenticated |
| Monitoring (peer list, health, stats) | Anonymous |
| Connected peers (detailed) | Authenticated (count-only for anonymous) |
Completed Features
- P2P topology with seed node bootstrap
- Gossip-style peer exchange for mesh discovery
- Per-register replication (ForwardOnly / FullReplica)
- Register-aware peering with version advertisements
- P2P heartbeat with version lag detection
- Peer ban/unban/reset management (REST + CLI + Blazor UI)
- JWT authentication with authorization policies
- EF Core PostgreSQL persistence with initial migration
- Bounded register cache with size-based eviction
- gRPC hardening (message limits, idle timeout, replication timeout)
- Seed node reconnection and idle connection cleanup
- Comprehensive observability (7 metrics, 6 traces)
Completed (Phase E - 2026-03-01)
- gRPC service with 7 RPCs
- Register replication pipeline
- Live register subscriptions
Deferred (Post-MVD)
- BLS threshold coordination
- TLS support for gRPC in production
- Performance tests (replication throughput)
- Integration tests (P2P multi-node scenarios)
Back to: Development Status