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

WIP: Updates due to the addition of handshake queries #5100

Conversation

jprider63
Copy link
Contributor

This makes a few updates given API changes from the addition of handshake queries (IntersectMBO/ouroboros-network#3907). Additional changes are likely, but I started running into compilation mismatches with ouroboros-network. It looks like the index-state now points to cardano-haskell-packages 2023-04-13T17:16:53Z on master. Is there a way to tell which ouroboros-network commit this corresponds to?

The corresponding ouroboros-network PR is here: IntersectMBO/ouroboros-network#4256

bolt12 and others added 5 commits April 19, 2023 12:59
Adds new flag 'PeerSharing' can have 3 possible values:

- `NoPeerSharing`
- `PeerSharingPrivate`
- `PeerSharingPublic`

This flag interacts with `PeerAdvertise` values in the following way:

`AdvertisePeer` is local to the configuration of a given node. A node
can be willing to share those peers that it has configured as
`PeerAdvertise`. However `PeerSharing` is about wether or not the peer
(itself) wishes to participate on `PeerSharing` or not or if it allows
others to share its address to others.

`PeerSharing` has priority over `AdvertisePeer`, example:

BP has `NoPeerSharing` flag (meaning it won't participate in Peer
Sharing, not even run the miniprotocol). Relay has BP as local peer
configured as `AdvertisePeer` (probably misconfigured it) When handshake
between the BP and the Relay happens the Relay is going to see that BP
does not wish to participate in PeerSharing and so it is not going to
perform peer sharing with it nor share it to others.

Here is the `combinePeerInformation` function that decides the sharing
interaction semantics between the two flags.

```
-- Combine a 'PeerSharing' value and a 'PeerAdvertise' value into a
-- resulting 'PeerSharing' that can be used to decide if we should
-- share or not the given Peer. According to the following rules:
--
-- - If no PeerSharing value is known then there's nothing we can assess
-- - If a peer is not participating in Peer Sharing ignore all other information
-- - If a peer said it wasn't okay to share its address, respect that no matter what.
-- - If a peer was privately configured with DoNotAdvertisePeer respect that no matter
-- what.
--
combinePeerInformation :: PeerSharing -> PeerAdvertise -> PeerSharing
combinePeerInformation NoPeerSharing      _                  = NoPeerSharing
combinePeerInformation PeerSharingPrivate _                  = PeerSharingPrivate
combinePeerInformation PeerSharingPublic  DoNotAdvertisePeer = PeerSharingPrivate
combinePeerInformation _                         _           = PeerSharingPublic
```

And this is the function that is used to filter the result list:
https://github.com/input-output-hk/ouroboros-network/blob/master/ouroboros-network/src/Ouroboros/Network/PeerSelection/KnownPeers.hs#L394

Also relevant:
https://github.com/input-output-hk/ouroboros-network/blob/master/ouroboros-network/src/Ouroboros/Network/Diffusion/P2P.hs#L1014
@jprider63 jprider63 force-pushed the 3907-handshake-parameters branch from ab09b2e to 12cc3d9 Compare April 20, 2023 03:10
@jprider63 jprider63 requested review from a team, coot, fmaste and cleverca22 as code owners April 20, 2023 03:10
@jprider63 jprider63 changed the base branch from master to bolt12/peer-sharing April 20, 2023 03:13
@coot coot force-pushed the bolt12/peer-sharing branch 3 times, most recently from bb13756 to 7e46b10 Compare April 25, 2023 11:18
@coot coot force-pushed the bolt12/peer-sharing branch from 7e46b10 to 278501e Compare April 28, 2023 07:26
@iohk-bors iohk-bors bot deleted the branch IntersectMBO:bolt12/peer-sharing April 28, 2023 09:15
@iohk-bors iohk-bors bot closed this Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants