2024-06-28 10:34:57 +00:00
|
|
|
|
{.push raises: [].}
|
2024-03-06 13:14:33 +00:00
|
|
|
|
|
2024-07-23 10:57:24 +00:00
|
|
|
|
import waku/[common/logging, factory/[waku, networks_config, external_config]]
|
2024-03-06 13:14:33 +00:00
|
|
|
|
import
|
|
|
|
|
std/[options, strutils, os, sequtils],
|
|
|
|
|
stew/shims/net as stewNet,
|
|
|
|
|
chronicles,
|
|
|
|
|
chronos,
|
|
|
|
|
metrics,
|
|
|
|
|
libbacktrace,
|
|
|
|
|
libp2p/crypto/crypto
|
|
|
|
|
|
|
|
|
|
export
|
2024-05-03 12:07:15 +00:00
|
|
|
|
networks_config, waku, logging, options, strutils, os, sequtils, stewNet, chronicles,
|
2024-03-15 23:08:47 +00:00
|
|
|
|
chronos, metrics, libbacktrace, crypto
|
2024-03-06 13:14:33 +00:00
|
|
|
|
|
2024-05-03 12:07:15 +00:00
|
|
|
|
proc setup*(): Waku =
|
|
|
|
|
const versionString = "version / git commit hash: " & waku.git_version
|
2024-03-06 13:14:33 +00:00
|
|
|
|
let rng = crypto.newRng()
|
|
|
|
|
|
|
|
|
|
let confRes = WakuNodeConf.load(version = versionString)
|
|
|
|
|
if confRes.isErr():
|
|
|
|
|
error "failure while loading the configuration", error = $confRes.error
|
|
|
|
|
quit(QuitFailure)
|
|
|
|
|
|
|
|
|
|
var conf = confRes.get()
|
|
|
|
|
|
|
|
|
|
let twnClusterConf = ClusterConf.TheWakuNetworkConf()
|
|
|
|
|
if len(conf.shards) != 0:
|
|
|
|
|
conf.pubsubTopics = conf.shards.mapIt(twnClusterConf.pubsubTopics[it.uint16])
|
|
|
|
|
else:
|
|
|
|
|
conf.pubsubTopics = twnClusterConf.pubsubTopics
|
|
|
|
|
|
|
|
|
|
# Override configuration
|
|
|
|
|
conf.maxMessageSize = twnClusterConf.maxMessageSize
|
|
|
|
|
conf.clusterId = twnClusterConf.clusterId
|
|
|
|
|
conf.rlnRelayEthContractAddress = twnClusterConf.rlnRelayEthContractAddress
|
|
|
|
|
conf.rlnRelayDynamic = twnClusterConf.rlnRelayDynamic
|
|
|
|
|
conf.rlnRelayBandwidthThreshold = twnClusterConf.rlnRelayBandwidthThreshold
|
|
|
|
|
conf.discv5Discovery = twnClusterConf.discv5Discovery
|
|
|
|
|
conf.discv5BootstrapNodes =
|
|
|
|
|
conf.discv5BootstrapNodes & twnClusterConf.discv5BootstrapNodes
|
|
|
|
|
conf.rlnEpochSizeSec = twnClusterConf.rlnEpochSizeSec
|
|
|
|
|
conf.rlnRelayUserMessageLimit = twnClusterConf.rlnRelayUserMessageLimit
|
|
|
|
|
|
2024-08-01 20:28:00 +00:00
|
|
|
|
# Only set rlnRelay to true if relay is configured
|
|
|
|
|
if conf.relay:
|
|
|
|
|
conf.rlnRelay = twnClusterConf.rlnRelay
|
|
|
|
|
|
2024-05-03 12:07:15 +00:00
|
|
|
|
debug "Starting node"
|
|
|
|
|
var waku = Waku.init(conf).valueOr:
|
|
|
|
|
error "Waku initialization failed", error = error
|
2024-03-06 13:14:33 +00:00
|
|
|
|
quit(QuitFailure)
|
|
|
|
|
|
2024-05-03 12:07:15 +00:00
|
|
|
|
(waitFor startWaku(addr waku)).isOkOr:
|
|
|
|
|
error "Starting waku failed", error = error
|
2024-03-06 13:14:33 +00:00
|
|
|
|
quit(QuitFailure)
|
|
|
|
|
|
|
|
|
|
# set triggerSelf to false, we don't want to process our own stealthCommitments
|
2024-05-03 12:07:15 +00:00
|
|
|
|
waku.node.wakuRelay.triggerSelf = false
|
2024-03-06 13:14:33 +00:00
|
|
|
|
|
|
|
|
|
info "Node setup complete"
|
2024-05-03 12:07:15 +00:00
|
|
|
|
return waku
|