mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-06-26 11:29:28 +00:00
feat(mix): add --mix-disable-cover-traffic CLI knob (#3972)
This commit is contained in:
parent
b878de82b8
commit
efafdfdc24
@ -17,6 +17,7 @@ type MixConfBuilder* = object
|
||||
mixNodes: seq[MixNodePubInfo]
|
||||
userMessageLimit: Option[int]
|
||||
disableSpamProtection: bool
|
||||
disableCoverTraffic: bool
|
||||
|
||||
proc init*(T: type MixConfBuilder): MixConfBuilder =
|
||||
MixConfBuilder()
|
||||
@ -36,6 +37,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 build*(b: MixConfBuilder): Result[Option[MixConf], string] =
|
||||
if not b.enabled.get(DefaultMixEnabled):
|
||||
return ok(none[MixConf]())
|
||||
@ -51,6 +55,7 @@ proc build*(b: MixConfBuilder): Result[Option[MixConf], string] =
|
||||
mixNodes: b.mixNodes,
|
||||
userMessageLimit: b.userMessageLimit,
|
||||
disableSpamProtection: b.disableSpamProtection,
|
||||
disableCoverTraffic: b.disableCoverTraffic,
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -65,6 +70,7 @@ proc build*(b: MixConfBuilder): Result[Option[MixConf], string] =
|
||||
mixNodes: b.mixNodes,
|
||||
userMessageLimit: b.userMessageLimit,
|
||||
disableSpamProtection: b.disableSpamProtection,
|
||||
disableCoverTraffic: b.disableCoverTraffic,
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@ -170,7 +170,7 @@ proc setupProtocols(
|
||||
(
|
||||
await node.mountMix(
|
||||
conf.clusterId, mixConf.mixKey, mixConf.mixnodes, mixConf.userMessageLimit,
|
||||
mixConf.disableSpamProtection,
|
||||
mixConf.disableSpamProtection, mixConf.disableCoverTraffic,
|
||||
)
|
||||
).isOkOr:
|
||||
return err("failed to mount waku mix protocol: " & $error)
|
||||
|
||||
@ -62,6 +62,7 @@ type MixConf* = ref object
|
||||
mixnodes*: seq[MixNodePubInfo]
|
||||
userMessageLimit*: Option[int]
|
||||
disableSpamProtection*: bool
|
||||
disableCoverTraffic*: bool
|
||||
|
||||
type StoreServiceConf* {.requiresInit.} = object
|
||||
dbMigration*: bool
|
||||
|
||||
@ -329,6 +329,7 @@ proc mountMix*(
|
||||
mixnodes: seq[MixNodePubInfo],
|
||||
userMessageLimit: Option[int] = none(int),
|
||||
disableSpamProtection: bool = false,
|
||||
disableCoverTraffic: bool = false,
|
||||
): Future[Result[void, string]] {.async.} =
|
||||
info "mounting mix protocol", nodeId = node.info #TODO log the config used
|
||||
|
||||
@ -361,7 +362,7 @@ proc mountMix*(
|
||||
|
||||
node.wakuMix = WakuMix.new(
|
||||
localaddrStr, node.peerManager, clusterId, mixPrivKey, mixnodes, publishMessage,
|
||||
userMessageLimit, disableSpamProtection,
|
||||
userMessageLimit, disableSpamProtection, disableCoverTraffic,
|
||||
).valueOr:
|
||||
error "Waku Mix protocol initialization failed", err = error
|
||||
return
|
||||
|
||||
@ -111,6 +111,7 @@ proc new*(
|
||||
publishMessage: PublishMessage,
|
||||
userMessageLimit: Option[int] = none(int),
|
||||
disableSpamProtection: bool = false,
|
||||
disableCoverTraffic: bool = false,
|
||||
): WakuMixResult[T] =
|
||||
let mixPubKey = public(mixPrivKey)
|
||||
trace "mixPubKey", mixPubKey = mixPubKey
|
||||
@ -146,11 +147,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():
|
||||
@ -172,7 +178,7 @@ proc new*(
|
||||
ExponentialDelayStrategy.new(meanDelay = 100, rng = crypto.newRng())
|
||||
)
|
||||
),
|
||||
coverTraffic = Opt.some(CoverTraffic(ct)),
|
||||
coverTraffic = coverTrafficOpt,
|
||||
)
|
||||
|
||||
processBootNodes(bootnodes, peermgr, m)
|
||||
|
||||
@ -681,6 +681,12 @@ hence would have reachability issues.""",
|
||||
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
|
||||
|
||||
# Kademlia Discovery config
|
||||
# Option-typed; desc states the default since the CLI can't auto-show it for none().
|
||||
enableKadDiscovery* {.
|
||||
@ -1152,6 +1158,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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user