Skip to content

Commit a459d3e

Browse files
committed
use exit==dest approach for mix
1 parent b0cd75f commit a459d3e

File tree

8 files changed

+23
-11
lines changed

8 files changed

+23
-11
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ ifeq ($(USE_LIBBACKTRACE), 0)
143143
NIM_PARAMS := $(NIM_PARAMS) -d:disable_libbacktrace
144144
endif
145145

146+
# enable experimental exit is dest feature in libp2p mix
147+
NIM_PARAMS := $(NIM_PARAMS) -d:libp2p_mix_experimental_exit_is_dest
148+
146149
libbacktrace:
147150
+ $(MAKE) -C vendor/nim-libbacktrace --no-print-directory BUILD_CXX_LIB=0
148151

apps/chat2mix/chat2mix.nim

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ type
8282
PrivateKey* = crypto.PrivateKey
8383
Topic* = waku_core.PubsubTopic
8484

85+
const MinMixNodePoolSize = 4
86+
8587
#####################
8688
## chat2 protobufs ##
8789
#####################
@@ -592,19 +594,20 @@ proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} =
592594

593595
node.peerManager.addServicePeer(servicePeerInfo, WakuLightpushCodec)
594596
node.peerManager.addServicePeer(servicePeerInfo, WakuPeerExchangeCodec)
597+
#node.peerManager.addServicePeer(servicePeerInfo, WakuRendezVousCodec)
595598

596599
# Start maintaining subscription
597600
asyncSpawn maintainSubscription(
598601
node, pubsubTopic, conf.contentTopic, servicePeerInfo, false
599602
)
600603
echo "waiting for mix nodes to be discovered..."
601604
while true:
602-
if node.getMixNodePoolSize() >= 3:
605+
if node.getMixNodePoolSize() >= MinMixNodePoolSize:
603606
break
604607
discard await node.fetchPeerExchangePeers()
605608
await sleepAsync(1000)
606609

607-
while node.getMixNodePoolSize() < 3:
610+
while node.getMixNodePoolSize() < MinMixNodePoolSize:
608611
info "waiting for mix nodes to be discovered",
609612
currentpoolSize = node.getMixNodePoolSize()
610613
await sleepAsync(1000)

examples/lightpush_mix/lightpush_publisher_mix.nim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ proc setupAndPublish(rng: ref HmacDrbgContext, conf: LightPushMixConf) {.async.}
144144
conn = connOpt.get()
145145
else:
146146
conn = node.wakuMix.toConnection(
147-
MixDestination.init(dPeerId, pxPeerInfo.addrs[0]), # destination lightpush peer
147+
MixDestination.exitNode(dPeerId), # destination lightpush peer
148148
WakuLightPushCodec, # protocol codec which will be used over the mix connection
149149
MixParameters(expectReply: Opt.some(true), numSurbs: Opt.some(byte(1))),
150150
# mix parameters indicating we expect a single reply
@@ -163,6 +163,9 @@ proc setupAndPublish(rng: ref HmacDrbgContext, conf: LightPushMixConf) {.async.}
163163
ephemeral: true, # tell store nodes to not store it
164164
timestamp: getNowInNanosecondTime(),
165165
) # current timestamp
166+
let res = await node.wakuLightpushClient.publishWithConn(
167+
LightpushPubsubTopic, message, conn, dPeerId
168+
)
166169

167170
let startTime = getNowInNanosecondTime()
168171

simulations/mixnet/config.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
log-level = "INFO"
22
relay = true
3-
#mix = true
3+
mix = true
44
filter = true
55
store = false
66
lightpush = true
@@ -18,7 +18,7 @@ num-shards-in-network = 1
1818
shard = [0]
1919
agent-string = "nwaku-mix"
2020
nodekey = "f98e3fba96c32e8d1967d460f1b79457380e1a895f7971cecc8528abe733781a"
21-
#mixkey = "a87db88246ec0eedda347b9b643864bee3d6933eb15ba41e6d58cb678d813258"
21+
mixkey = "a87db88246ec0eedda347b9b643864bee3d6933eb15ba41e6d58cb678d813258"
2222
rendezvous = true
2323
listen-address = "127.0.0.1"
2424
nat = "extip:127.0.0.1"
File renamed without changes.

waku/node/kernel_api/lightpush.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ proc lightpushPublishHandler(
199199
if mixify: #indicates we want to use mix to send the message
200200
#TODO: How to handle multiple addresses?
201201
let conn = node.wakuMix.toConnection(
202-
MixDestination.init(peer.peerId, peer.addrs[0]),
202+
MixDestination.exitNode(peer.peerId),
203203
WakuLightPushCodec,
204204
MixParameters(expectReply: Opt.some(true), numSurbs: Opt.some(byte(1))),
205205
# indicating we only want a single path to be used for reply hence numSurbs = 1

waku/waku_mix/protocol.nim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import
2121
logScope:
2222
topics = "waku mix"
2323

24-
const mixMixPoolSize = 3
24+
const minMixPoolSize = 4
2525

2626
type
2727
WakuMix* = ref object of MixProtocol
@@ -181,12 +181,12 @@ proc new*(
181181
peermgr.switch.peerInfo.peerId, nodeMultiAddr, mixPubKey, mixPrivKey,
182182
peermgr.switch.peerInfo.publicKey.skkey, peermgr.switch.peerInfo.privateKey.skkey,
183183
)
184-
if bootnodes.len < mixMixPoolSize:
185-
warn "publishing with mix won't work until there are 3 mix nodes in node pool"
184+
if bootnodes.len < minMixPoolSize:
185+
warn "publishing with mix won't work until atleast 3 mix nodes in node pool"
186186
let initTable = processBootNodes(bootnodes, peermgr)
187187

188-
if len(initTable) < mixMixPoolSize:
189-
warn "publishing with mix won't work until there are 3 mix nodes in node pool"
188+
if len(initTable) < minMixPoolSize:
189+
warn "publishing with mix won't work until atleast 3 mix nodes in node pool"
190190
var m = WakuMix(peerManager: peermgr, clusterId: clusterId, pubKey: mixPubKey)
191191
procCall MixProtocol(m).init(localMixNodeInfo, initTable, peermgr.switch)
192192
return ok(m)

waku/waku_rendezvous/protocol.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,7 @@ proc stopWait*(self: WakuRendezVous) {.async: (raises: []).} =
234234
# Stop the parent GenericRendezVous (stops the register deletion loop)
235235
await GenericRendezVous[WakuPeerRecord](self).stop()
236236

237+
# Stop the parent GenericRendezVous (stops the register deletion loop)
238+
await GenericRendezVous[WakuPeerRecord](self).stop()
239+
237240
info "waku rendezvous discovery stopped"

0 commit comments

Comments
 (0)