diff --git a/libp2p/crypto/crypto.nim b/libp2p/crypto/crypto.nim index 1a448c315..32ae75f95 100644 --- a/libp2p/crypto/crypto.nim +++ b/libp2p/crypto/crypto.nim @@ -10,6 +10,7 @@ ## This module implements Public Key and Private Key interface for libp2p. {.push raises: [Defect].} from strutils import split, strip, cmpIgnoreCase +import chronicles const libp2p_pki_schemes* {.strdefine.} = "rsa,ed25519,secp256k1,ecnist" @@ -1058,6 +1059,7 @@ proc getField*[T: PublicKey|PrivateKey](pb: ProtoBuffer, field: int, value = key ok(true) else: + debug "incorrect blob", bt=getStackTrace() err(ProtoError.IncorrectBlob) proc getField*(pb: ProtoBuffer, field: int, @@ -1076,4 +1078,5 @@ proc getField*(pb: ProtoBuffer, field: int, value = sig ok(true) else: + debug "incorrect blob", bt=getStackTrace() err(ProtoError.IncorrectBlob) diff --git a/libp2p/multiaddress.nim b/libp2p/multiaddress.nim index 859c119bf..418f9d7df 100644 --- a/libp2p/multiaddress.nim +++ b/libp2p/multiaddress.nim @@ -18,6 +18,7 @@ import multicodec, multihash, multibase, transcoder, vbuffer, peerid, protobuf/minprotobuf import stew/[base58, base32, endians2, results] export results, minprotobuf, vbuffer +import chronicles type MAKind* = enum @@ -1044,6 +1045,7 @@ proc getField*(pb: var ProtoBuffer, field: int, value = ma.get() ok(true) else: + debug "incorrect blob", bt=getStackTrace() err(ProtoError.IncorrectBlob) proc getRepeatedField*(pb: var ProtoBuffer, field: int, @@ -1061,5 +1063,6 @@ proc getRepeatedField*(pb: var ProtoBuffer, field: int, value.add(ma.get()) else: value.setLen(0) + debug "incorrect blob", bt=getStackTrace() return err(ProtoError.IncorrectBlob) ok(true) diff --git a/libp2p/peerid.nim b/libp2p/peerid.nim index cd01ec149..7af435129 100644 --- a/libp2p/peerid.nim +++ b/libp2p/peerid.nim @@ -234,4 +234,5 @@ proc getField*(pb: ProtoBuffer, field: int, pid = peerId ok(true) else: + debug "incorrect blob", bt=getStackTrace(), len=buffer.len err(ProtoError.IncorrectBlob) diff --git a/libp2p/protocols/pubsub/pubsubpeer.nim b/libp2p/protocols/pubsub/pubsubpeer.nim index ea865e0fc..3d5cef33a 100644 --- a/libp2p/protocols/pubsub/pubsubpeer.nim +++ b/libp2p/protocols/pubsub/pubsubpeer.nim @@ -100,6 +100,7 @@ proc handle*(p: PubSubPeer, conn: Connection) {.async.} = notice "failed to decode msg from peer", conn, peer = p, closed = conn.closed, err = rmsg.error() + trace "failed message", bytes=data.toHex() break trace "decoded msg from peer", diff --git a/libp2p/protocols/pubsub/rpc/protobuf.nim b/libp2p/protocols/pubsub/rpc/protobuf.nim index 3c44d3a16..48f3dc86d 100644 --- a/libp2p/protocols/pubsub/rpc/protobuf.nim +++ b/libp2p/protocols/pubsub/rpc/protobuf.nim @@ -13,6 +13,7 @@ import messages, ../../../peerid, ../../../utility, ../../../protobuf/minprotobuf +import stew/byteutils proc write*(pb: var ProtoBuffer, field: int, graft: ControlGraft) = var ipb = initProtoBuffer() @@ -76,8 +77,11 @@ proc write*(pb: var ProtoBuffer, field: int, subs: SubOpts) = proc encodeMessage*(msg: Message): seq[byte] = var pb = initProtoBuffer() pb.write(1, msg.fromPeer) + trace "encodeMessage: write fromPeer", fromPeer = msg.fromPeer pb.write(2, msg.data) + trace "encodeMessage: write data", data = msg.data.toHex pb.write(3, msg.seqno) + trace "encodeMessage: write seqno", seqno = msg.seqno for topic in msg.topicIDs: pb.write(4, topic) if len(msg.signature) > 0: