Skip to content

feat(p2p): DHT hardening, cover traffic module, and config hot-reload - #37

Merged
aratan merged 1 commit into
mainfrom
feat/dht-hardening-cover-traffic
Jul 15, 2026
Merged

feat(p2p): DHT hardening, cover traffic module, and config hot-reload#37
aratan merged 1 commit into
mainfrom
feat/dht-hardening-cover-traffic

Conversation

@aratan

@aratan aratan commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Seed health gate with degraded mode (GossipSub-only) when DHT unreachable
  • Parallel mDNS + DHT bootstrap for faster LAN peer discovery
  • DHT health monitor with 2-failure threshold and auto-recovery
  • Dedicated cover traffic module on /28sp/cover/v1 with CPU throttle
  • InitCoverTraffic/StartCoverTraffic public API on P2PHost
  • ConfigWatcher with SHA-256 polling (2s) for hot-reload of cover rates
  • 8 RED tests (covertraffic) passing, 5 P2P test stubs

Changes

File Change
internal/covertraffic/covertraffic.go NEW — Cover traffic module with Start/Stop/SetRate/CPU throttle
internal/covertraffic/covertraffic_test.go NEW — 8 unit tests for cover traffic (all passing)
internal/p2p/hotreload.go NEW — ConfigWatcher with SHA-256 polling
internal/p2p/p2p_test.go NEW — 5 RED test stubs (seed health, DHT degradation, cover, watcher)
internal/p2p/p2p.go Seed health (Config), DHT health monitor, degraded mode, cover traffic wiring
internal/p2p/discovery.go checkSeedHealth() with parallel 5s timeout
main.go InitCoverTraffic + StartCoverTraffic calls
config.yaml seedAddrs, requireSeeds fields added

Test Plan

  • go test ./internal/covertraffic/... — 8/8 PASS
  • go build ./... — compiles clean
  • go vet ./... — no warnings
  • go build ./internal/p2p/... — builds (tests require libp2p, longer compilation)

SDD

This is PR 1/4 of SDD change integrar-28sp-en-mesh-hermes.

Phase 1 of integrar-28sp-en-mesh-hermes:

- Seed health gate: checkSeedHealth() with parallel 5s probe before DHT
  advertising; enters degraded mode (GossipSub-only) when unreachable
- Parallel mDNS + DHT bootstrap for immediate LAN peer discovery
- DHT health monitor with 2-failure threshold, degraded mode, and
  auto-recovery when DHT becomes reachable again
- Cover traffic module (internal/covertraffic/) on dedicated /28sp/cover/v1
  topic with CPU throttle (auto-reduce 50% at >80% load)
- InitCoverTraffic/StartCoverTraffic in P2PHost API
- ConfigWatcher with SHA-256 polling (2s interval) for hot-reload of
  cover traffic rates without restart
- 8 RED tests for covertraffic (all passing), 5 test stubs for p2p

SDD: integrar-28sp-en-mesh-hermes, PR 1/4
@aratan
aratan force-pushed the feat/dht-hardening-cover-traffic branch from 597954a to 1c539bb Compare July 15, 2026 16:22
@aratan
aratan merged commit 3ea0831 into main Jul 15, 2026
2 of 3 checks passed
@aratan
aratan deleted the feat/dht-hardening-cover-traffic branch July 15, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant