From 54e6fb8631c460a1ae7af2a1808b8b5526237bd0 Mon Sep 17 00:00:00 2001 From: Prem Chaitanya Prathi Date: Tue, 11 Mar 2025 17:34:53 +0530 Subject: [PATCH] enable mix in enr and add mix protocol config --- waku/factory/external_config.nim | 11 +++++++++-- waku/factory/node_factory.nim | 21 +++++++++++---------- waku/waku_enr/capabilities.nim | 5 ++++- waku/waku_lightpush/client.nim | 4 +++- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/waku/factory/external_config.nim b/waku/factory/external_config.nim index f0e530580..ccb90747d 100644 --- a/waku/factory/external_config.nim +++ b/waku/factory/external_config.nim @@ -632,8 +632,15 @@ with the drawback of consuming some more bandwidth.""", .}: bool #Mix config - mixkey* {.desc: "ED25519 private key as 64 char hex string.", name: "mixkey".}: - Option[string] + mix* {. + desc: "Enable mix protocol: true|false", + defaultValue: false, + name: "mix" + .}: bool + mixkey* {. + desc: "ED25519 private key as 64 char hex string.", + name: "mixkey" + .}: Option[string] #TODO: Temp config for simulations.Ideally need to get this info from bootstrap ENRs #[ mixBootstrapNodes* {. desc: diff --git a/waku/factory/node_factory.nim b/waku/factory/node_factory.nim index 5c55e7273..79586e5b4 100644 --- a/waku/factory/node_factory.nim +++ b/waku/factory/node_factory.nim @@ -416,16 +416,17 @@ proc setupProtocols( err("failed to set node waku peer-exchange peer: " & peerExchangeNode.error) #mount mix - let mixPrivKey:string = - if conf.mixkey.isSome(): - conf.mixkey.get() - else: - error "missing mix key" - return err("missing mix key") - ( - await node.mountMix(mixPrivKey) - ).isOkOr: - return err("failed to mount waku mix protocol: " & $error) + if conf.mix: + let mixPrivKey:string = + if conf.mixkey.isSome(): + conf.mixkey.get() + else: + error "missing mix key" + return err("missing mix key") + ( + await node.mountMix(mixPrivKey) + ).isOkOr: + return err("failed to mount waku mix protocol: " & $error) return ok() ## Start node diff --git a/waku/waku_enr/capabilities.nim b/waku/waku_enr/capabilities.nim index 27b75d096..ba6ee3a99 100644 --- a/waku/waku_enr/capabilities.nim +++ b/waku/waku_enr/capabilities.nim @@ -20,6 +20,7 @@ type Filter = 2 Lightpush = 3 Sync = 4 + Mix = 5 const capabilityToCodec = { Capabilities.Relay: WakuRelayCodec, @@ -30,7 +31,7 @@ const capabilityToCodec = { }.toTable func init*( - T: type CapabilitiesBitfield, lightpush, filter, store, relay, sync: bool = false + T: type CapabilitiesBitfield, lightpush, filter, store, relay, sync, mix: bool = false ): T = ## Creates an waku2 ENR flag bit field according to RFC 31 (https://rfc.vac.dev/spec/31/) var bitfield: uint8 @@ -44,6 +45,8 @@ func init*( bitfield.setBit(3) if sync: bitfield.setBit(4) + if mix: + bitfield.setBit(5) CapabilitiesBitfield(bitfield) func init*(T: type CapabilitiesBitfield, caps: varargs[Capabilities]): T = diff --git a/waku/waku_lightpush/client.nim b/waku/waku_lightpush/client.nim index b4dbf9300..373923e7f 100644 --- a/waku/waku_lightpush/client.nim +++ b/waku/waku_lightpush/client.nim @@ -135,4 +135,6 @@ proc publishWithConn*( for obs in wl.publishObservers: obs.onMessagePublished(pubSubTopic, message) - return lightpushSuccessResult(1) \ No newline at end of file + #TODO: Implement response handling. + + return lightpushSuccessResult(1)