mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-05-07 23:39:42 +00:00
Improve logging of content topic on server (#3818)
This commit is contained in:
parent
509c875533
commit
ca4dbb19e0
@ -244,7 +244,8 @@ proc handleMessage*(
|
||||
) {.async.} =
|
||||
let msgHash = computeMessageHash(pubsubTopic, message).to0xHex()
|
||||
|
||||
info "handling message", pubsubTopic = pubsubTopic, msg_hash = msgHash
|
||||
info "handling message",
|
||||
pubsubTopic = pubsubTopic, contentTopic = message.contentTopic, msg_hash = msgHash
|
||||
|
||||
let handleMessageStartTime = Moment.now()
|
||||
|
||||
|
||||
@ -68,6 +68,7 @@ proc handleRequest(
|
||||
peer_id = peerId,
|
||||
requestId = pushRequest.requestId,
|
||||
pubsubTopic = pushRequest.pubsubTopic,
|
||||
contentTopic = pushRequest.message.contentTopic,
|
||||
msg_hash = msg_hash,
|
||||
receivedTime = getNowInNanosecondTime()
|
||||
|
||||
|
||||
@ -50,6 +50,7 @@ proc handleRequest*(
|
||||
peer_id = peerId,
|
||||
requestId = requestId,
|
||||
pubsubTopic = pubsubTopic,
|
||||
contentTopic = message.contentTopic,
|
||||
msg_hash = msg_hash,
|
||||
receivedTime = getNowInNanosecondTime()
|
||||
|
||||
|
||||
@ -223,6 +223,7 @@ proc logMessageInfo*(
|
||||
msg_id = msg_id_short,
|
||||
from_peer_id = remotePeerId,
|
||||
topic = topic,
|
||||
contentTopic = msg.contentTopic,
|
||||
receivedTime = getNowInNanosecondTime(),
|
||||
payloadSizeBytes = payloadSize
|
||||
else:
|
||||
@ -232,6 +233,7 @@ proc logMessageInfo*(
|
||||
msg_id = msg_id_short,
|
||||
to_peer_id = remotePeerId,
|
||||
topic = topic,
|
||||
contentTopic = msg.contentTopic,
|
||||
sentTime = getNowInNanosecondTime(),
|
||||
payloadSizeBytes = payloadSize
|
||||
|
||||
@ -680,7 +682,8 @@ proc publish*(
|
||||
let data = message.encode().buffer
|
||||
|
||||
let msgHash = computeMessageHash(pubsubTopic, message).to0xHex()
|
||||
notice "start publish Waku message", msg_hash = msgHash, pubsubTopic = pubsubTopic
|
||||
notice "start publish Waku message",
|
||||
msg_hash = msgHash, pubsubTopic = pubsubTopic, contentTopic = message.contentTopic
|
||||
|
||||
let relayedPeerCount = await procCall GossipSub(w).publish(pubsubTopic, data)
|
||||
|
||||
|
||||
@ -201,14 +201,18 @@ proc validateMessage*(
|
||||
|
||||
if timeDiff > rlnPeer.rlnMaxTimestampGap:
|
||||
warn "invalid message: timestamp difference exceeds threshold",
|
||||
timeDiff = timeDiff, maxTimestampGap = rlnPeer.rlnMaxTimestampGap
|
||||
timeDiff = timeDiff,
|
||||
maxTimestampGap = rlnPeer.rlnMaxTimestampGap,
|
||||
contentTopic = msg.contentTopic
|
||||
waku_rln_invalid_messages_total.inc(labelValues = ["invalid_timestamp"])
|
||||
return MessageValidationResult.Invalid
|
||||
|
||||
let computedEpoch = rlnPeer.calcEpoch(messageTime)
|
||||
if proof.epoch != computedEpoch:
|
||||
warn "invalid message: timestamp mismatches epoch",
|
||||
proofEpoch = fromEpoch(proof.epoch), computedEpoch = fromEpoch(computedEpoch)
|
||||
proofEpoch = fromEpoch(proof.epoch),
|
||||
computedEpoch = fromEpoch(computedEpoch),
|
||||
contentTopic = msg.contentTopic
|
||||
waku_rln_invalid_messages_total.inc(labelValues = ["timestamp_mismatch"])
|
||||
return MessageValidationResult.Invalid
|
||||
|
||||
@ -216,7 +220,8 @@ proc validateMessage*(
|
||||
if not rootValidationRes:
|
||||
warn "invalid message: provided root does not belong to acceptable window of roots",
|
||||
provided = proof.merkleRoot.inHex(),
|
||||
validRoots = rlnPeer.groupManager.validRoots.mapIt(it.inHex())
|
||||
validRoots = rlnPeer.groupManager.validRoots.mapIt(it.inHex()),
|
||||
contentTopic = msg.contentTopic
|
||||
waku_rln_invalid_messages_total.inc(labelValues = ["invalid_root"])
|
||||
return MessageValidationResult.Invalid
|
||||
|
||||
@ -233,12 +238,14 @@ proc validateMessage*(
|
||||
|
||||
proofVerificationRes.isOkOr:
|
||||
waku_rln_errors_total.inc(labelValues = ["proof_verification"])
|
||||
warn "invalid message: proof verification failed", payloadLen = msg.payload.len
|
||||
warn "invalid message: proof verification failed",
|
||||
payloadLen = msg.payload.len, contentTopic = msg.contentTopic
|
||||
return MessageValidationResult.Invalid
|
||||
|
||||
if not proofVerificationRes.value():
|
||||
# invalid proof
|
||||
warn "invalid message: invalid proof", payloadLen = msg.payload.len
|
||||
warn "invalid message: invalid proof",
|
||||
payloadLen = msg.payload.len, contentTopic = msg.contentTopic
|
||||
waku_rln_invalid_messages_total.inc(labelValues = ["invalid_proof"])
|
||||
return MessageValidationResult.Invalid
|
||||
|
||||
@ -252,11 +259,13 @@ proc validateMessage*(
|
||||
if hasDup.isErr():
|
||||
waku_rln_errors_total.inc(labelValues = ["duplicate_check"])
|
||||
elif hasDup.value == true:
|
||||
trace "invalid message: message is spam", payloadLen = msg.payload.len
|
||||
trace "invalid message: message is spam",
|
||||
payloadLen = msg.payload.len, contentTopic = msg.contentTopic
|
||||
waku_rln_spam_messages_total.inc()
|
||||
return MessageValidationResult.Spam
|
||||
|
||||
trace "message is valid", payloadLen = msg.payload.len
|
||||
trace "message is valid",
|
||||
payloadLen = msg.payload.len, contentTopic = msg.contentTopic
|
||||
# Metric increment moved to validator to include shard label
|
||||
return MessageValidationResult.Valid
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user