Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve connected peer distribution #7026

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Improve connected peer distribution #7026

wants to merge 9 commits into from

Conversation

benaadams
Copy link
Member

@benaadams benaadams commented May 15, 2024

Changes

  • Disfavour nodes with same ip addresses of nodes tried recently
  • Reject peers with differing udp and tcp ports as we only store 1 port per peer so need to be the same

Types of changes

What types of changes does your code introduce?

  • Optimization

Testing

Requires testing

  • Yes

If yes, did you write tests?

  • Yes

@benaadams benaadams marked this pull request as ready for review May 15, 2024 18:55
if (node.Address.Address == _localhost)
{
if (_logger.IsTrace)
_logger.Trace($"Received localhost as node address from: {msg.FarPublicKey}, node: {node}");
continue;
}
else if (!NetworkStorage.NodesFilter.Set(node.Address.Address))
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this should be better placed in DiscoveryManager.

@@ -17,10 +20,13 @@ namespace Nethermind.Network
{
public class NetworkStorage : INetworkStorage
{
public static LruKeyCache<IPAddress> NodesFilter { get; } = new(2048, "Ip Filter");
Copy link
Contributor

Choose a reason for hiding this comment

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

Please refrain from static. It breaks encapsulation.

@flcl42
Copy link
Contributor

flcl42 commented May 19, 2024

Might be better to store both ports. There is no agreement about having same ports; same ports may be easier to detect by ISP/bad actors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants