litep2p/discovery: Fix memory leak in `litep2p.public_addresses()` (#5998)
This PR ensures that the `litep2p.public_addresses()` never grows indefinitely. - effectively fixes subtle memory leaks - fixes authority DHT records being dropped due to size limits being exceeded - provides a healthier subset of public addresses to the `/identify` protocol This PR adds a new `ExternalAddressExpired` event to the litep2p/discovery process. Substrate uses an LRU `address_confirmations` bounded to 32 address entries. The oldest entry is propagated via the `ExternalAddressExpired` event when a new address is added to the list (if capacity is exceeded). The expired address is then removed from the `litep2p.public_addresses()`, effectively limiting its size to 32 entries (the size of `address_confirmations` LRU). cc @paritytech/networking @alexggh --------- Signed-off-by:Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by:
Bastian Köcher <git@kchr.de> Co-authored-by:
Dmitry Markin <dmitry@markin.tech>
Showing
- prdoc/pr_5998.prdoc 15 additions, 0 deletionsprdoc/pr_5998.prdoc
- substrate/client/network/src/litep2p/discovery.rs 51 additions, 6 deletionssubstrate/client/network/src/litep2p/discovery.rs
- substrate/client/network/src/litep2p/mod.rs 19 additions, 0 deletionssubstrate/client/network/src/litep2p/mod.rs
prdoc/pr_5998.prdoc
0 → 100644