diff --git a/examples/wakustealthcommitments/node_spec.nim b/examples/wakustealthcommitments/node_spec.nim index 4416f565f..dabaa0f75 100644 --- a/examples/wakustealthcommitments/node_spec.nim +++ b/examples/wakustealthcommitments/node_spec.nim @@ -34,7 +34,6 @@ proc setup*(): Waku = # Override configuration conf.maxMessageSize = twnClusterConf.maxMessageSize conf.clusterId = twnClusterConf.clusterId - conf.rlnRelay = twnClusterConf.rlnRelay conf.rlnRelayEthContractAddress = twnClusterConf.rlnRelayEthContractAddress conf.rlnRelayDynamic = twnClusterConf.rlnRelayDynamic conf.rlnRelayBandwidthThreshold = twnClusterConf.rlnRelayBandwidthThreshold @@ -44,6 +43,10 @@ proc setup*(): Waku = conf.rlnEpochSizeSec = twnClusterConf.rlnEpochSizeSec conf.rlnRelayUserMessageLimit = twnClusterConf.rlnRelayUserMessageLimit + # Only set rlnRelay to true if relay is configured + if conf.relay: + conf.rlnRelay = twnClusterConf.rlnRelay + debug "Starting node" var waku = Waku.init(conf).valueOr: error "Waku initialization failed", error = error diff --git a/waku/factory/external_config.nim b/waku/factory/external_config.nim index 9435d4e27..4556eb56a 100644 --- a/waku/factory/external_config.nim +++ b/waku/factory/external_config.nim @@ -566,6 +566,12 @@ type WakuNodeConf* = object name: "discv5-bits-per-hop" .}: int + discv5Only* {. + desc: "Disable all protocols other than discv5", + defaultValue: false, + name: "discv5-only" + .}: bool + ## waku peer exchange config peerExchange* {. desc: "Enable waku peer exchange protocol (responder side): true|false", diff --git a/waku/factory/node_factory.nim b/waku/factory/node_factory.nim index cee098609..f365e9b71 100644 --- a/waku/factory/node_factory.nim +++ b/waku/factory/node_factory.nim @@ -120,6 +120,10 @@ proc setupProtocols( ## Optionally include persistent message storage. ## No protocols are started yet. + if conf.discv5Only: + notice "Running node only with Discv5, not mounting additional protocols" + return ok() + node.mountMetadata(conf.clusterId).isOkOr: return err("failed to mount waku metadata protocol: " & error) diff --git a/waku/factory/waku.nim b/waku/factory/waku.nim index c6c651cc1..c77ea5237 100644 --- a/waku/factory/waku.nim +++ b/waku/factory/waku.nim @@ -105,7 +105,6 @@ proc init*(T: type Waku, conf: WakuNodeConf): Result[Waku, string] = # Override configuration confCopy.maxMessageSize = twnClusterConf.maxMessageSize confCopy.clusterId = twnClusterConf.clusterId - confCopy.rlnRelay = twnClusterConf.rlnRelay confCopy.rlnRelayEthContractAddress = twnClusterConf.rlnRelayEthContractAddress confCopy.rlnRelayChainId = twnClusterConf.rlnRelayChainId confCopy.rlnRelayDynamic = twnClusterConf.rlnRelayDynamic @@ -115,6 +114,10 @@ proc init*(T: type Waku, conf: WakuNodeConf): Result[Waku, string] = confCopy.discv5BootstrapNodes & twnClusterConf.discv5BootstrapNodes confCopy.rlnEpochSizeSec = twnClusterConf.rlnEpochSizeSec confCopy.rlnRelayUserMessageLimit = twnClusterConf.rlnRelayUserMessageLimit + + # Only set rlnRelay to true if relay is configured + if confCopy.relay: + confCopy.rlnRelay = twnClusterConf.rlnRelay else: discard @@ -216,15 +219,16 @@ proc updateWaku(waku: ptr Waku): Result[void, string] = return ok() proc startWaku*(waku: ptr Waku): Future[Result[void, string]] {.async: (raises: []).} = - (await startNode(waku.node, waku.conf, waku.dynamicBootstrapNodes)).isOkOr: - return err("error while calling startNode: " & $error) + if not waku[].conf.discv5Only: + (await startNode(waku.node, waku.conf, waku.dynamicBootstrapNodes)).isOkOr: + return err("error while calling startNode: " & $error) - # Update waku data that is set dynamically on node start - updateWaku(waku).isOkOr: - return err("Error in updateApp: " & $error) + # Update waku data that is set dynamically on node start + updateWaku(waku).isOkOr: + return err("Error in updateApp: " & $error) ## Discv5 - if waku[].conf.discv5Discovery: + if waku[].conf.discv5Discovery or waku[].conf.discv5Only: waku[].wakuDiscV5 = waku_discv5.setupDiscoveryV5( waku.node.enr, waku.node.peerManager, waku.node.topicSubscriptionQueue, waku.conf, waku.dynamicBootstrapNodes, waku.rng, waku.key,