mirror of https://github.com/waku-org/nwaku.git
Increase rln-relay logging (#908)
* updates default rln-relay content topic * adds further debug and trace level logs * converts a debug level log to the trace level
This commit is contained in:
parent
06f20af7d4
commit
c9e82873f1
|
@ -106,7 +106,7 @@ type
|
||||||
|
|
||||||
rlnRelayContentTopic* {.
|
rlnRelayContentTopic* {.
|
||||||
desc: "the pubsub topic for which rln-relay gets enabled",
|
desc: "the pubsub topic for which rln-relay gets enabled",
|
||||||
defaultValue: "/toy-chat/2/huilong/proto"
|
defaultValue: "/toy-chat/2/luzhou/proto"
|
||||||
name: "rln-relay-content-topic" }: ContentTopic
|
name: "rln-relay-content-topic" }: ContentTopic
|
||||||
|
|
||||||
staticnodes* {.
|
staticnodes* {.
|
||||||
|
|
|
@ -495,22 +495,36 @@ when defined(rln):
|
||||||
debug "rln-relay topic validator is called"
|
debug "rln-relay topic validator is called"
|
||||||
let msg = WakuMessage.init(message.data)
|
let msg = WakuMessage.init(message.data)
|
||||||
if msg.isOk():
|
if msg.isOk():
|
||||||
let wakumessage = msg.value()
|
let
|
||||||
|
wakumessage = msg.value()
|
||||||
|
payload = string.fromBytes(wakumessage.payload)
|
||||||
|
|
||||||
# check the contentTopic
|
# check the contentTopic
|
||||||
if (wakumessage.contentTopic != "") and (contentTopic != "") and (wakumessage.contentTopic != contentTopic):
|
if (wakumessage.contentTopic != "") and (contentTopic != "") and (wakumessage.contentTopic != contentTopic):
|
||||||
debug "content topic did not match:", contentTopic=wakumessage.contentTopic, payload=string.fromBytes(wakumessage.payload)
|
debug "content topic did not match:", contentTopic=wakumessage.contentTopic, payload=payload
|
||||||
return pubsub.ValidationResult.Accept
|
return pubsub.ValidationResult.Accept
|
||||||
|
|
||||||
# validate the message
|
# validate the message
|
||||||
let validationRes = node.wakuRlnRelay.validateMessage(wakumessage)
|
let
|
||||||
|
validationRes = node.wakuRlnRelay.validateMessage(wakumessage)
|
||||||
|
proof = toHex(wakumessage.proof.proof)
|
||||||
|
epoch = fromEpoch(wakumessage.proof.epoch)
|
||||||
|
root = toHex(wakumessage.proof.merkleRoot)
|
||||||
|
shareX = toHex(wakumessage.proof.shareX)
|
||||||
|
shareY = toHex(wakumessage.proof.shareY)
|
||||||
|
nullifier = toHex(wakumessage.proof.nullifier)
|
||||||
case validationRes:
|
case validationRes:
|
||||||
of Valid:
|
of Valid:
|
||||||
debug "message validity is verified, relaying:", wakumessage=wakumessage, payload=string.fromBytes(wakumessage.payload)
|
debug "message validity is verified, relaying:", contentTopic=wakumessage.contentTopic, epoch=epoch, timestamp=wakumessage.timestamp, payload=payload
|
||||||
|
trace "message validity is verified, relaying:", proof=proof, root=root, shareX=shareX, shareY=shareY, nullifier=nullifier
|
||||||
return pubsub.ValidationResult.Accept
|
return pubsub.ValidationResult.Accept
|
||||||
of Invalid:
|
of Invalid:
|
||||||
debug "message validity could not be verified, discarding:", wakumessage=wakumessage, payload=string.fromBytes(wakumessage.payload)
|
debug "message validity could not be verified, discarding:", contentTopic=wakumessage.contentTopic, epoch=epoch, timestamp=wakumessage.timestamp, payload=payload
|
||||||
|
trace "message validity could not be verified, discarding:", proof=proof, root=root, shareX=shareX, shareY=shareY, nullifier=nullifier
|
||||||
return pubsub.ValidationResult.Reject
|
return pubsub.ValidationResult.Reject
|
||||||
of Spam:
|
of Spam:
|
||||||
debug "A spam message is found! yay! discarding:", wakumessage=wakumessage, payload=string.fromBytes(wakumessage.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
|
||||||
if spamHandler.isSome:
|
if spamHandler.isSome:
|
||||||
let handler = spamHandler.get
|
let handler = spamHandler.get
|
||||||
handler(wakumessage)
|
handler(wakumessage)
|
||||||
|
|
|
@ -224,7 +224,7 @@ proc proofVerify*(rlnInstance: RLN[Bn256], data: openArray[byte], proof: RateLim
|
||||||
proofBytes= serialize(proof, data)
|
proofBytes= serialize(proof, data)
|
||||||
proofBuffer = proofBytes.toBuffer()
|
proofBuffer = proofBytes.toBuffer()
|
||||||
f = 0.uint32
|
f = 0.uint32
|
||||||
debug "serialized proof", proof=proofBytes.toHex()
|
trace "serialized proof", proof=proofBytes.toHex()
|
||||||
|
|
||||||
let verifyIsSuccessful = verify(rlnInstance, addr proofBuffer, addr f)
|
let verifyIsSuccessful = verify(rlnInstance, addr proofBuffer, addr f)
|
||||||
if not verifyIsSuccessful:
|
if not verifyIsSuccessful:
|
||||||
|
|
Loading…
Reference in New Issue