From 5742299c94a35bb3a70a03bd297ccd66d73e8066 Mon Sep 17 00:00:00 2001 From: cheatfate Date: Thu, 20 Feb 2020 09:34:06 +0200 Subject: [PATCH] Fix freezes in connection initialization. --- beacon_chain/libp2p_backend.nim | 4 ++++ beacon_chain/sync_protocol.nim | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/beacon_chain/libp2p_backend.nim b/beacon_chain/libp2p_backend.nim index 87e384a2a..18a54d7da 100644 --- a/beacon_chain/libp2p_backend.nim +++ b/beacon_chain/libp2p_backend.nim @@ -188,7 +188,10 @@ proc dialPeer*(node: Eth2Node, peerInfo: PeerInfo) {.async.} = discard await node.switch.dial(peerInfo) var peer = node.getPeer(peerInfo) peer.wasDialed = true + debug "Initializing connection" await initializeConnection(peer) + debug "Subscribing to pubsub" + await peer.network.switch.subscribeToPeer(peer.info) inc libp2p_successful_dials debug "Network handshakes completed" @@ -201,6 +204,7 @@ proc runDiscoveryLoop*(node: Eth2Node) {.async.} = if currentPeerCount < node.wantedPeers: try: let discoveredPeers = await node.discovery.lookupRandom() + debug "Discovered peers", peer = $discoveredPeers for peer in discoveredPeers: debug "Discovered peer", peer = $peer try: diff --git a/beacon_chain/sync_protocol.nim b/beacon_chain/sync_protocol.nim index f94fbaaea..48e5f1bf2 100644 --- a/beacon_chain/sync_protocol.nim +++ b/beacon_chain/sync_protocol.nim @@ -163,7 +163,7 @@ proc handleInitialStatus(peer: Peer, # will allow us to implement the subscription earlier. # The root of the problem is that both sides must call `subscribeToPeer` # before any GossipSub traffic will flow between them. - await peer.network.switch.subscribeToPeer(peer.info) + discard if theirStatus.forkVersion != state.forkVersion: notice "Irrelevant peer",