Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
02641de
feat(kademlia)!: add a routing-table node limiter hook
Jashk120 Nov 26, 2026
5e85ec1
perf(network): look up static and trusted nodes by public key
Jashk120 Nov 26, 2026
a0d63ce
feat(discovery): limit discv4 routing-table entries per subnet
Jashk120 Nov 26, 2026
1744bb8
fix(discovery): keep subnet-limited nodes out of the peer candidate s…
Jashk120 Nov 26, 2026
f40a3e2
test(discovery): cover subnet counts end to end
Jashk120 Nov 26, 2026
41e1c11
Decouple discovery subnet limiter from Network managers via Core seam
Jashk120 Nov 26, 2026
b0178c6
fix(discovery): remove inert fork gate from discv4 subnet limiter
Jashk120 Nov 26, 2026
61c3c23
test(discovery): make subnet cap end-to-end test falsifiable
Jashk120 Nov 26, 2026
56bb582
fix(discovery): run subnet limiter on the bucket the node lands in
Jashk120 Nov 27, 2026
38fc60d
fix(discovery): bypass LAN addresses in discv4 subnet limiter
Jashk120 Nov 27, 2026
e603dae
fix(discovery): cover StaticPeers, bootnode off-switch and limiter docs
Jashk120 Nov 27, 2026
4547c30
chore(discovery): drop redundant usings flagged by code lint
Jashk120 Nov 27, 2026
7b8366b
fix(kademlia): retain subnet-rejected promotion candidates
Jashk120 Nov 29, 2026
6d5b8cf
fix(discovery): drop unused ManagedNodeExemptions overload
Jashk120 Nov 29, 2026
33e2574
fix(discovery): drop subnet-rejected candidates before PeerPool
Jashk120 Nov 29, 2026
337f676
fix(kademlia): keep retained liveness on rejected endpoint change
Jashk120 Nov 29, 2026
bc270a4
fix(kademlia): merge ENR state only after subnet admission
Jashk120 Nov 29, 2026
e2843c0
fix(discovery): charge retained incumbent on refused refresh
Jashk120 Nov 29, 2026
4d35ad0
fix(discovery): exclude rejected seeds from DNS feeder budget
Jashk120 Nov 29, 2026
7173ec9
fix(config): opt xdc_archive out of discovery subnet cap
Jashk120 Nov 29, 2026
a9bffc6
fix(kademlia): probe subnet cap without charging on full leaf
Jashk120 Nov 29, 2026
502a80e
fix(discovery): exempt static peers without DNS lookup
Jashk120 Nov 29, 2026
948edaf
test(discovery): isolate bucket and table subnet guards
Jashk120 Nov 29, 2026
7ddaf92
fix(bootnode): align test fakes with discovery verdict returns
Jashk120 Nov 29, 2026
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 src/Nethermind/Nethermind.Init/Modules/DiscoveryModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ protected override void Load(ContainerBuilder builder)
.AddSingleton<ITrustedNodesManager, ILogManager>((logManager) =>
new TrustedNodesManager(initConfig.TrustedNodesPath.GetApplicationResourcePath(initConfig.DataDir), logManager))

// Backs the discovery subnet limiter's managed exemptions. Slim hosts without this
// registration (e.g. the bootnode) run the limiter without managed exemptions;
// flag-based exemptions (IsStatic/IsTrusted) still apply.
.AddSingleton<IDiscoveryNodeExemptions, IStaticNodesManager, ITrustedNodesManager, INetworkConfig, ILogManager>((staticNodes, trustedNodes, networkConfig, logManager) =>
new ManagedNodeExemptions(staticNodes, trustedNodes, networkConfig, logManager))

.Bind<INodeSource, IStaticNodesManager>()
.Bind<INodeSource, ITrustedNodesManager>()

Expand Down
3 changes: 2 additions & 1 deletion src/Nethermind/Nethermind.Kademlia/BucketAddResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public enum BucketAddResult
{
Added,
Refreshed,
Full
Full,
Rejected

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] A rejected endpoint change can cancel the liveness check for the endpoint the table retains. While a probe to incumbent A is pending, the same identity can complete a separate discv4 bond at B. NodeHealthTracker.OnIncomingMessageFrom clears the pending refresh by identity before the new Rejected result leaves A in the table, then clears the failure count too. If A times out, RefreshAsync skips removal because B already cleared the marker. Lookups keep returning A and its subnet charge remains occupied. Clear liveness state only when the update is accepted or the message proves liveness at the retained endpoint.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 337f676. NodeHealthTracker.OnIncomingMessageFrom (NodeHealthTracker.cs:128-135) clears _isRefreshing and _peerFailures only when addResult != Rejected — a refused endpoint change at B leaves the pending refresh and failure count for retained A intact, so A's timeout still evicts it and frees the slot and charge

}
3 changes: 2 additions & 1 deletion src/Nethermind/Nethermind.Kademlia/IKademlia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public interface IKademlia<TKey, TNode>
/// Adds a node to the routing table or refreshes its position when it is already present.
/// </summary>
/// <param name="node">Node to add or refresh.</param>
void AddOrRefresh(TNode node);
/// <returns>The routing-table verdict for <paramref name="node"/>.</returns>
BucketAddResult AddOrRefresh(TNode node);

/// <summary>
/// Removes a node from the routing table.
Expand Down
3 changes: 2 additions & 1 deletion src/Nethermind/Nethermind.Kademlia/INodeHealthTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Nethermind.Kademlia;

public interface INodeHealthTracker<TNode>
{
void OnIncomingMessageFrom(TNode sender);
/// <returns>The routing-table verdict for <paramref name="sender"/>.</returns>
BucketAddResult OnIncomingMessageFrom(TNode sender);
void OnRequestFailed(TNode node);
}
37 changes: 37 additions & 0 deletions src/Nethermind/Nethermind.Kademlia/IRoutingTableNodeLimiter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-FileCopyrightText: 2026 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

namespace Nethermind.Kademlia;

/// <summary>
/// Admission policy for nodes entering the routing table.
/// </summary>
/// <remarks>
/// Lock order is routing-table lock, then limiter lock. <see cref="TryAdmit"/> is called under the routing-table
/// lock, so an implementation must not call back into the table. The bucket scan receives the bucket's cached array,
/// which allocates only when the bucket size exceeds the replacement cache size.
/// </remarks>
public interface IRoutingTableNodeLimiter<TNode>
{
/// <summary>Admits <paramref name="node"/> to the bucket whose active entries are <paramref name="bucketNodes"/>.</summary>
/// <remarks>Called under the routing-table lock. Must not call back into the table. An exempt verdict releases
/// any charge the node previously held, so a node that gains an exemption stops consuming its subnet slot.</remarks>
bool TryAdmit(TNode node, ReadOnlySpan<TNode> bucketNodes);

/// <summary>Releases the slot held by <paramref name="node"/>, if any. Idempotent.</summary>
void Release(TNode node);

/// <summary>Table-wide probe: whether <see cref="TryAdmit"/> would find a table slot. Does not reserve.</summary>
bool WouldAdmit(TNode node);

/// <summary>
/// Bucket-scoped probe: whether <see cref="TryAdmit"/> would admit <paramref name="node"/> to the bucket
/// whose active entries are <paramref name="bucketNodes"/>. Pure check: never charges, releases, or
/// mutates limiter state.
/// </summary>
/// <remarks>
/// The default implementation falls back to the table-wide <see cref="WouldAdmit"/> probe.
/// Called under the routing-table lock. Must not call back into the table.
/// </remarks>
bool ProbeAdmit(TNode node, ReadOnlySpan<TNode> bucketNodes) => WouldAdmit(node);
}
33 changes: 25 additions & 8 deletions src/Nethermind/Nethermind.Kademlia/KBucket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,33 @@ public BucketAddResult TryAddOrRefresh(in TKadKey hash, TNode item, out TNode? t

internal int CopyAllWithHash((TKadKey Hash, TNode Node)[] destination) => _items.CopyAllWithKey(destination);

public bool RemoveAndReplace(in TKadKey hash)
public bool Remove(in TKadKey hash)
{
if (!_items.Remove(hash)) return false;

if (_replacement.TryPopHead(out TKadKey replacementHash, out TNode? replacement))
{
_items.AddOrRefresh(replacementHash, replacement!);
}
UpdateCachedArray();
return true;
}

if (_cacheItems)
/// <summary>
/// Promotes the most recently cached replacement that <paramref name="canPromote"/> accepts, retaining the
/// candidates it rejects.
/// </summary>
/// <param name="canPromote">Admission predicate for a candidate, or <see langword="null"/> to accept the first.</param>
/// <returns><see langword="true"/> when a replacement was promoted.</returns>
public bool TryPromote(Func<TNode, bool>? canPromote)
{
foreach ((TKadKey replacementHash, TNode replacement) in _replacement.GetAllWithKey())
{
_cachedArray = _items.GetAll();
if (canPromote is not null && !canPromote(replacement)) continue;

_replacement.Remove(replacementHash);
_items.AddOrRefresh(replacementHash, replacement);
UpdateCachedArray();
return true;
}

return true;
return false;
}

public void Clear()
Expand All @@ -87,6 +99,11 @@ public void Clear()
internal bool TryGetStored(in TKadKey hash, [MaybeNullWhen(false)] out TNode node)
=> _items.TryGetValue(hash, out node) || _replacement.TryGetValue(hash, out node);

private void UpdateCachedArray()
{
if (_cacheItems) _cachedArray = _items.GetAll();
}

private static bool ShouldUpdateCachedArray(TNode? previous, TNode item)
=> previous is not null &&
(typeof(TNode).IsValueType
Expand Down
118 changes: 93 additions & 25 deletions src/Nethermind/Nethermind.Kademlia/KBucketTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ private class TreeNode(int k, TKadKey prefix)
private readonly TKadKey _currentNodeHash;
private readonly IKademliaDistance<TKadKey> _distance;
private readonly Func<TNode, TNode, TNode>? _mergeOnRefresh;
private readonly IRoutingTableNodeLimiter<TNode>? _limiter;
private readonly ILogger _logger;

private readonly Lock _lock = new();
Expand All @@ -54,6 +55,7 @@ public KBucketTree(
_distance = distance;
_currentNodeHash = nodeHashProvider.GetHash(config.CurrentNodeId);
_mergeOnRefresh = config.MergeOnRefresh;
_limiter = config.NodeLimiter;
_root = new TreeNode(config.KSize, distance.Zero);
_logger = loggerFactory.CreateLogger<KBucketTree<TNode, TKadKey>>();
if (_logger.IsEnabled(LogLevel.Trace)) _logger.LogTrace($"Initialized KBucketTree with k={_k}, currentNodeId={_currentNodeHash}");
Expand All @@ -63,25 +65,19 @@ public BucketAddResult TryAddOrRefresh(in TKadKey nodeHash, TNode node, out TNod
{
BucketAddResult resp;
bool fireAdded;
TNode nodeToStore = node;
TNode nodeToStore;
IRoutingTableNodeLimiter<TNode>? limiter = _limiter;
lock (_lock)
{
ThrowIfMergeReentered();
KBucket<TNode, TKadKey> bucket = GetBucketForHash(nodeHash);
if (_mergeOnRefresh is not null && bucket.TryGetStored(nodeHash, out TNode? previous))
resp = TryAddOrRefreshLocked(nodeHash, node, out nodeToStore, out toRefresh, out fireAdded);
if (resp == BucketAddResult.Full)
{
_isMergingRefresh = true;
try
{
nodeToStore = _mergeOnRefresh(nodeToStore, previous);
}
finally
{
_isMergingRefresh = false;
}
// The node landed in the replacement cache, not the table: release the
// charge so only active entries count. Full implies the key was absent
// from the active set, so this cannot release a live slot.
limiter?.Release(nodeToStore);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] A replacement-cache insertion can make NodeSource drop an eligible candidate even though active subnet occupancy stays at nine. In a full unsplittable leaf, TryAdmit publishes the tenth charge and unlocks the limiter before the bucket returns Full and the tree releases the charge. The candidate consumer takes only the limiter lock, so an already queued, uncharged candidate can be filtered in that interval. Its identity remains reserved in RecentNodeFilter after the drop. Check eligibility without charging an absent key in a full unsplittable leaf, and charge it when promoted.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a9bffc6. A full unsplittable leaf now uses ProbeAdmit (DiscoveryNodeLimiter.cs:151-159) — a pure check under the limiter lock with no mutation and no charge — and parks the candidate uncharged; the charge happens only when promotion admits it. The consumer's WouldAdmit window can no longer observe a phantom tenth charge.

}

resp = TryAddOrRefreshLocked(nodeHash, nodeToStore, out toRefresh, out fireAdded);
}

if (fireAdded) OnNodeAdded?.Invoke(this, nodeToStore);
Expand All @@ -91,6 +87,7 @@ public BucketAddResult TryAddOrRefresh(in TKadKey nodeHash, TNode node, out TNod
private BucketAddResult TryAddOrRefreshLocked(
in TKadKey nodeHash,
TNode node,
out TNode nodeToStore,
out TNode? toRefresh,
out bool fireAdded)
{
Expand All @@ -105,22 +102,88 @@ private BucketAddResult TryAddOrRefreshLocked(
if (current.IsLeaf)
{
if (_logger.IsEnabled(LogLevel.Trace)) _logger.LogTrace($"Reached leaf node at depth {depth}");
BucketAddResult resp = current.Bucket.TryAddOrRefresh(nodeHash, node, out toRefresh);
fireAdded = resp == BucketAddResult.Added;
if (resp is BucketAddResult.Added or BucketAddResult.Refreshed)
{
if (_logger.IsEnabled(LogLevel.Trace)) _logger.LogTrace($"Successfully added/refreshed node {node} in bucket at depth {depth}");
return resp;
}

if (resp == BucketAddResult.Full && ShouldSplit(depth, logDistance))
// A new key that would overflow a splittable leaf belongs in a post-split child:
// split first so the limiter only ever sees the final bucket, which may be empty.
if (!current.Bucket.ContainsNode(nodeHash) && current.Bucket.Count >= _k && ShouldSplit(depth, logDistance))
{
if (_logger.IsEnabled(LogLevel.Trace)) _logger.LogTrace($"Splitting bucket at depth {depth}");
SplitBucket(depth, current);
continue;
}

if (_logger.IsEnabled(LogLevel.Trace)) _logger.LogTrace($"Failed to add node {nodeHash} {node}. Bucket at depth {depth} is full. {_k} {current.Bucket.Count}");
// A full unsplittable leaf can only park an absent key in the replacement cache, which
// holds no charge until promotion. Probe without charging so a transient charge never
// becomes visible to the limiter-lock-only WouldAdmit consumer between TryAdmit and
// the Full release. Promotion via TryAdmit charges on a free slot.
if (_limiter is not null
&& !current.Bucket.ContainsNode(nodeHash)
&& current.Bucket.Count >= _k
&& !ShouldSplit(depth, logDistance))
{
if (!_limiter.ProbeAdmit(node, current.Bucket.GetAllCached()))
{
if (_logger.IsEnabled(LogLevel.Trace)) _logger.LogTrace($"Subnet limiter rejected node {node}");
nodeToStore = node;
toRefresh = default;
fireAdded = false;
return BucketAddResult.Rejected;
}

nodeToStore = node;
if (_mergeOnRefresh is not null && current.Bucket.TryGetStored(nodeHash, out TNode? previousUncharged))
{
_isMergingRefresh = true;
try
{
nodeToStore = _mergeOnRefresh(node, previousUncharged);
}
finally
{
_isMergingRefresh = false;
}
}

BucketAddResult unchargedResp = current.Bucket.TryAddOrRefresh(nodeHash, nodeToStore, out toRefresh);
fireAdded = unchargedResp == BucketAddResult.Added;
if (_logger.IsEnabled(LogLevel.Trace)) _logger.LogTrace($"Failed to add node {nodeHash} {nodeToStore}. Bucket at depth {depth} is full. {_k} {current.Bucket.Count}");
return unchargedResp;
}

if (_limiter is not null && !_limiter.TryAdmit(node, current.Bucket.GetAllCached()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] A DNS-fed endpoint change can replace the restart address even when subnet admission refuses it. If the DNS feeder supplies a newer verified ENR advertising only B for an incumbent at A, MergeOnRefresh installs that ENR in A's shared state before TryAdmit rejects B. The table retains A, but DiscoveryPersistenceManager writes the ENR for B under the same node ID. Restore then only tries B and loses A as a seed even if A still answers. Preserve the admitted UDP endpoint for restore when the saved ENR only advertises the refused endpoint.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in bc270a4. MergeOnRefresh now runs only after admission: both the charged path and the probe path check the limiter first, and a refused endpoint change returns Rejected

{
if (_logger.IsEnabled(LogLevel.Trace)) _logger.LogTrace($"Subnet limiter rejected node {node}");
nodeToStore = node;
toRefresh = default;
fireAdded = false;
return BucketAddResult.Rejected;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Subnet refusals can exhaust the discv4 DNS feeder before it adds any seed. With two ordinary peers from one public /24 already in the unsplit root, the next 50 compatible, reachable DNS records from that subnet can all return Rejected. NodeHealthTracker discards the result and NodeSourceToDiscV4Feeder increments addedNodes after each void call, so it stops before a later eligible record from a different subnet. Propagate the subnet refusal to the feeder so rejected entries do not spend its seed budget.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4d35ad0. IDiscoveryApp.AddNodeToDiscovery now returns whether the node was admitted, and the feeder skips addedNodes++ on false (NodeSourceToDiscV4Feeder.cs:50-55); CompositeDiscoveryApp broadcasts then ORs over its app snapshot

}

// Merge only after admission: the merge may share mutable state with the
// stored entry (e.g. Node ENR state), so a rejected endpoint change must
// not clobber the admitted endpoint that restore still needs.
nodeToStore = node;
if (_mergeOnRefresh is not null && current.Bucket.TryGetStored(nodeHash, out TNode? previous))
{
_isMergingRefresh = true;
try
{
nodeToStore = _mergeOnRefresh(node, previous);
}
finally
{
_isMergingRefresh = false;
}
}

BucketAddResult resp = current.Bucket.TryAddOrRefresh(nodeHash, nodeToStore, out toRefresh);
fireAdded = resp == BucketAddResult.Added;
if (resp is BucketAddResult.Added or BucketAddResult.Refreshed)
{
if (_logger.IsEnabled(LogLevel.Trace)) _logger.LogTrace($"Successfully added/refreshed node {nodeToStore} in bucket at depth {depth}");
return resp;
}

if (_logger.IsEnabled(LogLevel.Trace)) _logger.LogTrace($"Failed to add node {nodeHash} {nodeToStore}. Bucket at depth {depth} is full. {_k} {current.Bucket.Count}");
return resp;
}

Expand Down Expand Up @@ -199,7 +262,12 @@ public bool Remove(in TKadKey nodeHash)

KBucket<TNode, TKadKey> bucket = GetBucketForHash(nodeHash);
removedNode = bucket.GetByHash(nodeHash);
removed = bucket.RemoveAndReplace(nodeHash);
removed = bucket.Remove(nodeHash);
if (removed)
{
if (removedNode is not null) _limiter?.Release(removedNode);
bucket.TryPromote(node => _limiter is null || _limiter.TryAdmit(node, bucket.GetAllCached()));
}
}

if (removed && removedNode is not null) OnNodeRemoved?.Invoke(this, removedNode);
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Kademlia/Kademlia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public Kademlia(

public TNode CurrentNode => _currentNodeId;

public void AddOrRefresh(TNode node) => _nodeHealthTracker.OnIncomingMessageFrom(node);
public BucketAddResult AddOrRefresh(TNode node) => _nodeHealthTracker.OnIncomingMessageFrom(node);

public void Remove(TNode node) => _routingTable.Remove(_keyOperator.GetNodeHash(node));

Expand Down
12 changes: 12 additions & 0 deletions src/Nethermind/Nethermind.Kademlia/KademliaConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ public class KademliaConfig<TNode>
/// <remarks>
/// The merge must return promptly, must not perform I/O or mutate the routing table that invoked it, and must not
/// acquire a lock that callers can hold while entering that routing table (which would invert the lock order).
/// The merge runs only after the node limiter admits the incoming value, so a rejected endpoint change
/// cannot mutate the stored entry's shared state.
/// </remarks>
public Func<TNode, TNode, TNode>? MergeOnRefresh { get; set; }

/// <summary>
/// Optional admission policy consulted before a node takes a slot in the routing table. The default,
/// <see langword="null"/>, admits every node.
/// </summary>
/// <remarks>
/// The routing table calls <see cref="IRoutingTableNodeLimiter{TNode}.TryAdmit"/> while holding its own lock, so an
/// implementation must not call back into the table; the lock order is routing-table lock, then limiter lock.
/// </remarks>
public IRoutingTableNodeLimiter<TNode>? NodeLimiter { get; set; }
}
20 changes: 15 additions & 5 deletions src/Nethermind/Nethermind.Kademlia/NodeHealthTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ private async Task RefreshAsync(TNode toRefresh, TKadKey nodeHash, CancellationT
/// Call when an incoming message from a node is received. This is used by other algorithm for health checks.
/// </summary>
/// <param name="node"></param>
public void OnIncomingMessageFrom(TNode node)
/// <returns>The routing-table verdict for <paramref name="node"/>.</returns>
public BucketAddResult OnIncomingMessageFrom(TNode node)
{
_isRefreshing.TryRemove(nodeHashProvider.GetHash(node), out _);

BucketAddResult addResult = routingTable.TryAddOrRefresh(nodeHashProvider.GetHash(node), node, out TNode? toRefresh);
TKadKey nodeHash = nodeHashProvider.GetHash(node);
BucketAddResult addResult = routingTable.TryAddOrRefresh(nodeHash, node, out TNode? toRefresh);
if (addResult == BucketAddResult.Full && toRefresh is not null)
{
if (SameAsSelf(toRefresh))
Expand All @@ -124,7 +124,17 @@ public void OnIncomingMessageFrom(TNode node)
TryRefresh(toRefresh);
}
}
_peerFailures.Delete(nodeHashProvider.GetHash(node));

if (addResult != BucketAddResult.Rejected)
{
// A rejected endpoint leaves the retained entry untouched, so it proves nothing about
// that entry's liveness. Keep any pending refresh and the failure count so the retained
// endpoint can still be evicted.
_isRefreshing.TryRemove(nodeHash, out _);
_peerFailures.Delete(nodeHash);
}

return addResult;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ public interface INetworkConfig : IConfig
[ConfigItem(DefaultValue = "true", Description = "When filtering by recent IP, bucket peers by subnet (e.g., IPv4 /24, IPv6 /64) so multiple IPs in the same subnet share a single entry. If false, use exact IP addresses only.")]
bool FilterPeersBySameSubnet { get; set; }

[ConfigItem(DefaultValue = "true", Description = "Reject discovery nodes whose IP key was seen recently (time-windowed), using the peer IP filter.")]
[ConfigItem(DefaultValue = "true", Description = "Limit discovery table entries per subnet key (2/bucket, 10/table, LAN bypassed).")]
bool FilterDiscoveryNodesByRecentIp { get; set; }

[ConfigItem(DefaultValue = "true", Description = "When filtering discovery nodes by recent IP, bucket discovery node IPs by subnet (e.g., IPv4 /24, IPv6 /64) so multiple discovery node IPs in the same subnet share a single entry. If false, use exact IP addresses only.")]
[ConfigItem(DefaultValue = "true", Description = "When limiting discovery nodes, bucket public IPs by subnet (IPv4 /24, IPv6 /64); LAN addresses bypass the limit (2/bucket, 10/table).")]
bool FilterDiscoveryNodesBySameSubnet { get; set; }
}
3 changes: 2 additions & 1 deletion src/Nethermind/Nethermind.Network.Core/IDiscoveryApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Nethermind.Network
public interface IDiscoveryApp : INodeSource, IStoppableService
{
Task StartAsync();
void AddNodeToDiscovery(Node node);
/// <returns>True when the node was admitted and should count against feeder budgets; false when it was refused or skipped.</returns>
bool AddNodeToDiscovery(Node node);
}
}
Loading
Loading