From c3bfe15a3552c6aeb77ef997cca13cb1671ef05e Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Sun, 29 Nov 2020 14:43:41 +0100 Subject: [PATCH] increase default max peers (#2106) * increase default max peers also avoid reconnection when opening stream as this might induce a loop * Use dial without addresses * dial back max peers a little --- beacon_chain/conf.nim | 2 +- beacon_chain/eth2_network.nim | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/beacon_chain/conf.nim b/beacon_chain/conf.nim index 1eba5c9f8..3dfda0c1f 100644 --- a/beacon_chain/conf.nim +++ b/beacon_chain/conf.nim @@ -139,7 +139,7 @@ type name: "udp-port" }: Port maxPeers* {. - defaultValue: 79 # The Wall gets released + defaultValue: 160 # 5 (fanout) * 64 (subnets) / 2 (subs) for a heathy mesh desc: "The maximum number of peers to connect to" name: "max-peers" }: int diff --git a/beacon_chain/eth2_network.nim b/beacon_chain/eth2_network.nim index ea67ad794..dc84a5714 100644 --- a/beacon_chain/eth2_network.nim +++ b/beacon_chain/eth2_network.nim @@ -311,10 +311,13 @@ template remote*(peer: Peer): untyped = proc openStream(node: Eth2Node, peer: Peer, protocolId: string): Future[Connection] {.async.} = + # When dialling here, we do not provide addresses - all new connection + # attempts are handled via `connect` which also takes into account + # reconnection timeouts let protocolId = protocolId & "ssz_snappy" conn = await dial( - node.switch, peer.info.peerId, peer.info.addrs, protocolId) + node.switch, peer.info.peerId, protocolId) # libp2p may replace peerinfo ref sometimes, so make sure we have a recent # one @@ -665,7 +668,7 @@ proc handleIncomingStream(network: Eth2Node, case peer.connectionState of Disconnecting, Disconnected, None: # We got incoming stream request while disconnected or disconnecting. - warn "Got incoming request from disconnected peer", peer = peer, + debug "Got incoming request from disconnected peer", peer = peer, message = msgName await conn.closeWithEOF() return