Fix discv5 loop in case of no nodes (#2243)

* Fix discovery loop in case of no peers in routing table

* local testnet: Stop searching when amount of peers in testnet is reached
This commit is contained in:
Kim De Mey 2021-01-18 14:13:26 +01:00 committed by GitHub
parent f1bb8a6a1a
commit 6fabefa76f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -916,8 +916,10 @@ proc runDiscoveryLoop*(node: Eth2Node) {.async.} =
warn "Peer count low, no new peers discovered",
discovered_nodes = len(discoveredNodes), new_peers = newPeers,
current_peers = currentPeers, wanted_peers = node.wantedPeers
else:
await sleepAsync(1.seconds)
# Discovery `queryRandom` can have a synchronous fast path for example
# when no peers are in the routing table. Don't run it in continuous loop.
await sleepAsync(1.seconds)
proc getPersistentNetMetadata*(conf: BeaconNodeConf): Eth2Metadata =
let metadataPath = conf.dataDir / nodeMetadataFilename

View File

@ -373,6 +373,7 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do
--log-level="${LOG_LEVEL}" \
--tcp-port=$(( BASE_PORT + NUM_NODE )) \
--udp-port=$(( BASE_PORT + NUM_NODE )) \
--max-peers=$(( NUM_NODES - 1 )) \
--data-dir="${NODE_DATA_DIR}" \
${BOOTSTRAP_ARG} \
${STATE_SNAPSHOT_ARG} \