Skip to content

Commit

Permalink
chore(rln_db_inspector): include in wakunode2 binary (#2292)
Browse files Browse the repository at this point in the history
  • Loading branch information
rymnc authored Mar 6, 2024
1 parent 0def490 commit a9d0e48
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 57 deletions.
3 changes: 3 additions & 0 deletions apps/wakunode2/wakunode2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import
libp2p/crypto/crypto
import
../../tools/rln_keystore_generator/rln_keystore_generator,
../../tools/rln_db_inspector/rln_db_inspector,
../../waku/common/logging,
../../waku/factory/external_config,
./networks_config,
Expand Down Expand Up @@ -86,6 +87,8 @@ when isMainModule:
case conf.cmd
of generateRlnKeystore:
doRlnKeystoreGenerator(conf)
of inspectRlnDb:
doInspectRlnDb(conf)
of noCommand:
# The Waku Network config (cluster-id=1)
if conf.clusterId == 1:
Expand Down
36 changes: 36 additions & 0 deletions docs/tutorial/rln-db-inspector.md
Original file line number Diff line number Diff line change
@@ -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

3 changes: 3 additions & 0 deletions tools/rln_db_inspector/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# rln_db_inspector

Documentation on running the `rln-db-inspector` can be found [here](../../docs/tutorial/rln-db-inspector.md)
47 changes: 0 additions & 47 deletions tools/rln_db_inspector/external_config.nim

This file was deleted.

3 changes: 0 additions & 3 deletions tools/rln_db_inspector/nim.cfg

This file was deleted.

9 changes: 2 additions & 7 deletions tools/rln_db_inspector/rln_db_inspector.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,13 @@ import
logScope:
topics = "rln_db_inspector"

when isMainModule:
{.pop.}
proc doInspectRlnDb*(conf: WakuNodeConf) =
# 1. load configuration
let conf = RlnDbInspectorConf.loadConfig().valueOr:
error "failure while loading the configuration", error
quit(1)

trace "configuration", conf = $conf

# 2. initialize rlnInstance
let rlnInstance = createRLNInstance(d=20,
tree_path = conf.rlnRelayTreePath).valueOr:
tree_path = conf.treePath).valueOr:
error "failure while creating RLN instance", error
quit(1)

Expand Down
8 changes: 8 additions & 0 deletions waku/factory/external_config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type EthRpcUrl = distinct string
type StartUpCommand* = enum
noCommand # default, runs waku
generateRlnKeystore # generates a new RLN keystore
inspectRlnDb # Inspects a given RLN tree db, providing essential db stats

type
WakuNodeConf* = object
Expand Down Expand Up @@ -103,6 +104,13 @@ type
command
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:
execute* {.
desc: "Runs the registration function on-chain. By default, a dry-run will occur",
Expand Down

0 comments on commit a9d0e48

Please sign in to comment.