working conf builder and test

This commit is contained in:
fryorcraken 2025-04-04 14:39:43 +11:00
parent ed0474ade3
commit 82e0bf8cf5
2 changed files with 9 additions and 32 deletions

View File

@ -1,5 +1,7 @@
{.push raises: [].}
# TODO: this file should be called cluster_conf.nim
type ClusterConf* = object
maxMessageSize*: string
clusterId*: uint16
@ -10,6 +12,7 @@ type ClusterConf* = object
rlnRelayBandwidthThreshold*: int
rlnEpochSizeSec*: uint64
rlnRelayUserMessageLimit*: uint64
# TODO: should be uint16 like the `shards` parameter
numShardsInNetwork*: uint32
discv5Discovery*: bool
discv5BootstrapNodes*: seq[string]
@ -30,7 +33,6 @@ proc TheWakuNetworkConf*(T: type ClusterConf): ClusterConf =
rlnRelayUserMessageLimit: 100,
numShardsInNetwork: 8,
discv5Discovery: true,
# TODO: Why is this part of the conf? eg an edge node would not have this
discv5BootstrapNodes:
@[
"enr:-QESuED0qW1BCmF-oH_ARGPr97Nv767bl_43uoy70vrbah3EaCAdK3Q0iRQ6wkSTTpdrg_dU_NC2ydO8leSlRpBX4pxiAYJpZIJ2NIJpcIRA4VDAim11bHRpYWRkcnO4XAArNiZub2RlLTAxLmRvLWFtczMud2FrdS5zYW5kYm94LnN0YXR1cy5pbQZ2XwAtNiZub2RlLTAxLmRvLWFtczMud2FrdS5zYW5kYm94LnN0YXR1cy5pbQYfQN4DgnJzkwABCAAAAAEAAgADAAQABQAGAAeJc2VjcDI1NmsxoQOTd-h5owwj-cx7xrmbvQKU8CV3Fomfdvcv1MBc-67T5oN0Y3CCdl-DdWRwgiMohXdha3UyDw",

View File

@ -42,7 +42,8 @@ import
../factory/internal_config,
../factory/external_config,
../factory/app_callbacks,
../waku_enr/multiaddr
../waku_enr/multiaddr,
./waku_conf
logScope:
topics = "wakunode waku"
@ -52,7 +53,7 @@ const git_version* {.strdefine.} = "n/a"
type Waku* = ref object
version: string
conf: WakuNodeConf
conf: WakuConf
rng: ref HmacDrbgContext
key: crypto.PrivateKey
@ -69,32 +70,6 @@ type Waku* = ref object
metricsServer*: MetricsHttpServerRef
appCallbacks*: AppCallbacks
proc logConfig(conf: WakuNodeConf) =
info "Configuration: Enabled protocols",
relay = conf.relay,
rlnRelay = conf.rlnRelay,
store = conf.store,
filter = conf.filter,
lightpush = conf.lightpush,
peerExchange = conf.peerExchange
info "Configuration. Network", cluster = conf.clusterId
for shard in conf.shards:
info "Configuration. Shards", shard = shard
for i in conf.discv5BootstrapNodes:
info "Configuration. Bootstrap nodes", node = i
if conf.rlnRelay and conf.rlnRelayDynamic:
info "Configuration. Validation",
mechanism = "onchain rln",
contract = conf.rlnRelayEthContractAddress,
maxMessageSize = conf.maxMessageSize,
rlnEpochSizeSec = conf.rlnEpochSizeSec,
rlnRelayUserMessageLimit = conf.rlnRelayUserMessageLimit,
rlnRelayEthClientAddress = string(conf.rlnRelayEthClientAddress)
func version*(waku: Waku): string =
waku.version
@ -170,11 +145,11 @@ proc setupAppCallbacks(
return ok()
proc new*(
T: type Waku, confCopy: var WakuNodeConf, appCallbacks: AppCallbacks = nil
T: type Waku, wakuConf: var WakuConf, appCallbacks: AppCallbacks = nil
): Result[Waku, string] =
let rng = crypto.newRng()
logging.setupLog(confCopy.logLevel, confCopy.logFormat)
logging.setupLog(wakuConf.logLevel, wakuConf.logFormat)
confCopy = block:
let res = applyPresetConfiguration(confCopy)
@ -183,7 +158,7 @@ proc new*(
return err("Failed to complete the config:" & $res.error)
res.get()
logConfig(confCopy)
wakuConf.log()
info "Running nwaku node", version = git_version