logos-delivery/logos_delivery
Igor Sirotin e2f9efedd8 fix(discovery): prune stale discv5 peers from peer store (#3933)
Peer-exchange responds with ENRs read from the PeerStore ENRBook, which
is fed add-only by the discv5 search loop and only pruned on capacity,
never on staleness. discv5 revalidates its routing table and evicts
unreachable nodes within seconds, but those evictions were not
propagated to the peer store, so PX kept advertising ENRs of dead peers
(only peers we personally failed to dial -> CannotConnect were skipped;
disconnected peers are CanConnect and discovered-but-unconnected peers
are NotConnected, both of which were still served).

Reconcile the peer store against the live routing table at the end of
each discv5 search iteration: drop Discv5-origin, non-connected peers
that discv5 no longer knows about. Peers discovered in the same round
are preserved.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 11:00:10 +01:00
..