diff --git a/beacon_chain/libp2p_backend.nim b/beacon_chain/libp2p_backend.nim index 18a54d7da..66fc9e1c2 100644 --- a/beacon_chain/libp2p_backend.nim +++ b/beacon_chain/libp2p_backend.nim @@ -188,10 +188,14 @@ 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) + + # TODO: This should happen automatically in the future in nim-libp2p debug "Subscribing to pubsub" await peer.network.switch.subscribeToPeer(peer.info) + inc libp2p_successful_dials debug "Network handshakes completed" diff --git a/beacon_chain/sync_protocol.nim b/beacon_chain/sync_protocol.nim index 48e5f1bf2..72ca79afc 100644 --- a/beacon_chain/sync_protocol.nim +++ b/beacon_chain/sync_protocol.nim @@ -156,15 +156,6 @@ proc handleInitialStatus(peer: Peer, state: BeaconSyncNetworkState, ourStatus: StatusMsg, theirStatus: StatusMsg) {.async, gcsafe.} = - when networkBackend == libp2p: - # TODO: This doesn't seem like an appropraite place for this call, - # but it's hard to pick a better place at the moment. - # nim-libp2p plans to add a general `onPeerConnected` callback which - # 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. - discard - if theirStatus.forkVersion != state.forkVersion: notice "Irrelevant peer", peer, theirFork = theirStatus.forkVersion, ourFork = state.forkVersion