mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-10 20:36:31 +00:00
38036966a6
* Improve the tests of the local testnet The local testnet test was rather flaky and would occasionally fail. It has been made more robust by adding the ENRs directly to the routing table instead of doing some random lookups. Additionally, the amount of nodes were increased (=64), ip limits configuration was added, and the bits-per-hop value was set to 1 in order to make the lookups more likely to hit the network instead of only the local routing table. Failure is obviously still possible to happen when sufficient packets get lost. If this turns out to be the case with the current amount of nodes, we might have to revise the testing strategy here. * Disable lookup test for State network Disable lookup test for State network due to issue with custom distance function causing the lookup to not always converging towards the target.
37 lines
1.3 KiB
Nim
37 lines
1.3 KiB
Nim
# Nimbus - Portal Network
|
|
# Copyright (c) 2021 Status Research & Development GmbH
|
|
# Licensed and distributed under either of
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
import
|
|
stew/shims/net,
|
|
eth/keys,
|
|
eth/p2p/discoveryv5/[enr, node, routing_table],
|
|
eth/p2p/discoveryv5/protocol as discv5_protocol
|
|
|
|
proc localAddress*(port: int): Address =
|
|
Address(ip: ValidIpAddress.init("127.0.0.1"), port: Port(port))
|
|
|
|
proc initDiscoveryNode*(rng: ref BrHmacDrbgContext,
|
|
privKey: PrivateKey,
|
|
address: Address,
|
|
bootstrapRecords: openArray[Record] = [],
|
|
localEnrFields: openArray[(string, seq[byte])] = [],
|
|
previousRecord = none[enr.Record]()): discv5_protocol.Protocol =
|
|
# set bucketIpLimit to allow bucket split
|
|
let config = DiscoveryConfig.init(1000, 24, 5)
|
|
|
|
result = newProtocol(privKey,
|
|
some(address.ip),
|
|
some(address.port), some(address.port),
|
|
bindPort = address.port,
|
|
bootstrapRecords = bootstrapRecords,
|
|
localEnrFields = localEnrFields,
|
|
previousRecord = previousRecord,
|
|
config = config,
|
|
rng = rng)
|
|
|
|
result.open()
|