feat(mix): add --mix-disable-cover-traffic CLI knob (#3972)

This commit is contained in:
AkshayaMani 2026-06-23 07:28:51 -04:00 committed by akshaya
parent e40ff023b9
commit b0b61b9e36
No known key found for this signature in database
GPG Key ID: 12C1A9E9F5629D18
6 changed files with 29 additions and 7 deletions

View File

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

View File

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

View File

@ -59,6 +59,7 @@ type MixConf* = ref object
mixnodes*: seq[MixNodePubInfo]
userMessageLimit*: Option[int]
disableSpamProtection*: bool
disableCoverTraffic*: bool
useOnchainLEZ*: bool
gifterService*: bool
gifterWalletAccount*: string

View File

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

View File

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

View File

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