diff --git a/.gitmodules b/.gitmodules index 57ddea4d42..9f9490c124 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,7 +12,7 @@ path = vendor/nim-libp2p url = https://github.com/vacp2p/nim-libp2p.git ignore = dirty - branch = master + branch = enhance-logs-for-nwaku [submodule "vendor/nim-stew"] path = vendor/nim-stew url = https://github.com/status-im/nim-stew.git diff --git a/vendor/nim-libp2p b/vendor/nim-libp2p index 94d93cbf25..10a1ef87b5 160000 --- a/vendor/nim-libp2p +++ b/vendor/nim-libp2p @@ -1 +1 @@ -Subproject commit 94d93cbf2531296f0e636aa702b500b242eb4158 +Subproject commit 10a1ef87b58d66b7e0ae82df4e5879c1300a06cf diff --git a/waku/node/waku_node.nim b/waku/node/waku_node.nim index 23d9799c32..e3665f17be 100644 --- a/waku/node/waku_node.nim +++ b/waku/node/waku_node.nim @@ -259,7 +259,7 @@ proc registerRelayDefaultHandler(node: WakuNode, topic: PubsubTopic) = let defaultHandler = proc( topic: PubsubTopic, msg: WakuMessage ): Future[void] {.async, gcsafe.} = - await traceHandler(topic, msg) + #await traceHandler(topic, msg) await filterHandler(topic, msg) await archiveHandler(topic, msg) diff --git a/waku/waku_relay/protocol.nim b/waku/waku_relay/protocol.nim index b922f69d3b..d79a476a0a 100644 --- a/waku/waku_relay/protocol.nim +++ b/waku/waku_relay/protocol.nim @@ -180,18 +180,32 @@ proc initRelayMetricObserver(w: WakuRelay) = return ok((msg_id_short, msg.topic, wakuMessage, msgSize)) proc logMessageInfo( - peer: PubSubPeer, topic: string, msg_id_short: string, msg: WakuMessage + peer: PubSubPeer, + topic: string, + msg_id_short: string, + msg: WakuMessage, + onRecv: bool, ) = let msg_hash = computeMessageHash(topic, msg).to0xHex() - notice "sent relay message", - my_peer_id = w.switch.peerInfo.peerId, - msg_hash = msg_hash, - msg_id = msg_id_short, - to_peer_id = peer.peerId, - topic = topic, - sentTime = getNowInNanosecondTime(), - payloadSizeBytes = msg.payload.len + if onRecv: + notice "received relay message", + my_peer_id = w.switch.peerInfo.peerId, + msg_hash = msg_hash, + msg_id = msg_id_short, + from_peer_id = peer.peerId, + topic = topic, + receivedTime = getNowInNanosecondTime(), + payloadSizeBytes = msg.payload.len + else: + notice "sent relay message", + my_peer_id = w.switch.peerInfo.peerId, + msg_hash = msg_hash, + msg_id = msg_id_short, + to_peer_id = peer.peerId, + topic = topic, + sentTime = getNowInNanosecondTime(), + payloadSizeBytes = msg.payload.len proc updateMetrics( peer: PubSubPeer, @@ -212,14 +226,31 @@ proc initRelayMetricObserver(w: WakuRelay) = updateMetrics(peer, topic, wakuMessage, msgSize, onRecv = true) discard + proc onRecvAndValidated(peer: PubSubPeer, msg: Message, msgId: MessageId) = + let msg_id_short = shortLog(msgId) + let wakuMessage = WakuMessage.decode(msg.data).valueOr: + warn "onRecvAndValidated: failed decoding to Waku Message", + my_peer_id = w.switch.peerInfo.peerId, + msg_id = msg_id_short, + from_peer_id = peer.peerId, + pubsub_topic = msg.topic, + error = $error + return + + logMessageInfo(peer, msg.topic, msg_id_short, wakuMessage, onRecv = true) + proc onSend(peer: PubSubPeer, msgs: var RPCMsg) = for msg in msgs.messages: let (msg_id_short, topic, wakuMessage, msgSize) = decodeRpcMessageInfo(peer, msg).valueOr: + warn "onSend: failed decoding RPC info", + my_peer_id = w.switch.peerInfo.peerId, to_peer_id = peer.peerId continue - logMessageInfo(peer, topic, msg_id_short, wakuMessage) + logMessageInfo(peer, topic, msg_id_short, wakuMessage, onRecv = false) updateMetrics(peer, topic, wakuMessage, msgSize, onRecv = false) - let administrativeObserver = PubSubObserver(onRecv: onRecv, onSend: onSend) + let administrativeObserver = PubSubObserver( + onRecv: onRecv, onSend: onSend, onRecvAndValidated: onRecvAndValidated + ) w.addObserver(administrativeObserver)