mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-14 17:04:53 +00:00
chore(rln-relay): log levels for certain logs (#1986)
This commit is contained in:
parent
4ed414576a
commit
97a7c9d04d
@ -195,7 +195,7 @@ proc validateMessage*(rlnPeer: WakuRLNRelay,
|
|||||||
# calculate the gaps
|
# calculate the gaps
|
||||||
gap = absDiff(epoch, msgEpoch)
|
gap = absDiff(epoch, msgEpoch)
|
||||||
|
|
||||||
debug "epoch info", currentEpoch = fromEpoch(epoch), msgEpoch = fromEpoch(msgEpoch)
|
trace "epoch info", currentEpoch = fromEpoch(epoch), msgEpoch = fromEpoch(msgEpoch)
|
||||||
|
|
||||||
# validate the epoch
|
# validate the epoch
|
||||||
if gap > MaxEpochGap:
|
if gap > MaxEpochGap:
|
||||||
@ -208,7 +208,7 @@ proc validateMessage*(rlnPeer: WakuRLNRelay,
|
|||||||
|
|
||||||
let rootValidationRes = rlnPeer.groupManager.validateRoot(proof.merkleRoot)
|
let rootValidationRes = rlnPeer.groupManager.validateRoot(proof.merkleRoot)
|
||||||
if not rootValidationRes:
|
if not rootValidationRes:
|
||||||
debug "invalid message: provided root does not belong to acceptable window of roots", provided=proof.merkleRoot.inHex(), validRoots=rlnPeer.groupManager.validRoots.mapIt(it.inHex())
|
warn "invalid message: provided root does not belong to acceptable window of roots", provided=proof.merkleRoot.inHex(), validRoots=rlnPeer.groupManager.validRoots.mapIt(it.inHex())
|
||||||
waku_rln_invalid_messages_total.inc(labelValues=["invalid_root"])
|
waku_rln_invalid_messages_total.inc(labelValues=["invalid_root"])
|
||||||
return MessageValidationResult.Invalid
|
return MessageValidationResult.Invalid
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ proc validateMessage*(rlnPeer: WakuRLNRelay,
|
|||||||
return MessageValidationResult.Invalid
|
return MessageValidationResult.Invalid
|
||||||
if not proofVerificationRes.value():
|
if not proofVerificationRes.value():
|
||||||
# invalid proof
|
# invalid proof
|
||||||
debug "invalid message: invalid proof", payloadLen = msg.payload.len
|
warn "invalid message: invalid proof", payloadLen = msg.payload.len
|
||||||
waku_rln_invalid_messages_total.inc(labelValues=["invalid_proof"])
|
waku_rln_invalid_messages_total.inc(labelValues=["invalid_proof"])
|
||||||
return MessageValidationResult.Invalid
|
return MessageValidationResult.Invalid
|
||||||
|
|
||||||
@ -240,11 +240,11 @@ proc validateMessage*(rlnPeer: WakuRLNRelay,
|
|||||||
if hasDup.isErr():
|
if hasDup.isErr():
|
||||||
waku_rln_errors_total.inc(labelValues=["duplicate_check"])
|
waku_rln_errors_total.inc(labelValues=["duplicate_check"])
|
||||||
elif hasDup.value == true:
|
elif hasDup.value == true:
|
||||||
debug "invalid message: message is spam", payloadLen = msg.payload.len
|
trace "invalid message: message is spam", payloadLen = msg.payload.len
|
||||||
waku_rln_spam_messages_total.inc()
|
waku_rln_spam_messages_total.inc()
|
||||||
return MessageValidationResult.Spam
|
return MessageValidationResult.Spam
|
||||||
|
|
||||||
debug "message is valid", payloadLen = msg.payload.len
|
trace "message is valid", payloadLen = msg.payload.len
|
||||||
let rootIndex = rlnPeer.groupManager.indexOfRoot(proof.merkleRoot)
|
let rootIndex = rlnPeer.groupManager.indexOfRoot(proof.merkleRoot)
|
||||||
waku_rln_valid_messages_total.observe(rootIndex.toFloat())
|
waku_rln_valid_messages_total.observe(rootIndex.toFloat())
|
||||||
return MessageValidationResult.Valid
|
return MessageValidationResult.Valid
|
||||||
@ -314,9 +314,9 @@ proc generateRlnValidator*(wakuRlnRelay: WakuRLNRelay,
|
|||||||
wakuRlnRelay.messageBucket.get().tryConsume(message.data.len):
|
wakuRlnRelay.messageBucket.get().tryConsume(message.data.len):
|
||||||
return pubsub.ValidationResult.Accept
|
return pubsub.ValidationResult.Accept
|
||||||
else:
|
else:
|
||||||
info "message bandwidth limit exceeded, running rate limit proof validation"
|
trace "message bandwidth limit exceeded, running rate limit proof validation"
|
||||||
except OverflowDefect: # not a problem
|
except OverflowDefect: # not a problem
|
||||||
debug "not enough bandwidth, running rate limit proof validation"
|
trace "not enough bandwidth, running rate limit proof validation"
|
||||||
|
|
||||||
let decodeRes = WakuMessage.decode(message.data)
|
let decodeRes = WakuMessage.decode(message.data)
|
||||||
if decodeRes.isOk():
|
if decodeRes.isOk():
|
||||||
@ -341,15 +341,12 @@ proc generateRlnValidator*(wakuRlnRelay: WakuRLNRelay,
|
|||||||
payload = string.fromBytes(wakumessage.payload)
|
payload = string.fromBytes(wakumessage.payload)
|
||||||
case validationRes:
|
case validationRes:
|
||||||
of Valid:
|
of Valid:
|
||||||
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
|
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:", 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
|
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:", 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()
|
||||||
@ -411,7 +408,6 @@ proc new*(T: type WakuRlnRelay,
|
|||||||
## Mounts the rln-relay protocol on the node.
|
## Mounts the rln-relay protocol on the node.
|
||||||
## The rln-relay protocol can be mounted in two modes: on-chain and off-chain.
|
## The rln-relay protocol can be mounted in two modes: on-chain and off-chain.
|
||||||
## Returns an error if the rln-relay protocol could not be mounted.
|
## Returns an error if the rln-relay protocol could not be mounted.
|
||||||
debug "rln-relay input validation passed"
|
|
||||||
try:
|
try:
|
||||||
let rlnRelay = await mount(conf, registrationHandler)
|
let rlnRelay = await mount(conf, registrationHandler)
|
||||||
return ok(rlnRelay)
|
return ok(rlnRelay)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user