From 545c08bb3ec789fb6c8496a9a33b8653df9738b3 Mon Sep 17 00:00:00 2001 From: Ivan Folgueira Bande Date: Fri, 29 Nov 2024 16:07:27 +0100 Subject: [PATCH] filter: add better debug logs --- waku/waku_filter_v2/client.nim | 27 ++++++++++++++++++++------- waku/waku_filter_v2/protocol.nim | 2 ++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/waku/waku_filter_v2/client.nim b/waku/waku_filter_v2/client.nim index 617648aff..8dadb46e9 100644 --- a/waku/waku_filter_v2/client.nim +++ b/waku/waku_filter_v2/client.nim @@ -2,7 +2,13 @@ {.push raises: [].} -import std/options, chronicles, chronos, libp2p/protocols/protocol, bearssl/rand +import + std/options, + chronicles, + chronos, + libp2p/protocols/protocol, + bearssl/rand, + stew/byteutils import ../node/peer_manager, ../node/delivery_monitor/subscriptions_observer, @@ -101,6 +107,7 @@ proc sendSubscribeRequest( proc ping*( wfc: WakuFilterClient, servicePeer: RemotePeerInfo ): Future[FilterSubscribeResult] {.async.} = + debug "sending ping", servicePeer = shortLog($servicePeer) let requestId = generateRequestId(wfc.rng) let filterSubscribeRequest = FilterSubscribeRequest.ping(requestId) @@ -170,17 +177,23 @@ proc initProtocolHandler(wfc: WakuFilterClient) = proc handler(conn: Connection, proto: string) {.async.} = let buf = await conn.readLp(int(DefaultMaxPushSize)) - let decodeRes = MessagePush.decode(buf) - if decodeRes.isErr(): - error "Failed to decode message push", peerId = conn.peerId + let msgPush = MessagePush.decode(buf).valueOr: + error "Failed to decode message push", peerId = conn.peerId, error = $error waku_filter_errors.inc(labelValues = [decodeRpcFailure]) return - let messagePush = decodeRes.value #TODO: toAPI() split here - trace "Received message push", peerId = conn.peerId, messagePush + let msg_hash = + computeMessageHash(msgPush.pubsubTopic, msgPush.wakuMessage).to0xHex() + + debug "Received message push", + peerId = conn.peerId, + msg_hash, + payload = shortLog(msgPush.wakuMessage.payload), + pubsubTopic = msgPush.pubsubTopic, + content_topic = msgPush.wakuMessage.contentTopic for handler in wfc.pushHandlers: - asyncSpawn handler(messagePush.pubsubTopic, messagePush.wakuMessage) + asyncSpawn handler(msgPush.pubsubTopic, msgPush.wakuMessage) # Protocol specifies no response for now return diff --git a/waku/waku_filter_v2/protocol.nim b/waku/waku_filter_v2/protocol.nim index b30ff9b7c..f3707210f 100644 --- a/waku/waku_filter_v2/protocol.nim +++ b/waku/waku_filter_v2/protocol.nim @@ -194,12 +194,14 @@ proc pushToPeers( error "duplicate message found, not-pushing message to subscribed peers", pubsubTopic = messagePush.pubsubTopic, contentTopic = messagePush.wakuMessage.contentTopic, + payload = shortLog(messagePush.wakuMessage.payload), target_peer_ids = targetPeerIds, msg_hash = msgHash else: notice "pushing message to subscribed peers", pubsubTopic = messagePush.pubsubTopic, contentTopic = messagePush.wakuMessage.contentTopic, + payload = shortLog(messagePush.wakuMessage.payload), target_peer_ids = targetPeerIds, msg_hash = msgHash