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

[Gossipsub] Inconsistency in mesh peer tracking #2175

Closed
wants to merge 7 commits into from

Conversation

AgeManning
Copy link
Contributor

Peers that GRAFT to us without sending subscriptions for the grafted topic can be added to the mesh. These peers once disconnected, do then not get removed from the mesh. This creates a variety of inconsistencies.

This PR resolves this by adding the topics that a peer send us via grafts, to the peer_topics mapping, indicating that they are in fact subscribed to that topic. There should never be a case that a peer grafts us, without locally being subscribed to the topic.

In a similar vein, this improves the consistency of blacklisted peers that the user can add/remove at arbitrary times.

protocols/gossipsub/src/behaviour.rs Outdated Show resolved Hide resolved
@@ -2913,11 +2921,6 @@ where
connection_id: &ConnectionId,
endpoint: &ConnectedPoint,
) {
// Ignore connections from blacklisted peers.
Copy link
Member

Choose a reason for hiding this comment

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

Can you expand on why we no longer ignore blacklisted peers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found that in many cases we are under the assumption that any connected peer exists in connected_peers and their topic subscriptions exist in peer_topics. When peers disconnect we use these mappings to correctly remove them from the mesh and other mappings in the behaviour. If there is any inconsistencies, gossipsub panics (this PR fixes on such instance).

Although I haven't seen a panic from blacklisted peers (I'm not using them atm), i'm concerned about inconsistencies coming from states where users at arbitrary times blacklist and unblacklist (via the public functions) peers.

This change represents a safer approach where we register the connections of all peers, add them to the mappings (so they exist regardless of when the user ad-hoc add/removes them) but we still block all messages for whatever peers are blacklisted at the time we receive them. On disconnects, as all peers connections are registered they are removed from all mappings correctly, regardless of the current state of blacklisting.

There probably is a way we could do this without registering the connection, but I think there a quite a few edge cases and this makes it simpler to reason about.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks @AgeManning for the details!

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

Thanks @AgeManning for upstreaming the patch!

@mxinden
Copy link
Member

mxinden commented Aug 9, 2021

@AgeManning I don't have permissions to merge latest master via the UI. Could you either (a) grant me that permission or (b) merge yourself?

@AgeManning
Copy link
Contributor Author

Thanks @mxinden. In the future, I'll make these PRs fully accessible to you.

@paulhauner
Copy link

We're on a bit of a tight timeline over at sigp/lighthouse with a hard-fork happening on a public testnet next week. This is the last blocker before we can get a release candidate out.

I appreciate that the maintainers have their own priorities, I just wanted to make that known 🙂 As always, thanks for your efforts and I appreciate that reviews can take time 🙏

@mxinden
Copy link
Member

mxinden commented Aug 11, 2021

We're on a bit of a tight timeline over at sigp/lighthouse with a hard-fork happening on a public testnet next week. This is the last blocker before we can get a release candidate out.

I appreciate that the maintainers have their own priorities, I just wanted to make that known slightly_smiling_face As always, thanks for your efforts and I appreciate that reviews can take time pray

@paulhauner do I understand correctly that you only need this patch to be merged into master, or would you need a new release as well?

Patch will be merged through #2189 as I can't merge current master branch here.

@mxinden
Copy link
Member

mxinden commented Aug 11, 2021

Merged via #2189, thus closing here.

@mxinden mxinden closed this Aug 11, 2021
@paulhauner
Copy link

Thank you, much appreciated!

do I understand correctly that you only need this patch to be merged into master, or would you need a new release as well?

We're fine with targeting master for the time being. No rush to push a release :)

bors bot pushed a commit to sigp/lighthouse that referenced this pull request Aug 12, 2021
## Issue Addressed

- Resolves #2457
- Resolves #2443

## Proposed Changes

Target the (presently unreleased) head of `libp2p/rust-libp2p:master` in order to obtain the fix from libp2p/rust-libp2p#2175.

Additionally:

- `libsecp256k1` needed to be upgraded to satisfy the new version of `libp2p`.
- There were also a handful of minor changes to `eth2_libp2p` to suit some interface changes.
- Two `cargo audit --ignore` flags were remove due to libp2p upgrades.

## Additional Info
 
 NA
pawanjay176 pushed a commit to pawanjay176/lighthouse that referenced this pull request Aug 27, 2021
## Issue Addressed

- Resolves sigp#2457
- Resolves sigp#2443

## Proposed Changes

Target the (presently unreleased) head of `libp2p/rust-libp2p:master` in order to obtain the fix from libp2p/rust-libp2p#2175.

Additionally:

- `libsecp256k1` needed to be upgraded to satisfy the new version of `libp2p`.
- There were also a handful of minor changes to `eth2_libp2p` to suit some interface changes.
- Two `cargo audit --ignore` flags were remove due to libp2p upgrades.

## Additional Info
 
 NA
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.

3 participants