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

Delay the promotion of the peer from connecting to connected #3418

Merged
merged 5 commits into from
Nov 1, 2024

Conversation

vicsn
Copy link
Contributor

@vicsn vicsn commented Oct 22, 2024

Motivation

Replaces #3332
Original message:

A re-opening of #2690; there is also #2729 which I had considered to be a simpler alternative, but I believe that both changes are desirable (with this one going in first) for a more foolproof setup.

The Aleo network stack is two-tiered, and both the lower- and higher-level layers recognize that connections may have been started but not fully finalized yet, which corresponds to the "connecting" and "connected" states of connections and peers respectively.

This PR ensures that the lower networking layer is the first one to conclude its connection setup, which is done by marking the (higher-level) peers as "connected" only via OnConnect, which is triggered only after the lower-level layer has concluded all its work. To do this, the Peer object (instead of just the address) is persisted in the connecting_peers collection past the handshake, and moved to connected_peers only during OnConnect::on_connect.

Test Plan

The existing tests are adjusted to account for this; I've also tested it locally in a --dev network.

Fixes #3331 and all other potential issues of its kind (i.e. attempting to treat a connection as fully established before the lower-level TCP stack recognizes it as such).

Copy link
Collaborator

@zkxuerb zkxuerb left a comment

Choose a reason for hiding this comment

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

LGTM

@alzger alzger merged commit 40a2459 into AleoNet:staging Nov 1, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Abnormal disconnection caused by asynchronous Ping message
6 participants