diff --git a/waku/factory/conf_builder/eligibility_conf_builder.nim b/waku/factory/conf_builder/eligibility_conf_builder.nim index 615e73175..a552606ee 100644 --- a/waku/factory/conf_builder/eligibility_conf_builder.nim +++ b/waku/factory/conf_builder/eligibility_conf_builder.nim @@ -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" diff --git a/waku/factory/external_config.nim b/waku/factory/external_config.nim index df9962abf..7e33ffd7c 100644 --- a/waku/factory/external_config.nim +++ b/waku/factory/external_config.nim @@ -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 diff --git a/waku/factory/node_factory.nim b/waku/factory/node_factory.nim index 8ad019812..a5ad86178 100644 --- a/waku/factory/node_factory.nim +++ b/waku/factory/node_factory.nim @@ -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