diff --git a/beacon_chain/eth2_network.nim b/beacon_chain/eth2_network.nim index 5d4ba9ba1..189e0224e 100644 --- a/beacon_chain/eth2_network.nim +++ b/beacon_chain/eth2_network.nim @@ -156,7 +156,7 @@ when networkBackend in [libp2p, libp2pDaemon]: # are running behind a NAT). var switch = newStandardSwitch(some keys.seckey, hostAddress, triggerSelf = true, gossip = false) - result = Eth2Node.init(conf, switch, keys.seckey.skkey) + result = Eth2Node.init(conf, switch, keys.seckey.asEthKey) else: let keyFile = conf.ensureNetworkIdFile @@ -227,10 +227,13 @@ when networkBackend in [libp2p, libp2pDaemon]: node.addKnownPeer bootstrapNode await node.start() - await sleepAsync(10.seconds) - if bootstrapEnrs.len > 0 and libp2p_successful_dials.value == 0: - fatal "Failed to connect to any bootstrap node. Quitting", bootstrapEnrs - quit 1 + proc checkIfConnectedToBootstrapNode {.async.} = + await sleepAsync(10.seconds) + if bootstrapEnrs.len > 0 and libp2p_successful_dials.value == 0: + fatal "Failed to connect to any bootstrap node. Quitting", bootstrapEnrs + quit 1 + + traceAsyncErrors checkIfConnectedToBootstrapNode() proc saveConnectionAddressFile*(node: Eth2Node, filename: string) = when networkBackend == libp2p: diff --git a/beacon_chain/libp2p_backend.nim b/beacon_chain/libp2p_backend.nim index c92cd8187..87e384a2a 100644 --- a/beacon_chain/libp2p_backend.nim +++ b/beacon_chain/libp2p_backend.nim @@ -182,12 +182,15 @@ proc toPeerInfo(r: Option[enr.TypedRecord]): PeerInfo = return r.get.toPeerInfo proc dialPeer*(node: Eth2Node, peerInfo: PeerInfo) {.async.} = - debug "Dialing peer", peer = $peerInfo + logScope: peer = $peerInfo + + debug "Dialing peer" discard await node.switch.dial(peerInfo) var peer = node.getPeer(peerInfo) peer.wasDialed = true await initializeConnection(peer) inc libp2p_successful_dials + debug "Network handshakes completed" proc runDiscoveryLoop*(node: Eth2Node) {.async.} = debug "Starting discovery loop"