diff --git a/logos_delivery/waku/factory/conf_builder/mix_conf_builder.nim b/logos_delivery/waku/factory/conf_builder/mix_conf_builder.nim index 7061ca6db..853c78bca 100644 --- a/logos_delivery/waku/factory/conf_builder/mix_conf_builder.nim +++ b/logos_delivery/waku/factory/conf_builder/mix_conf_builder.nim @@ -14,6 +14,7 @@ type MixConfBuilder* = object mixNodes: seq[MixNodePubInfo] userMessageLimit: Option[int] disableSpamProtection: bool + disableCoverTraffic: bool useOnchainLEZ: bool gifterService: bool gifterWalletAccount: string @@ -39,6 +40,9 @@ proc withUserMessageLimit*(b: var MixConfBuilder, limit: int) = proc withDisableSpamProtection*(b: var MixConfBuilder, disable: bool) = b.disableSpamProtection = disable +proc withDisableCoverTraffic*(b: var MixConfBuilder, disable: bool) = + b.disableCoverTraffic = disable + proc withUseOnchainLEZ*(b: var MixConfBuilder, use: bool) = b.useOnchainLEZ = use @@ -72,6 +76,7 @@ proc build*(b: MixConfBuilder): Result[Option[MixConf], string] = mixNodes: b.mixNodes, userMessageLimit: b.userMessageLimit, disableSpamProtection: b.disableSpamProtection, + disableCoverTraffic: b.disableCoverTraffic, useOnchainLEZ: b.useOnchainLEZ, gifterService: b.gifterService, gifterWalletAccount: b.gifterWalletAccount, @@ -92,6 +97,7 @@ proc build*(b: MixConfBuilder): Result[Option[MixConf], string] = mixNodes: b.mixNodes, userMessageLimit: b.userMessageLimit, disableSpamProtection: b.disableSpamProtection, + disableCoverTraffic: b.disableCoverTraffic, useOnchainLEZ: b.useOnchainLEZ, gifterService: b.gifterService, gifterWalletAccount: b.gifterWalletAccount, diff --git a/logos_delivery/waku/factory/node_factory.nim b/logos_delivery/waku/factory/node_factory.nim index 983182599..b6a3d22ac 100644 --- a/logos_delivery/waku/factory/node_factory.nim +++ b/logos_delivery/waku/factory/node_factory.nim @@ -179,6 +179,7 @@ proc setupProtocols( await node.mountMix( conf.clusterId, mixConf.mixKey, mixConf.mixnodes, mixConf.userMessageLimit, mixConf.disableSpamProtection, + disableCoverTraffic = mixConf.disableCoverTraffic, useOnchainLEZ = mixConf.useOnchainLEZ, ) ).isOkOr: diff --git a/logos_delivery/waku/factory/waku_conf.nim b/logos_delivery/waku/factory/waku_conf.nim index 60e50a941..c4365b3db 100644 --- a/logos_delivery/waku/factory/waku_conf.nim +++ b/logos_delivery/waku/factory/waku_conf.nim @@ -59,6 +59,7 @@ type MixConf* = ref object mixnodes*: seq[MixNodePubInfo] userMessageLimit*: Option[int] disableSpamProtection*: bool + disableCoverTraffic*: bool useOnchainLEZ*: bool gifterService*: bool gifterWalletAccount*: string diff --git a/logos_delivery/waku/node/waku_node.nim b/logos_delivery/waku/node/waku_node.nim index 5a9c25f86..f4f1d2ab2 100644 --- a/logos_delivery/waku/node/waku_node.nim +++ b/logos_delivery/waku/node/waku_node.nim @@ -337,6 +337,7 @@ proc mountMix*( mixnodes: seq[MixNodePubInfo], userMessageLimit: Option[int] = none(int), disableSpamProtection: bool = false, + disableCoverTraffic: bool = false, useOnchainLEZ: bool = false, ): Future[Result[void, string]] {.async.} = info "mounting mix protocol", nodeId = node.info #TODO log the config used @@ -370,7 +371,7 @@ proc mountMix*( node.wakuMix = WakuMix.new( localaddrStr, node.peerManager, clusterId, mixPrivKey, mixnodes, publishMessage, - userMessageLimit, disableSpamProtection, useOnchainLEZ, + userMessageLimit, disableSpamProtection, disableCoverTraffic, useOnchainLEZ, ).valueOr: error "Waku Mix protocol initialization failed", err = error return diff --git a/logos_delivery/waku/waku_mix/protocol.nim b/logos_delivery/waku/waku_mix/protocol.nim index a2ff21fd3..06d508f9d 100644 --- a/logos_delivery/waku/waku_mix/protocol.nim +++ b/logos_delivery/waku/waku_mix/protocol.nim @@ -111,6 +111,7 @@ proc new*( publishMessage: PublishMessage, userMessageLimit: Option[int] = none(int), disableSpamProtection: bool = false, + disableCoverTraffic: bool = false, useOnchainLEZ: bool = false, ): WakuMixResult[T] = let mixPubKey = public(mixPrivKey) @@ -150,11 +151,16 @@ proc new*( else: info "mix spam protection disabled" - let ct = ConstantRateCoverTraffic.new( - totalSlots = ctTotalSlots, - epochDuration = ctEpochDuration, - useInternalEpochTimer = disableSpamProtection, - ) + var coverTrafficOpt = default(Opt[CoverTraffic]) + if not disableCoverTraffic: + let ct = ConstantRateCoverTraffic.new( + totalSlots = ctTotalSlots, + epochDuration = ctEpochDuration, + useInternalEpochTimer = disableSpamProtection, + ) + coverTrafficOpt = Opt.some(CoverTraffic(ct)) + else: + info "mix cover traffic disabled" var mixRlnSpam: MixRlnSpamProtection if spamProtectionOpt.isSome(): @@ -176,7 +182,7 @@ proc new*( ExponentialDelayStrategy.new(meanDelay = 100, rng = crypto.newRng()) ) ), - coverTraffic = Opt.some(CoverTraffic(ct)), + coverTraffic = coverTrafficOpt, ) processBootNodes(bootnodes, peermgr, m) diff --git a/tools/confutils/cli_args.nim b/tools/confutils/cli_args.nim index 95c6c7f2a..9f02b83ce 100644 --- a/tools/confutils/cli_args.nim +++ b/tools/confutils/cli_args.nim @@ -654,6 +654,12 @@ with the drawback of consuming some more bandwidth.""", name: "mix-disable-spam-protection" .}: bool + mixDisableCoverTraffic* {. + desc: "Disable constant-rate cover traffic emission for mix protocol.", + defaultValue: false, + name: "mix-disable-cover-traffic" + .}: bool + mixOnchainLEZ* {. desc: "Use on-chain LEZ (LSSA sequencer) for mix RLN spam protection instead of off-chain keystores.", defaultValue: false, @@ -1151,6 +1157,7 @@ proc toWakuConf*(n: WakuNodeConf): ConfResult[WakuConf] = if n.mixUserMessageLimit.isSome(): b.mixConf.withUserMessageLimit(n.mixUserMessageLimit.get()) b.mixConf.withDisableSpamProtection(n.mixDisableSpamProtection) + b.mixConf.withDisableCoverTraffic(n.mixDisableCoverTraffic) b.filterServiceConf.withEnabled(n.filter) b.filterServiceConf.withSubscriptionTimeout(n.filterSubscriptionTimeout)