14 tests covering request-response correlation, timeout handling, auto-connect, parallel stat collection, ping RTT with metrics update, concurrent multi-peer requests, and dead peer channel cleanup. Also fixes a pre-existing data race (P2P-RACE-1) in GracefulClose where SetWriteDeadline was called outside writeMu, racing with concurrent Send() calls. Co-Authored-By: Charon <developers@lethean.io>
2.9 KiB
2.9 KiB
Findings
Code Quality
- 90 tests in node/, all pass — 72.1% statement coverage (up from 63.5%)
- logging/ fully tested (12 tests, 100% coverage)
- UEPS 88.5% coverage — wire protocol tests added in Phase 1
go vetclean — no static analysis warningsgo test -raceclean — no data races (GracefulClose race fixed, see below)- Zero TODOs/FIXMEs in codebase
Security Posture (Strong)
- X25519 ECDH key exchange with Borg STMF
- Challenge-response authentication (HMAC-SHA256)
- TLS 1.2+ with hardened cipher suites
- Message deduplication (5-min TTL, prevents amplification)
- Per-peer rate limiting (100 burst, 50 msg/sec)
- Tarball extraction: Zip Slip defence, 100 MB per-file limit, symlink/hardlink rejection
- Peer auth modes: open or public-key allowlist
Architecture Strengths
- Clean separation: identity / transport / peers / protocol / worker / controller
- KD-tree peer selection via Poindexter: [PingMS × 1.0, Hops × 0.7, GeoKM × 0.2, (100-Score) × 1.2]
- Debounced persistence (5s coalesce window for peer registry)
- Buffer pool for JSON encoding (reduces GC pressure)
- Decoupled MinerManager/ProfileManager interfaces
Critical Test Gaps
| File | Lines | Tests | Coverage |
|---|---|---|---|
| identity.go | 290 | 5 tests | Good |
| peer.go | 708 | 19 tests | Good |
| message.go | 237 | 8 tests | Good |
| worker.go | 402 | 10 tests | Good |
| bundle.go | 355 | 9 tests | Good |
| protocol.go | 88 | 5 tests | Good |
| transport.go | 934 | 11 tests | Good (Phase 2) |
| controller.go | 327 | 14 tests | Good (Phase 3) |
| dispatcher.go | 39 | stub | N/A |
| ueps/packet.go | 124 | 9 tests | Good (Phase 1) |
| ueps/reader.go | 138 | 9 tests | Good (Phase 1) |
Known Issues
- dispatcher.go is a stub — Contains commented-out UEPS routing code. Threat circuit breaker and intent routing not implemented.
- UEPS 0xFF payload length ambiguous — Relies on external TCP framing, not self-delimiting. Comments note this but no solution implemented.
Potential race in controller.go—— Not a real issue. The pending map is initialised intransport.OnMessage(c.handleResponse)called during initNewControllerbeforeOnMessageis called, andhandleResponseuses a mutex. No panic possible.- No resource cleanup on some error paths — transport.handleWSUpgrade doesn't clean up on handshake timeout; transport.Connect doesn't clean up temp connection on error.
- Threat score semantics undefined — Referenced in dispatcher stub and UEPS header but no scoring/routing logic exists.
Bugs Fixed
- P2P-RACE-1: GracefulClose data race (Phase 3) —
GracefulClosecalledpc.Conn.SetWriteDeadline()outside ofwriteMu, racing with concurrentSend()calls that also modify the write deadline. Fixed by removing the bareSetWriteDeadlinecall and relying onSend()which already manages deadlines under the lock. Detected bygo test -race.