enable mix in enr and add mix protocol config

This commit is contained in:
Prem Chaitanya Prathi 2025-03-11 17:34:53 +05:30
parent 8ca9726081
commit 6d24bb1fec
5 changed files with 28 additions and 14 deletions

View File

@ -665,8 +665,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:

View File

@ -122,6 +122,7 @@ proc networkConfiguration*(conf: WakuNodeConf, clientId: string): NetConfigResul
store = conf.store,
relay = conf.relay,
sync = conf.storeSync,
mix = conf.mix,
)
# Resolve and use DNS domain IP

View File

@ -427,16 +427,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

View File

@ -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 =

View File

@ -127,4 +127,6 @@ proc publishWithConn*(
for obs in wl.publishObservers:
obs.onMessagePublished(pubSubTopic, message)
return lightpushSuccessResult(1)
#TODO: Implement response handling.
return lightpushSuccessResult(1)