[WIP] initialize EligibilityManager properly

This commit is contained in:
Sergei Tikhomirov 2025-06-25 17:52:48 +02:00
parent 1e1d89ec93
commit 3cd3e58fec
3 changed files with 20 additions and 5 deletions

View File

@ -42,6 +42,7 @@ proc build*(b: EligibilityConfBuilder): Result[Option[EligibilityConf], string]
debug "eligibility: EligibilityConf validation failed - payment amount is zero"
return err("Eligibility: payment amount must be above zero")
# FIXME: how to reuse Eth RPC URL from RLN (?) config?
let urls = b.ethClientUrls.get(@[])
if urls.len == 0:
debug "eligibility: EligibilityConf validation failed - no eth rpc urls"

View File

@ -519,7 +519,7 @@ type WakuNodeConf* = object
reliabilityEnabled* {.
desc:
"""Adds an extra effort in the delivery/reception of messages by leveraging store-v3 requests.
with the drawback of consuming some more bandwidth.""",
with the drawback of consuming some more bandwidth.""",
defaultValue: false,
name: "reliability"
.}: bool

View File

@ -36,7 +36,8 @@ import
../node/peer_manager/peer_store/migrations as peer_store_sqlite_migrations,
../waku_lightpush_legacy/common,
../common/rate_limit/setting,
../common/databases/dburl
../common/databases/dburl,
../incentivization/eligibility_manager
## Peer persistence
@ -439,9 +440,22 @@ proc setupProtocols(
return
err("failed to set node waku peer-exchange peer: " & peerExchangeNode.error)
# set up eligibility check (i13n POC)
# check that: rlnRelay is mounted; Lightpush is mounted
# FIXME: conf items are not propagated here; where are they parsed?
# initialize eligibility manager if eligibility is enabled
if conf.eligibilityConf.isSome() and conf.eligibilityConf.get().enabled:
# Check that RLN Relay and Lightpush are mounted
if node.wakuRlnRelay.isNil or node.wakuLightPush.isNil:
return err("Eligibility manager requires both RLN Relay and Lightpush protocols to be mounted")
let ethUrl = conf.eligibilityConf.get().ethClientUrls[0]
try:
let manager = await EligibilityManager.init(ethUrl)
node.peerManager.eligibilityManager = some(manager)
except CatchableError:
return err("failed to initialize eligibility manager: " & getCurrentExceptionMsg())
# TODO: figure out where to store conf: expected address and expected amount
# NOtE: consider both client's and server's perspective!
#if conf.eligibilityEnabled:
# debug "i13n: eligibility enabled!"
# debug "eligibilityReceiverAddress:", conf.eligibilityReceiverAddress