From 120549e313814515dcc6841bac42315e4fa3efd8 Mon Sep 17 00:00:00 2001 From: diegomrsantos Date: Fri, 7 Jun 2024 11:48:44 +0200 Subject: [PATCH 1/2] fix(services): setup services before peerinfo is updated (#1120) --- libp2p/switch.nim | 6 ++---- tests/hole-punching-interop/hole_punching.nim | 5 +++-- tests/testautonatservice.nim | 2 +- tests/testautorelay.nim | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/libp2p/switch.nim b/libp2p/switch.nim index 518a48c846..f7e19f9be0 100644 --- a/libp2p/switch.nim +++ b/libp2p/switch.nim @@ -349,13 +349,11 @@ proc start*(s: Switch) {.async, public.} = s.acceptFuts.add(s.accept(t)) s.peerInfo.listenAddrs &= t.addrs - await s.peerInfo.update() - - await s.ms.start() - for service in s.services: discard await service.setup(s) + await s.peerInfo.update() + await s.ms.start() s.started = true debug "Started libp2p node", peer = s.peerInfo diff --git a/tests/hole-punching-interop/hole_punching.nim b/tests/hole-punching-interop/hole_punching.nim index eea2812897..184bfcbf13 100644 --- a/tests/hole-punching-interop/hole_punching.nim +++ b/tests/hole-punching-interop/hole_punching.nim @@ -1,8 +1,9 @@ -import std/[os, options, strformat] +import std/[os, options, strformat, sequtils] import redis import chronos, chronicles import ../../libp2p/[builders, switch, + multicodec, observedaddrmanager, services/hpservice, services/autorelayservice, @@ -76,7 +77,7 @@ proc main() {.async.} = debug "Connected to relay", relayId # Wait for our relay address to be published - while switch.peerInfo.addrs.len == 0: + while not switch.peerInfo.addrs.anyIt(it.contains(multiCodec("p2p-circuit")).tryGet()): await sleepAsync(100.milliseconds) if isListener: diff --git a/tests/testautonatservice.nim b/tests/testautonatservice.nim index eb68538b54..01a1d2885a 100644 --- a/tests/testautonatservice.nim +++ b/tests/testautonatservice.nim @@ -23,7 +23,7 @@ import stubs/autonatclientstub proc createSwitch(autonatSvc: Service = nil, withAutonat = true, maxConnsPerPeer = 1, maxConns = 100, nameResolver: NameResolver = nil): Switch = var builder = SwitchBuilder.new() .withRng(newRng()) - .withAddresses(@[ MultiAddress.init("/ip4/0.0.0.0/tcp/0").tryGet() ]) + .withAddresses(@[ MultiAddress.init("/ip4/0.0.0.0/tcp/0").tryGet() ], false) .withTcpTransport() .withMaxConnsPerPeer(maxConnsPerPeer) .withMaxConnections(maxConns) diff --git a/tests/testautorelay.nim b/tests/testautorelay.nim index de2f3c02e7..7df4d00ac7 100644 --- a/tests/testautorelay.nim +++ b/tests/testautorelay.nim @@ -20,7 +20,7 @@ import ./helpers proc createSwitch(r: Relay, autorelay: Service = nil): Switch = var builder = SwitchBuilder.new() .withRng(newRng()) - .withAddresses(@[ MultiAddress.init("/ip4/0.0.0.0/tcp/0").tryGet() ]) + .withAddresses(@[ MultiAddress.init("/ip4/0.0.0.0/tcp/0").tryGet() ], false) .withTcpTransport() .withMplex() .withNoise() From d0af3fbe8559f69195657a360c3dd4ac4552c811 Mon Sep 17 00:00:00 2001 From: kaiserd <1684595+kaiserd@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:25:47 +0200 Subject: [PATCH 2/2] chore(version): update libp2p.nimble to 1.3.0 (#1119) --- libp2p.nimble | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libp2p.nimble b/libp2p.nimble index 28245174a4..214a6e00ac 100644 --- a/libp2p.nimble +++ b/libp2p.nimble @@ -1,7 +1,7 @@ mode = ScriptMode.Verbose packageName = "libp2p" -version = "1.1.0" +version = "1.3.0" author = "Status Research & Development GmbH" description = "LibP2P implementation" license = "MIT"