Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ ifeq ($(USE_LIBBACKTRACE), 0)
NIM_PARAMS := $(NIM_PARAMS) -d:disable_libbacktrace
endif

# enable experimental exit is dest feature in libp2p mix
NIM_PARAMS := $(NIM_PARAMS) -d:libp2p_mix_experimental_exit_is_dest

libbacktrace:
+ $(MAKE) -C vendor/nim-libbacktrace --no-print-directory BUILD_CXX_LIB=0

Expand Down
7 changes: 5 additions & 2 deletions apps/chat2mix/chat2mix.nim
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ type
PrivateKey* = crypto.PrivateKey
Topic* = waku_core.PubsubTopic

const MinMixNodePoolSize = 4

#####################
## chat2 protobufs ##
#####################
Expand Down Expand Up @@ -592,19 +594,20 @@ proc processInput(rfd: AsyncFD, rng: ref HmacDrbgContext) {.async.} =

node.peerManager.addServicePeer(servicePeerInfo, WakuLightpushCodec)
node.peerManager.addServicePeer(servicePeerInfo, WakuPeerExchangeCodec)
#node.peerManager.addServicePeer(servicePeerInfo, WakuRendezVousCodec)

# Start maintaining subscription
asyncSpawn maintainSubscription(
node, pubsubTopic, conf.contentTopic, servicePeerInfo, false
)
echo "waiting for mix nodes to be discovered..."
while true:
if node.getMixNodePoolSize() >= 3:
if node.getMixNodePoolSize() >= MinMixNodePoolSize:
break
discard await node.fetchPeerExchangePeers()
await sleepAsync(1000)

while node.getMixNodePoolSize() < 3:
while node.getMixNodePoolSize() < MinMixNodePoolSize:
info "waiting for mix nodes to be discovered",
currentpoolSize = node.getMixNodePoolSize()
await sleepAsync(1000)
Expand Down
5 changes: 4 additions & 1 deletion examples/lightpush_mix/lightpush_publisher_mix.nim
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ proc setupAndPublish(rng: ref HmacDrbgContext, conf: LightPushMixConf) {.async.}
conn = connOpt.get()
else:
conn = node.wakuMix.toConnection(
MixDestination.init(dPeerId, pxPeerInfo.addrs[0]), # destination lightpush peer
MixDestination.exitNode(dPeerId), # destination lightpush peer
WakuLightPushCodec, # protocol codec which will be used over the mix connection
MixParameters(expectReply: Opt.some(true), numSurbs: Opt.some(byte(1))),
# mix parameters indicating we expect a single reply
Expand All @@ -163,6 +163,9 @@ proc setupAndPublish(rng: ref HmacDrbgContext, conf: LightPushMixConf) {.async.}
ephemeral: true, # tell store nodes to not store it
timestamp: getNowInNanosecondTime(),
) # current timestamp
let res = await node.wakuLightpushClient.publishWithConn(
LightpushPubsubTopic, message, conn, dPeerId
)

let startTime = getNowInNanosecondTime()

Expand Down
4 changes: 2 additions & 2 deletions simulations/mixnet/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
log-level = "INFO"
relay = true
#mix = true
mix = true
filter = true
store = false
lightpush = true
Expand All @@ -18,7 +18,7 @@ num-shards-in-network = 1
shard = [0]
agent-string = "nwaku-mix"
nodekey = "f98e3fba96c32e8d1967d460f1b79457380e1a895f7971cecc8528abe733781a"
#mixkey = "a87db88246ec0eedda347b9b643864bee3d6933eb15ba41e6d58cb678d813258"
mixkey = "a87db88246ec0eedda347b9b643864bee3d6933eb15ba41e6d58cb678d813258"
rendezvous = true
listen-address = "127.0.0.1"
nat = "extip:127.0.0.1"
Expand Down
2 changes: 1 addition & 1 deletion waku/node/kernel_api/lightpush.nim
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ proc lightpushPublishHandler(
if mixify: #indicates we want to use mix to send the message
#TODO: How to handle multiple addresses?
let conn = node.wakuMix.toConnection(
MixDestination.init(peer.peerId, peer.addrs[0]),
MixDestination.exitNode(peer.peerId),
WakuLightPushCodec,
MixParameters(expectReply: Opt.some(true), numSurbs: Opt.some(byte(1))),
# indicating we only want a single path to be used for reply hence numSurbs = 1
Expand Down
10 changes: 5 additions & 5 deletions waku/waku_mix/protocol.nim
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import
logScope:
topics = "waku mix"

const mixMixPoolSize = 3
const minMixPoolSize = 4

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

if len(initTable) < mixMixPoolSize:
warn "publishing with mix won't work until there are 3 mix nodes in node pool"
if len(initTable) < minMixPoolSize:
warn "publishing with mix won't work until atleast 3 mix nodes in node pool"
var m = WakuMix(peerManager: peermgr, clusterId: clusterId, pubKey: mixPubKey)
procCall MixProtocol(m).init(localMixNodeInfo, initTable, peermgr.switch)
return ok(m)
Expand Down
3 changes: 3 additions & 0 deletions waku/waku_rendezvous/protocol.nim
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,7 @@ proc stopWait*(self: WakuRendezVous) {.async: (raises: []).} =
# Stop the parent GenericRendezVous (stops the register deletion loop)
await GenericRendezVous[WakuPeerRecord](self).stop()

# Stop the parent GenericRendezVous (stops the register deletion loop)
await GenericRendezVous[WakuPeerRecord](self).stop()

info "waku rendezvous discovery stopped"
Loading