Skip to content

Commit

Permalink
fix(rln-relay): waku_rln_number_registered_memberships metrics approp…
Browse files Browse the repository at this point in the history
…riately handled (#2018)
  • Loading branch information
rymnc authored Sep 11, 2023
1 parent 47ae19c commit a4e7833
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions waku/waku_rln_relay/group_manager/on_chain/group_manager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ method atomicBatch*(g: OnchainGroupManager,
let operationSuccess = g.rlnInstance.atomicWrite(some(start), idCommitments, toRemoveIndices)
if not operationSuccess:
raise newException(ValueError, "atomic batch operation failed")
waku_rln_number_registered_memberships.inc(int64(idCommitments.len - toRemoveIndices.len))
# TODO: when slashing is enabled, we need to track slashed members
waku_rln_number_registered_memberships.set(int64(start.int + idCommitments.len - toRemoveIndices.len))

if g.registerCb.isSome():
var membersSeq = newSeq[Membership]()
Expand Down Expand Up @@ -304,7 +305,7 @@ proc getAndHandleEvents(g: OnchainGroupManager,
toBlock: BlockNumber): Future[void] {.async.} =
initializedGuard(g)

let blockTable = await g.getBlockTable(fromBlock, toBlock)
let blockTable = await g.getBlockTable(fromBlock, toBlock)
await g.handleEvents(blockTable)
await g.handleRemovedEvents(blockTable)

Expand Down Expand Up @@ -544,4 +545,4 @@ method isReady*(g: OnchainGroupManager): Future[bool] {.async,gcsafe.} =
if g.latestProcessedBlock < currentBlock:
return false

return not (await g.isSyncing())
return not (await g.isSyncing())
3 changes: 2 additions & 1 deletion waku/waku_rln_relay/protocol_metrics.nim
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ declarePublicHistogram(identifier = waku_rln_valid_messages_total,
buckets = generateBucketsForHistogram(AcceptableRootWindowSize))
declarePublicCounter(waku_rln_errors_total, "number of errors detected while operating the rln relay", ["type"])
declarePublicCounter(waku_rln_proof_verification_total, "number of times the rln proofs are verified")
declarePublicCounter(waku_rln_number_registered_memberships, "number of registered and active rln memberships")
# this is a gauge so that we can set it based on the events we receive
declarePublicGauge(waku_rln_number_registered_memberships, "number of registered and active rln memberships")

# Timing metrics
declarePublicGauge(waku_rln_proof_verification_duration_seconds, "time taken to verify a proof")
Expand Down

0 comments on commit a4e7833

Please sign in to comment.