chore(rln_db_inspector): include in wakunode2 binary (#2292)

This commit is contained in:
Aaryamann Challani 2024-03-06 19:38:43 +05:30 committed by GitHub
parent 0def4904f2
commit a9d0e48164
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 52 additions and 57 deletions

View File

@ -14,6 +14,7 @@ import
libp2p/crypto/crypto libp2p/crypto/crypto
import import
../../tools/rln_keystore_generator/rln_keystore_generator, ../../tools/rln_keystore_generator/rln_keystore_generator,
../../tools/rln_db_inspector/rln_db_inspector,
../../waku/common/logging, ../../waku/common/logging,
../../waku/factory/external_config, ../../waku/factory/external_config,
./networks_config, ./networks_config,
@ -86,6 +87,8 @@ when isMainModule:
case conf.cmd case conf.cmd
of generateRlnKeystore: of generateRlnKeystore:
doRlnKeystoreGenerator(conf) doRlnKeystoreGenerator(conf)
of inspectRlnDb:
doInspectRlnDb(conf)
of noCommand: of noCommand:
# The Waku Network config (cluster-id=1) # The Waku Network config (cluster-id=1)
if conf.clusterId == 1: if conf.clusterId == 1:

View File

@ -0,0 +1,36 @@
# rln-db-inspector
This document describes how to run and use the `rln-db-inspector` tool.
It is meant to be used to debug and fetch the metadata stored in the RLN tree db.
## Pre-requisites
1. An existing RLN tree db
## Usage
1. First, we compile the binary
```bash
make -j16 wakunode2
```
This command will fetch the rln static library and link it automatically.
2. Define the arguments you wish to use
```bash
export RLN_TREE_DB_PATH="xxx"
```
3. Run the db inspector
```bash
./build/wakunode2 inspectRlnDb \
--rln-relay-tree-path:$RLN_TREE_DB_PATH
```
What this does is -
a. loads the tree db from the path provided
b. Logs out the metadata, including, number of leaves set, past 5 merkle roots, last synced block number

View File

@ -0,0 +1,3 @@
# rln_db_inspector
Documentation on running the `rln-db-inspector` can be found [here](../../docs/tutorial/rln-db-inspector.md)

View File

@ -1,47 +0,0 @@
when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import
stew/results,
chronos,
confutils,
confutils/defs,
confutils/toml/defs as confTomlDefs,
confutils/toml/std/net as confTomlNet,
libp2p/crypto/crypto,
libp2p/crypto/secp,
libp2p/multiaddress,
secp256k1
import
../../waku/common/confutils/envvar/defs as confEnvvarDefs,
../../waku/common/confutils/envvar/std/net as confEnvvarNet
export
confTomlDefs,
confTomlNet,
confEnvvarDefs,
confEnvvarNet
type
RlnDbInspectorConf* = object
configFile* {.
desc: "Loads configuration from a TOML file (cmd-line parameters take precedence)",
name: "config-file" }: Option[InputFile]
## General node config
rlnRelayTreePath* {.
desc: "The path to the rln-relay tree",
defaultValue: "",
name: "rln-relay-tree-path" }: string
proc loadConfig*(T: type RlnDbInspectorConf): Result[T, string] =
try:
let conf = RlnDbInspectorConf.load()
if conf.rlnRelayTreePath == "":
return err("--rln-relay-tree-path must be set")
ok(conf)
except CatchableError, Exception:
err(getCurrentExceptionMsg())

View File

@ -1,3 +0,0 @@
-d:chronicles_line_numbers
-d:chronicles_runtime_filtering=on
#-d:"chronicles_enabled_topics=GossipSub:TRACE,WakuRelay:TRACE"

View File

@ -16,18 +16,13 @@ import
logScope: logScope:
topics = "rln_db_inspector" topics = "rln_db_inspector"
when isMainModule: proc doInspectRlnDb*(conf: WakuNodeConf) =
{.pop.}
# 1. load configuration # 1. load configuration
let conf = RlnDbInspectorConf.loadConfig().valueOr:
error "failure while loading the configuration", error
quit(1)
trace "configuration", conf = $conf trace "configuration", conf = $conf
# 2. initialize rlnInstance # 2. initialize rlnInstance
let rlnInstance = createRLNInstance(d=20, let rlnInstance = createRLNInstance(d=20,
tree_path = conf.rlnRelayTreePath).valueOr: tree_path = conf.treePath).valueOr:
error "failure while creating RLN instance", error error "failure while creating RLN instance", error
quit(1) quit(1)

View File

@ -41,6 +41,7 @@ type EthRpcUrl = distinct string
type StartUpCommand* = enum type StartUpCommand* = enum
noCommand # default, runs waku noCommand # default, runs waku
generateRlnKeystore # generates a new RLN keystore generateRlnKeystore # generates a new RLN keystore
inspectRlnDb # Inspects a given RLN tree db, providing essential db stats
type type
WakuNodeConf* = object WakuNodeConf* = object
@ -103,6 +104,13 @@ type
command command
defaultValue: noCommand }: StartUpCommand defaultValue: noCommand }: StartUpCommand
of inspectRlnDb:
# have to change the name here since it counts as a duplicate, within noCommand
treePath* {.
desc: "Path to the RLN merkle tree sled db (https://github.com/spacejam/sled)",
defaultValue: ""
name: "rln-relay-tree-path" .}: string
of generateRlnKeystore: of generateRlnKeystore:
execute* {. execute* {.
desc: "Runs the registration function on-chain. By default, a dry-run will occur", desc: "Runs the registration function on-chain. By default, a dry-run will occur",