mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-07 16:33:08 +00:00
chore: debug mesage to find flow
This commit is contained in:
parent
6afd781773
commit
ed5e2d517e
@ -11,6 +11,7 @@ proc unsafeAppendRLNProof*(
|
||||
## this proc derived from appendRLNProof, does not perform nonce check to
|
||||
## facilitate bad message id generation for testing
|
||||
|
||||
debug "calling generateProof from unsafeAppendRLNProof from waku_rln_relay_utils"
|
||||
let input = msg.toRLNSignal()
|
||||
let epoch = rlnPeer.calcEpoch(senderEpochTime)
|
||||
|
||||
|
||||
@ -70,6 +70,7 @@ proc sendRlnMessageWithInvalidProof*(
|
||||
completionFuture: Future[bool],
|
||||
payload: seq[byte] = "Hello".toBytes(),
|
||||
): Future[bool] {.async.} =
|
||||
debug "calling generateProof from sendRlnMessageWithInvalidProof from utils_static"
|
||||
let
|
||||
extraBytes: seq[byte] = @[byte(1), 2, 3]
|
||||
rateLimitProofRes = client.wakuRlnRelay.groupManager.generateProof(
|
||||
|
||||
@ -265,6 +265,7 @@ proc installRelayApiHandlers*(
|
||||
error "publish error", err = msg
|
||||
return RestApiResponse.badRequest("Failed to publish. " & msg)
|
||||
|
||||
debug "calling appendRLNProof from post_waku_v2_relay_v1_auto_messages_no_topic"
|
||||
# if RLN is mounted, append the proof to the message
|
||||
if not node.wakuRlnRelay.isNil():
|
||||
node.wakuRlnRelay.appendRLNProof(message, float64(getTime().toUnix())).isOkOr:
|
||||
@ -272,6 +273,7 @@ proc installRelayApiHandlers*(
|
||||
"Failed to publish: error appending RLN proof to message: " & $error
|
||||
)
|
||||
|
||||
debug "calling validateMessage from post_waku_v2_relay_v1_auto_messages_no_topic"
|
||||
(await node.wakuRelay.validateMessage(pubsubTopic, message)).isOkOr:
|
||||
return RestApiResponse.badRequest("Failed to publish: " & error)
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ proc checkAndGenerateRLNProof*(
|
||||
rlnPeer: Option[WakuRLNRelay], message: WakuMessage
|
||||
): Result[WakuMessage, string] =
|
||||
# check if the message already has RLN proof
|
||||
debug "calling appendRLNProof from checkAndGenerateRLNProof from waku_lightpush_legacy"
|
||||
if message.proof.len > 0:
|
||||
return ok(message)
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ import
|
||||
../protocol_metrics,
|
||||
../constants,
|
||||
../rln
|
||||
import options, chronos, results, std/[deques, sequtils]
|
||||
import options, chronos, results, std/[deques, sequtils], chronicles
|
||||
|
||||
export options, chronos, results, protocol_types, protocol_metrics, deques
|
||||
|
||||
@ -145,6 +145,17 @@ method validateRoot*(
|
||||
g: GroupManager, root: MerkleNode
|
||||
): bool {.base, gcsafe, raises: [].} =
|
||||
## validates the root against the valid roots queue
|
||||
# Print all validRoots in one line with square brackets
|
||||
var rootsStr = "["
|
||||
var first = true
|
||||
for r in g.validRoots.items():
|
||||
if not first:
|
||||
rootsStr.add(", ")
|
||||
rootsStr.add($r)
|
||||
first = false
|
||||
rootsStr.add("]")
|
||||
debug "Valid Merkle roots in validateRoot", roots = rootsStr, root_to_validate = root
|
||||
|
||||
# Check if the root is in the valid roots queue
|
||||
if g.indexOfRoot(root) >= 0:
|
||||
return true
|
||||
@ -189,6 +200,9 @@ method generateProof*(
|
||||
return err("membership index is not set")
|
||||
if g.userMessageLimit.isNone():
|
||||
return err("user message limit is not set")
|
||||
|
||||
debug "calling proofGen from generateProof from group_manager_base", data = data
|
||||
|
||||
waku_rln_proof_generation_duration_seconds.nanosecondTime:
|
||||
let proof = proofGen(
|
||||
rlnInstance = g.rlnInstance,
|
||||
|
||||
@ -193,6 +193,8 @@ proc validateMessage*(
|
||||
## `timeOption` indicates Unix epoch time (fractional part holds sub-seconds)
|
||||
## if `timeOption` is supplied, then the current epoch is calculated based on that
|
||||
|
||||
debug "calling validateMessage from rln_relay", msg = msg
|
||||
|
||||
let decodeRes = RateLimitProof.init(msg.proof)
|
||||
if decodeRes.isErr():
|
||||
return MessageValidationResult.Invalid
|
||||
@ -312,6 +314,8 @@ proc appendRLNProof*(
|
||||
let input = msg.toRLNSignal()
|
||||
let epoch = rlnPeer.calcEpoch(senderEpochTime)
|
||||
|
||||
debug "calling generateProof from appendRLNProof from rln_relay", input = input
|
||||
|
||||
let nonce = rlnPeer.nonceManager.getNonce().valueOr:
|
||||
return err("could not get new message id to generate an rln proof: " & $error)
|
||||
let proof = rlnPeer.groupManager.generateProof(input, epoch, nonce).valueOr:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user