From 9ef5dc4adf286e2be36c3191242fbb8a16f7cc40 Mon Sep 17 00:00:00 2001 From: rymnc <43716372+rymnc@users.noreply.github.com> Date: Tue, 23 Apr 2024 12:56:05 +0200 Subject: [PATCH 1/2] chore(rln-db-inspector): add more logging to find zero leaf indices --- tools/rln_db_inspector/rln_db_inspector.nim | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/rln_db_inspector/rln_db_inspector.nim b/tools/rln_db_inspector/rln_db_inspector.nim index eed618df58..90607e10f8 100644 --- a/tools/rln_db_inspector/rln_db_inspector.nim +++ b/tools/rln_db_inspector/rln_db_inspector.nim @@ -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 = 0 + 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) From 1ce258df5c2b9f75e87cc63f7bf26ed35115c1dd Mon Sep 17 00:00:00 2001 From: rymnc <43716372+rymnc@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:51:54 +0200 Subject: [PATCH 2/2] fix: assumeEmptyAfter var --- tools/rln_db_inspector/rln_db_inspector.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/rln_db_inspector/rln_db_inspector.nim b/tools/rln_db_inspector/rln_db_inspector.nim index 90607e10f8..0820e255fe 100644 --- a/tools/rln_db_inspector/rln_db_inspector.nim +++ b/tools/rln_db_inspector/rln_db_inspector.nim @@ -41,7 +41,7 @@ proc doInspectRlnDb*(conf: WakuNodeConf) = var index: uint = 0 var hits: uint = 0 var zeroLeafIndices: seq[uint] = @[] - var assumeEmptyAfter: uint = 0 + var assumeEmptyAfter: uint = 10 while true: let leaf = rlnInstance.getMember(index).valueOr: error "failure while getting RLN leaf", error