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

feat: avoid duplicate autoconnection attempt #1742

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

wyfo
Copy link
Contributor

@wyfo wyfo commented Jan 27, 2025

Gossip autoconnection could result in two nodes attempting to connect to each other concurrently.
To fix this issue, only one node initiate the connection now. The selection criteria is arbitrary but deterministic, currently the greater zid of both.

Gossip autoconnection could result in two nodes attempting to connect
to each other concurrently.
To fix this issue, only one node initiate the connection now. The
selection criteria is arbitrary but deterministic, currently the
greater zid of both.
@wyfo wyfo added the enhancement Existing things could work better label Jan 27, 2025
@wyfo wyfo requested a review from OlivierHecart January 27, 2025 21:25
Comment on lines 513 to 516
if !self.autoconnect.is_empty()
&& self.autoconnect.matches(whatami)
&& select_autoconnect_node(self.graph[self.idx].zid, zid)
{
Copy link
Contributor

@oteffahi oteffahi Jan 28, 2025

Choose a reason for hiding this comment

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

This is a more complex problem than what it seems. Consider the following:

  • Node1 is a peer, it is setup to autoconnect to routers and peers.
  • Node2 is a router, it is setup to autoconnect only to routers.
  • Node2 has a higher ZID, and therefore is the one returned by select_autoconnect_node.
    In thise case, Node1 will not attempt to connect because it is not the selected node, and Node2 will not autoconnect because it does not have peers in its autoconnect config, and the connection will never be established...

Copy link
Contributor

@oteffahi oteffahi Jan 28, 2025

Choose a reason for hiding this comment

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

Unless we add autoconnect config to the exchanged gossip information, the other solutions may involve closing one of the two links during or after opening the transport.

Copy link
Contributor

@oteffahi oteffahi left a comment

Choose a reason for hiding this comment

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

Typos and missing comments

DEFAULT_CONFIG.json5 Outdated Show resolved Hide resolved
DEFAULT_CONFIG.json5 Outdated Show resolved Hide resolved
@wyfo wyfo requested a review from oteffahi January 31, 2025 09:16
DEFAULT_CONFIG.json5 Outdated Show resolved Hide resolved
DEFAULT_CONFIG.json5 Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Existing things could work better
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants