Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- kad: Prevent local provider eviction, expiration, and removal panics; `max_provider_keys` now applies separately to remote provider keys and local registrations (up to 2× in total), and rejected registrations are reported ([#665](https://github.com/paritytech/litep2p/issues/665))

## [0.15.2] - 2026-09-04

This is a security release.
Expand Down
3 changes: 3 additions & 0 deletions src/protocol/libp2p/kademlia/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ impl ConfigBuilder {

/// Set maximum number of provider keys in the memory store.
///
/// The limit applies separately to the provider keys of remote peers and to the keys this
/// node provides itself, so up to twice this many keys can be held in total.
///
/// If unspecified, the default maximum number of provider keys is 1024.
pub fn with_max_provider_keys(mut self, max_provider_keys: usize) -> Self {
self.memory_store_config.max_provider_keys = max_provider_keys;
Expand Down
27 changes: 16 additions & 11 deletions src/protocol/libp2p/kademlia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1287,17 +1287,22 @@ impl Kademlia {
addresses,
};

self.store.put_local_provider(key.clone(), quorum);

self.engine.start_add_provider(
query_id,
key.clone(),
provider,
self.routing_table
.closest(&Key::new(key), self.replication_factor)
.into(),
quorum,
);
if self.store.put_local_provider(key.clone(), quorum) {
self.engine.start_add_provider(
query_id,
key.clone(),
provider,
self.routing_table
.closest(&Key::new(key), self.replication_factor)
.into(),
quorum,
);
} else {
let _ = self
.event_tx
.send(KademliaEvent::QueryFailed { query_id })
.await;
}
}
Some(KademliaCommand::StopProviding {
key,
Expand Down
Loading
Loading