Skip to content

Conversation

@heifner
Copy link
Contributor

@heifner heifner commented Apr 1, 2025

Fix for an issue where net_plugin would allow some duplicate connections to remain open.

Simplified to just checking both incoming and outgoing connections for duplicate.

Resolves #1255

@heifner heifner added the OCI Work exclusive to OCI team label Apr 1, 2025
@heifner heifner requested review from greg7mdp and linh2931 April 2, 2025 12:29
else
peer_dlog(this, "Invalid handshake p2p_address ${p}", ("p", msg.p2p_address));
} else {
// check if peer requests no trx or no blocks
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is a little confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

fc_dlog( logger, "not duplicate, my_impl->node_id '${lhs}' < msg.node_id '${rhs}'",
("lhs", my_impl->node_id)("rhs", msg.node_id) );
// only the connection from lower node_id to higher node_id will be considered as a duplicate,
// so there is no chance for both connections to be closed
Copy link
Contributor

Choose a reason for hiding this comment

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

The is simpler than the complicated prior version.

@greg7mdp
Copy link
Contributor

greg7mdp commented Apr 2, 2025

I wonder if it would not be preferable to do the duplicate connection check when (msg.generation >= 1) (instead of ==)?

};
if (my_impl->connections.any_of_connections(is_duplicate)) {
peer_dlog( this, "sending go_away duplicate, msg.p2p_address: ${add}", ("add", msg.p2p_address) );
go_away_message gam(duplicate);
Copy link
Contributor

@greg7mdp greg7mdp Apr 2, 2025

Choose a reason for hiding this comment

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

I don't think the constructor of go_away_message serves any useful purpose, and makes the code (here at least) more awkward. Without it we could do:
enqueue(go_away_message{duplicate, conn_node_id});
which I think is clearer.

Copy link
Contributor

Choose a reason for hiding this comment

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

bonus point if making go_away_reason an enum class :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@heifner
Copy link
Contributor Author

heifner commented Apr 2, 2025

Seems excessive to check on every handshake message.

I think the cost is probaly negligeable, but OK.

@heifner heifner merged commit bb2cc1b into main Apr 3, 2025
36 checks passed
@heifner heifner deleted the GH-1255-dup-connection branch April 3, 2025 13:42
@ericpassmore
Copy link
Contributor

Note:start
category: Other
component: P2P
summary: Fix for an issue where net_plugin would allow some duplicate connections to remain open.
Note:end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCI Work exclusive to OCI team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

P2P: Fix duplicate connection logic

5 participants