Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(rln-db-inspector): add more logging to find zero leaf indices #2617

Merged
merged 3 commits into from
Apr 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tools/rln_db_inspector/rln_db_inspector.nim
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,29 @@ proc doInspectRlnDb*(conf: WakuNodeConf) =
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)
Loading