Skip to content

Remove temporary channels#4595

Merged
pwojcikdev merged 20 commits intonanocurrency:developfrom
pwojcikdev:networking-fixes/connecting-4
May 4, 2024
Merged

Remove temporary channels#4595
pwojcikdev merged 20 commits intonanocurrency:developfrom
pwojcikdev:networking-fixes/connecting-4

Conversation

@pwojcikdev
Copy link
Copy Markdown
Contributor

Our current networking design is strange in this aspect, that we treat connections accepted by our node (temporary channels) differently to connections that are initiated by our node. There is no fundamental reason for such behavior, TCP allows for bidirectional communication and doing so may lead to more robust network, since some peers aren't directly reachable (NAT, firewalls).

The logic for handling those temporary channels was also not great, it created a new channel for each processed message which led to inefficiencies, especially when paired with fair queuing. Look at nano::transport::tcp_channels::process_message (...). It also used node id for channel lookup when processing messages. Here I'm associating each realtime connection with a single channel, without relying on node id, which is simpler and more robust approach.

This PR moves management of lower-level connections fully to tcp_listener and implements them using coroutines. Each connection attempt is given a timeout (by default 60 seconds) and node id conflicts are only rejected for same IP addresses.

Previous attempt to fix this issue was #3928

@qwahzi qwahzi added this to the V27 milestone Apr 30, 2024
{
nano::test::system system;
auto node = add_ipc_enabled_node (system);
// Add node2 first to avoid peers with ephemeral ports
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.

How does changing the order avoid ephemeral ports?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The way tests setup nodes is that second node connects to the first one. Connection is initiated from ephemeral port to a specific listening port. Here we can only predict the listening port, so node needs to connect to node2.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If there is a better way I'll be happy to change it. I wanted to get it working without removing asserts.

@pwojcikdev pwojcikdev merged commit 958c6ea into nanocurrency:develop May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Merged / V27.0

Development

Successfully merging this pull request may close these issues.

3 participants