mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-05 11:34:45 +00:00
deploy: daaca4a4a38b748084569d2c2c1544d85b133b56
This commit is contained in:
parent
84c2bee07f
commit
4d52c68095
@ -508,29 +508,11 @@ proc processInput(rfd: AsyncFD, rng: ref BrHmacDrbgContext) {.async.} =
|
|||||||
echo "A spam message is found and discarded"
|
echo "A spam message is found and discarded"
|
||||||
chat.prompt = false
|
chat.prompt = false
|
||||||
showChatPrompt(chat)
|
showChatPrompt(chat)
|
||||||
|
echo "rln-relay preparation is in progress ..."
|
||||||
# set up rln relay inputs
|
node.mountRlnRelay(conf, some(spamHandler))
|
||||||
let (groupOpt, memKeyPairOpt, memIndexOpt) = rlnRelayStaticSetUp(conf.rlnRelayMemIndex)
|
echo "your membership index is: ", node.wakuRlnRelay.membershipIndex
|
||||||
if memIndexOpt.isNone:
|
echo "your rln identity key is: ", node.wakuRlnRelay.membershipKeyPair.idKey.toHex()
|
||||||
error "failed to mount WakuRLNRelay"
|
echo "your rln identity commitment key is: ", node.wakuRlnRelay.membershipKeyPair.idCommitment.toHex()
|
||||||
else:
|
|
||||||
# mount rlnrelay in offline mode (for now)
|
|
||||||
node.mountRlnRelayStatic(group = groupOpt.get(), memKeyPair = memKeyPairOpt.get(), memIndex = memIndexOpt.get(), pubsubTopic = conf.rlnRelayPubsubTopic, contentTopic = conf.rlnRelayContentTopic, spamHandler = some(spamHandler))
|
|
||||||
|
|
||||||
debug "membership id key", idkey=memKeyPairOpt.get().idKey.toHex
|
|
||||||
debug "membership id commitment key", idCommitmentkey=memKeyPairOpt.get().idCommitment.toHex
|
|
||||||
|
|
||||||
# check the correct construction of the tree by comparing the calculated root against the expected root
|
|
||||||
# no error should happen as it is already captured in the unit tests
|
|
||||||
# TODO have added this check to account for unseen corner cases, will remove it later
|
|
||||||
let
|
|
||||||
root = node.wakuRlnRelay.rlnInstance.getMerkleRoot.value.toHex()
|
|
||||||
expectedRoot = STATIC_GROUP_MERKLE_ROOT
|
|
||||||
if root != expectedRoot:
|
|
||||||
error "root mismatch: something went wrong not in Merkle tree construction"
|
|
||||||
debug "the calculated root", root
|
|
||||||
debug "WakuRLNRelay is mounted successfully", pubsubtopic=conf.rlnRelayPubsubTopic, contentTopic=conf.rlnRelayContentTopic
|
|
||||||
|
|
||||||
|
|
||||||
await chat.readWriteLoop()
|
await chat.readWriteLoop()
|
||||||
|
|
||||||
|
@ -248,7 +248,42 @@ type
|
|||||||
desc: "the pubsub topic for which rln-relay gets enabled",
|
desc: "the pubsub topic for which rln-relay gets enabled",
|
||||||
defaultValue: "/waku/2/default-waku/proto"
|
defaultValue: "/waku/2/default-waku/proto"
|
||||||
name: "rln-relay-pubsub-topic" }: string
|
name: "rln-relay-pubsub-topic" }: string
|
||||||
|
|
||||||
|
rlnRelayDynamic* {.
|
||||||
|
desc: "Enable waku-rln-relay with on-chain dynamic group management: true|false",
|
||||||
|
defaultValue: false
|
||||||
|
name: "rln-relay-dynamic" }: bool
|
||||||
|
|
||||||
|
rlnRelayIdKey* {.
|
||||||
|
desc: "Rln relay identity secret key as a Hex string",
|
||||||
|
defaultValue: ""
|
||||||
|
name: "rln-relay-id" }: string
|
||||||
|
|
||||||
|
rlnRelayIdCommitmentKey* {.
|
||||||
|
desc: "Rln relay identity commitment key as a Hex string",
|
||||||
|
defaultValue: ""
|
||||||
|
name: "rln-relay-id-commitment" }: string
|
||||||
|
|
||||||
|
rlnRelayEthAccount* {.
|
||||||
|
desc: "Ethereum account address for an Ethereum testnet",
|
||||||
|
defaultValue: ""
|
||||||
|
name: "eth-account-address" }: string
|
||||||
|
|
||||||
|
rlnRelayEthAccountPrivKey* {.
|
||||||
|
desc: "Account private key for an Ethereum testnet",
|
||||||
|
defaultValue: ""
|
||||||
|
name: "eth-account-privatekey" }: string
|
||||||
|
|
||||||
|
rlnRelayEthClientAddress* {.
|
||||||
|
desc: "Ethereum testnet client address e.g., ws://localhost:8540/",
|
||||||
|
defaultValue: "ws://localhost:8540/"
|
||||||
|
name: "eth-client-address" }: string
|
||||||
|
|
||||||
|
rlnRelayEthMemContractAddress* {.
|
||||||
|
desc: "Address of membership contract on an Ethereum testnet",
|
||||||
|
defaultValue: ""
|
||||||
|
name: "eth-mem-contract-address" }: string
|
||||||
|
|
||||||
# NOTE: Keys are different in nim-libp2p
|
# NOTE: Keys are different in nim-libp2p
|
||||||
proc parseCmdArg*(T: type crypto.PrivateKey, p: TaintedString): T =
|
proc parseCmdArg*(T: type crypto.PrivateKey, p: TaintedString): T =
|
||||||
try:
|
try:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# libtool - Provide generalized library-building support services.
|
# libtool - Provide generalized library-building support services.
|
||||||
# Generated automatically by config.status (libbacktrace) version-unused
|
# Generated automatically by config.status (libbacktrace) version-unused
|
||||||
# Libtool was configured on host fv-az182-332:
|
# Libtool was configured on host fv-az190-604:
|
||||||
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
|
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
|
||||||
#
|
#
|
||||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
|
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
|
||||||
|
@ -14,6 +14,7 @@ import
|
|||||||
rln,
|
rln,
|
||||||
waku_rln_relay_types,
|
waku_rln_relay_types,
|
||||||
../../node/[wakunode2_types,config],
|
../../node/[wakunode2_types,config],
|
||||||
|
../../../../../examples/v2/config_chat2,
|
||||||
../waku_message
|
../waku_message
|
||||||
|
|
||||||
|
|
||||||
@ -681,8 +682,8 @@ proc addRLNRelayValidator*(node: WakuNode, pubsubTopic: string, contentTopic: Co
|
|||||||
debug "A spam message is found! yay! discarding:", contentTopic=wakumessage.contentTopic, epoch=epoch, timestamp=wakumessage.timestamp, payload=payload
|
debug "A spam message is found! yay! discarding:", contentTopic=wakumessage.contentTopic, epoch=epoch, timestamp=wakumessage.timestamp, payload=payload
|
||||||
trace "A spam message is found! yay! discarding:", proof=proof, root=root, shareX=shareX, shareY=shareY, nullifier=nullifier
|
trace "A spam message is found! yay! discarding:", proof=proof, root=root, shareX=shareX, shareY=shareY, nullifier=nullifier
|
||||||
if spamHandler.isSome:
|
if spamHandler.isSome:
|
||||||
let handler = spamHandler.get
|
let handler = spamHandler.get
|
||||||
handler(wakumessage)
|
handler(wakumessage)
|
||||||
return pubsub.ValidationResult.Reject
|
return pubsub.ValidationResult.Reject
|
||||||
# set a validator for the supplied pubsubTopic
|
# set a validator for the supplied pubsubTopic
|
||||||
let pb = PubSub(node.wakuRelay)
|
let pb = PubSub(node.wakuRelay)
|
||||||
@ -818,7 +819,7 @@ proc mountRlnRelayDynamic*(node: WakuNode,
|
|||||||
node.wakuRlnRelay = rlnPeer
|
node.wakuRlnRelay = rlnPeer
|
||||||
|
|
||||||
|
|
||||||
proc mountRlnRelay*(node: WakuNode, conf: WakuNodeConf) {.raises: [Defect, ValueError, IOError, CatchableError].} =
|
proc mountRlnRelay*(node: WakuNode, conf: WakuNodeConf|Chat2Conf, spamHandler: Option[SpamHandler] = none(SpamHandler)) {.raises: [Defect, ValueError, IOError, CatchableError].} =
|
||||||
if not conf.rlnRelayDynamic:
|
if not conf.rlnRelayDynamic:
|
||||||
info " setting up waku-rln-relay in on-chain mode... "
|
info " setting up waku-rln-relay in on-chain mode... "
|
||||||
# set up rln relay inputs
|
# set up rln relay inputs
|
||||||
@ -827,7 +828,7 @@ proc mountRlnRelay*(node: WakuNode, conf: WakuNodeConf) {.raises: [Defect, Value
|
|||||||
error "failed to mount WakuRLNRelay"
|
error "failed to mount WakuRLNRelay"
|
||||||
else:
|
else:
|
||||||
# mount rlnrelay in off-chain mode with a static group of users
|
# mount rlnrelay in off-chain mode with a static group of users
|
||||||
node.mountRlnRelayStatic(group = groupOpt.get(), memKeyPair = memKeyPairOpt.get(), memIndex= memIndexOpt.get(), pubsubTopic = conf.rlnRelayPubsubTopic, contentTopic = conf.rlnRelayContentTopic)
|
node.mountRlnRelayStatic(group = groupOpt.get(), memKeyPair = memKeyPairOpt.get(), memIndex= memIndexOpt.get(), pubsubTopic = conf.rlnRelayPubsubTopic, contentTopic = conf.rlnRelayContentTopic, spamHandler = spamHandler)
|
||||||
|
|
||||||
info "membership id key", idkey=memKeyPairOpt.get().idKey.toHex
|
info "membership id key", idkey=memKeyPairOpt.get().idKey.toHex
|
||||||
info "membership id commitment key", idCommitmentkey=memKeyPairOpt.get().idCommitment.toHex
|
info "membership id commitment key", idCommitmentkey=memKeyPairOpt.get().idCommitment.toHex
|
||||||
@ -860,9 +861,9 @@ proc mountRlnRelay*(node: WakuNode, conf: WakuNodeConf) {.raises: [Defect, Value
|
|||||||
let keyPair = @[(rlnRelayId, rlnRelayIdCommitmentKey)]
|
let keyPair = @[(rlnRelayId, rlnRelayIdCommitmentKey)]
|
||||||
let memKeyPair = keyPair.toMembershipKeyPairs()[0]
|
let memKeyPair = keyPair.toMembershipKeyPairs()[0]
|
||||||
# mount the rln relay protocol in the on-chain/dynamic mode
|
# mount the rln relay protocol in the on-chain/dynamic mode
|
||||||
waitFor node.mountRlnRelayDynamic(memContractAddr = ethMemContractAddress, ethClientAddr = ethClientAddr, memKeyPair = some(memKeyPair), memIndex = some(rlnRelayIndex), ethAccAddr = ethAccountAddr, ethAccountPrivKey = ethAccountPrivKey, pubsubTopic = conf.rlnRelayPubsubTopic, contentTopic = conf.rlnRelayContentTopic)
|
waitFor node.mountRlnRelayDynamic(memContractAddr = ethMemContractAddress, ethClientAddr = ethClientAddr, memKeyPair = some(memKeyPair), memIndex = some(rlnRelayIndex), ethAccAddr = ethAccountAddr, ethAccountPrivKey = ethAccountPrivKey, pubsubTopic = conf.rlnRelayPubsubTopic, contentTopic = conf.rlnRelayContentTopic, spamHandler = spamHandler)
|
||||||
else:
|
else:
|
||||||
# no rln credential is provided
|
# no rln credential is provided
|
||||||
# mount the rln relay protocol in the on-chain/dynamic mode
|
# mount the rln relay protocol in the on-chain/dynamic mode
|
||||||
waitFor node.mountRlnRelayDynamic(memContractAddr = ethMemContractAddress, ethClientAddr = ethClientAddr, ethAccAddr = ethAccountAddr, ethAccountPrivKey = ethAccountPrivKey, pubsubTopic = conf.rlnRelayPubsubTopic, contentTopic = conf.rlnRelayContentTopic)
|
waitFor node.mountRlnRelayDynamic(memContractAddr = ethMemContractAddress, ethClientAddr = ethClientAddr, ethAccAddr = ethAccountAddr, ethAccountPrivKey = ethAccountPrivKey, pubsubTopic = conf.rlnRelayPubsubTopic, contentTopic = conf.rlnRelayContentTopic, spamHandler = spamHandler)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user