fryorcraken cc66c7fe78 chore!: separate internal and CLI configurations (#3357)
Split `WakuNodeConfig` object for better separation of concerns and to introduce a tree-like structure to configuration.

* fix: ensure twn cluster conf is still applied when clusterId=1
* test: remove usage of `WakuNodeConf`
* Remove macro, split builder files, remove wakunodeconf from tests
* rm network_conf_builder module as it is not used

---------

Co-authored-by: NagyZoltanPeter <113987313+NagyZoltanPeter@users.noreply.github.com>
Co-authored-by: Ivan Folgueira Bande <ivansete@status.im>
2025-05-07 23:05:35 +02:00

67 lines
1.8 KiB
Nim

when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import chronicles, sequtils, results
import waku/[waku_rln_relay/rln, waku_rln_relay/conversion_utils]
logScope:
topics = "rln_db_inspector"
type InspectRlnDbConf* = object
treePath*: string
proc doInspectRlnDb*(conf: InspectRlnDbConf) =
# 1. load configuration
trace "configuration", conf = $conf
# 2. initialize rlnInstance
let rlnInstance = createRLNInstance(d = 20, tree_path = conf.treePath).valueOr:
error "failure while creating RLN instance", error
quit(1)
# 3. get metadata
let metadataOpt = rlnInstance.getMetadata().valueOr:
error "failure while getting RLN metadata", error
quit(1)
if metadataOpt.isNone():
error "RLN metadata does not exist"
quit(1)
let metadata = metadataOpt.get()
info "RLN metadata",
lastProcessedBlock = metadata.lastProcessedBlock,
chainId = metadata.chainId,
contractAddress = metadata.contractAddress,
validRoots = metadata.validRoots.mapIt(it.inHex())
var index: uint = 0
var hits: uint = 0
var zeroLeafIndices: seq[uint] = @[]
var assumeEmptyAfter: uint = 10
while true:
let leaf = rlnInstance.getMember(index).valueOr:
error "failure while getting RLN leaf", error
quit(1)
if leaf.inHex() == "0000000000000000000000000000000000000000000000000000000000000000":
zeroLeafIndices.add(index)
hits = hits + 1
else:
hits = 0
if hits > assumeEmptyAfter:
info "reached end of RLN tree", index = index - assumeEmptyAfter
# remove zeroLeafIndices that are not at the end of the tree
zeroLeafIndices = zeroLeafIndices.filterIt(it < index - assumeEmptyAfter)
break
index = index + 1
info "zero leaf indices", zeroLeafIndices
quit(0)