mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-06-27 11:59:26 +00:00
fix(integrate): adapt #3947 to rebase/lez-rln-gifter-on-3807
Verified end-to-end: - wakunode2 builds - chat2mix builds - tests/waku_kademlia/test_waku_kademlia.nim — 14/14 PASS - 5-node mixnet sim — all nodes mount mix protocol, Kad-DHT bootstrap + start, service discovery lookup queries find all peers.
This commit is contained in:
parent
c417c7edf8
commit
0e2d276847
@ -6,7 +6,7 @@ when not (compileOption("threads")):
|
||||
|
||||
{.push raises: [].}
|
||||
|
||||
import std/[strformat, strutils, times, options, random, sequtils]
|
||||
import std/[strformat, strutils, times, options, random, sequtils, sets]
|
||||
import
|
||||
confutils,
|
||||
chronicles,
|
||||
@ -571,18 +571,16 @@ proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} =
|
||||
if conf.kadBootstrapNodes.len > 0:
|
||||
var kadBootstrapPeers: seq[(PeerId, seq[MultiAddress])]
|
||||
for nodeStr in conf.kadBootstrapNodes:
|
||||
let (peerId, ma) = block:
|
||||
parseFullAddress(nodeStr).isOkOr:
|
||||
error "Failed to parse kademlia bootstrap node", node = nodeStr, error
|
||||
continue
|
||||
|
||||
let (peerId, ma) = parseFullAddress(nodeStr).valueOr:
|
||||
error "Failed to parse kademlia bootstrap node", node = nodeStr, error = error
|
||||
continue
|
||||
kadBootstrapPeers.add((peerId, @[ma]))
|
||||
|
||||
if kadBootstrapPeers.len > 0:
|
||||
node.mountKademlia(
|
||||
KademliaDiscoveryConf(
|
||||
bootstrapNodes: kadBootstrapPeers,
|
||||
servicesToDiscover: @[MixProtocolID],
|
||||
servicesToDiscover: toHashSet([MixProtocolID]),
|
||||
randomLookupInterval: chronos.seconds(60),
|
||||
serviceLookupInterval: chronos.seconds(60),
|
||||
kadDhtConfig: KadDHTConfig.new(),
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import logos_delivery/waku/compat/option_valueor
|
||||
import logos_delivery/waku/common/option_shims
|
||||
{.push raises: [].}
|
||||
|
||||
import std/[options, sequtils, sets]
|
||||
|
||||
@ -876,11 +876,6 @@ proc startNode*(
|
||||
if conf.relay:
|
||||
node.peerManager.start()
|
||||
|
||||
if not node.wakuKademlia.isNil():
|
||||
let minMixPeers = if conf.mixConf.isSome(): 4 else: 0
|
||||
(await node.wakuKademlia.start(minMixPeers = minMixPeers)).isOkOr:
|
||||
return err("failed to start kademlia discovery: " & error)
|
||||
|
||||
# Re-publish gossipsub trigger after switch + kademlia are up. The dummy
|
||||
# publish in WakuMix.start() fires too early in LEZ mode (0 peers on topic),
|
||||
# so SUBSCRIBE messages never propagate without this second publish.
|
||||
|
||||
@ -13,6 +13,7 @@ import
|
||||
eth/p2p/discoveryv5/enr,
|
||||
libp2p/crypto/crypto,
|
||||
libp2p/crypto/curve25519,
|
||||
libp2p/crypto/rng as libp2p_rng,
|
||||
libp2p/[multiaddress, multicodec],
|
||||
libp2p/protocols/ping,
|
||||
libp2p/protocols/pubsub/gossipsub,
|
||||
@ -393,7 +394,8 @@ proc mountKademlia*(
|
||||
let wk = WakuKademlia.new(
|
||||
node.switch, node.peerManager, config.bootstrapNodes, config.servicesToAdvertise,
|
||||
config.servicesToDiscover, config.randomLookupInterval,
|
||||
config.serviceLookupInterval, node.rng, config.kadDhtConfig, config.discoConfig,
|
||||
config.serviceLookupInterval, libp2p_rng.newBearSslRng(node.rng),
|
||||
config.kadDhtConfig, config.discoConfig,
|
||||
config.clientMode, config.xprPublishing,
|
||||
).valueOr:
|
||||
return err("failed to create service discovery: " & error)
|
||||
|
||||
@ -6,6 +6,7 @@ import libp2p/[peerid, multiaddress, switch]
|
||||
import libp2p/extended_peer_record
|
||||
import libp2p/protocols/service_discovery/types as sd_types
|
||||
import libp2p/crypto/crypto as libp2p_keys
|
||||
import libp2p/crypto/rng as libp2p_rng
|
||||
|
||||
import
|
||||
logos_delivery/waku/discovery/waku_kademlia,
|
||||
@ -35,7 +36,7 @@ proc newTestKademlia*(
|
||||
servicesToDiscover = toHashSet(servicesToDiscover),
|
||||
randomLookupInterval = randomLookupInterval,
|
||||
serviceLookupInterval = serviceLookupInterval,
|
||||
rng = rng(),
|
||||
rng = libp2p_rng.newBearSslRng(rng()),
|
||||
clientMode = clientMode,
|
||||
xprPublishing = xprPublishing,
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user