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

Modify connection manager state data type #5017

Merged
merged 15 commits into from
Dec 11, 2024
Merged

Conversation

coot
Copy link
Contributor

@coot coot commented Nov 29, 2024

Description

We used to identify connections just be remote IP address and its port, but
since we bind to 0.0.0.0, this is not good enough. We might get two
connections from the same remote host to different interfaces (or the same
interface but a different IP). Such connections wouldn't be distinguished. For
this reason we switch the internal data type to something isomorphic to

-- map from remote address, maybe local address to connection data
Map peerAddr (Map (Maybe peerAddr) connectionData)

The reason we use Maybe is that we insert outbound connections before we know
their local address.

  • connection-manager: moved ConnectionState to its own module
  • connection-manager: use strict map
  • connection-manager: identify connections by local & remote address
  • connection-manager: small code refactoring
  • connection-manager: updated ouroboros-network-framework tests & demos
  • connection-manager: fixed tests
  • connection-manager: added TODO
  • inbound-governor: handle unknown connection
  • inbound-governor: changed order of events
  • connection-manager: removed IOSimPOR unit test
  • connection-manager: improve test trace
  • connection-manager: trace state changes through traceTMVar

Checklist

Quality

  • Commit sequence makes sense and have useful messages, see ref.
  • New tests are added and existing tests are updated.
  • Self-reviewed the PR.

Maintenance

  • Linked an issue or added the PR to the current sprint of ouroboros-network project.
  • Added labels.
  • Updated changelog files.
  • The documentation has been properly updated, see ref.

@coot coot requested a review from a team as a code owner November 29, 2024 14:12
@coot coot added the connection-manager Issues / PRs related to connection-manager label Nov 29, 2024
@coot coot self-assigned this Nov 29, 2024
@coot coot force-pushed the coot/connection-manager-state branch 2 times, most recently from 53c6ff0 to 60e1235 Compare December 2, 2024 17:02
Copy link
Contributor

@bolt12 bolt12 left a comment

Choose a reason for hiding this comment

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

Nice PR!

coot and others added 11 commits December 10, 2024 22:02
On Linux when a server listens on a given (addr, port), and we connect
a socket which is bound to the same address:

* the accept call never returns
* the connect returns, and the socket acts as a mirror: whatever is sent
  over it, can be received from it.

This patch implements the same behaviour of simulated snockets.  It also
provides a test which verifies it.
Connections in side connection manager state must be identified by their
`ConnectionId`.  Since the state map also reserves places for outbound
connections for which we only know the remote address the state is
slightly more general than `Map (ConnectionId peerAddr) ...`.

The data type used by the state is provided in
`Ouroboros.Network.ConnectionManager.ConnMap` module, the
`Ouroboros.Network.ConnectionManager.State` module provides type alias
for the state type and additional APIs needed by the connection manager.
Can we remove the transition tracer, since we use `traceTVar` in
`newMutableConnState`?
IOSimPOR discovered that a connection can be removed from the connection
manager (by the connection clean-up function), while it is promoted to
warm remote.
It wasn't enough to fix IOSimPOR issue fixed in the previous commit.
@coot coot force-pushed the coot/connection-manager-state branch from 9dbbd0d to 2cfc7fb Compare December 10, 2024 21:05
coot added 4 commits December 10, 2024 23:17
The fixed schedule doesn't satisfy IOSimPOR invariants anymore.
Note that this is only effective in `IOSim`.
It's useful to provide not only the transitions that didn't match, but
also the time and the server name to make it easier to locate the
transition in a trace.
@coot coot force-pushed the coot/connection-manager-state branch from 2cfc7fb to e73179a Compare December 10, 2024 22:17
@coot coot added this pull request to the merge queue Dec 11, 2024
Merged via the queue into main with commit cb7af71 Dec 11, 2024
12 checks passed
@coot coot deleted the coot/connection-manager-state branch December 11, 2024 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
connection-manager Issues / PRs related to connection-manager
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants