logos-delivery/logos_delivery
Ivan FB 38a98ac7c1
fix(discovery): age stale discv5 ENRs out of peer-exchange via freshness TTL
PX serves ENRs from the add-only PeerStore ENRBook, whose only liveness
gate was CannotConnect. Disconnected/never-dialed discv5 peers stayed
NotConnected and were advertised indefinitely (#3933).

Instead of deleting peer-store state against the bounded discv5 routing
table (which can false-prune a live peer evicted from a full k-bucket),
track an ENR last-seen Moment and gate the PX read path on it:

- EnrLastSeenBook + EnrFreshnessTTL; touchEnrSeen stamps freshness.
- Refresh-only liveness: stamped on ENR (re)write, on connect, and from
  the revalidated routing table each discv5 round. Membership never
  deletes state, so a live-but-bucket-evicted peer just ages out of PX
  rather than being purged.
- getEnrsFromStore skips non-Connected ENRs older than the TTL; a
  Connected peer is always considered fresh.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 13:42:11 +02:00
..