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

[Issue 1278] Rework static peer discovery handling #1292

Conversation

mbaxter
Copy link
Contributor

@mbaxter mbaxter commented Aug 11, 2020

PR description

Rework discovery-level handling of static peers to fix a few issues:

  • Make sure that permissions are respected when pushing static peers into the discovery layer
  • Initiate ping-pong bonding cycle rather than directly adding peers to our peer table to ensure that peer is live and running discovery
  • Check that enode url indicates discovery protocol is running before attempting to bond with peer
  • Remove duplicate dropPeer logic

Fixed Issue(s)

Fixes #1278

Signed-off-by: Meredith Baxter <meredith.baxter@consensys.net>
Signed-off-by: Meredith Baxter <meredith.baxter@consensys.net>
Signed-off-by: Meredith Baxter <meredith.baxter@consensys.net>
Signed-off-by: Meredith Baxter <meredith.baxter@consensys.net>
Signed-off-by: Meredith Baxter <meredith.baxter@consensys.net>
@mbaxter mbaxter marked this pull request as ready for review August 11, 2020 03:17
@@ -265,6 +265,7 @@ public void awaitStop() {
@Override
public boolean addMaintainConnectionPeer(final Peer peer) {
final boolean wasAdded = maintainedPeers.add(peer);
peerDiscoveryAgent.bond(peer);
Copy link
Member

Choose a reason for hiding this comment

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

Does this mean that we require discovery to be enabled on peers that we want to add using static-nodes.json file or AddPeer API? Because I feel like most uses that are statically mapping their peers might not have discovery enabled (and might not want to).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No - we try to create a DiscoveryPeer to initiate bonding with. The DiscoveryPeer.from helper will only return a peer if discovery appears to be enabled. The bonding process consists of sending a PING to that peer, and waiting for a response. Only if the peer is running discovery and responds do we add the peer to our table. If the peer doesn't respond, we'll retry a few times and then stop.

Users can explicitly indicate that discovery is disabled by supplying enode urls with discport=0, which will cause us to skip the bonding attempt.

@mbaxter mbaxter merged commit 88ce796 into hyperledger:master Aug 11, 2020
@timbeiko timbeiko mentioned this pull request Aug 12, 2020
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.

Admin_addPeer publishes peers to discovery DHT without validating first
3 participants