Skip to content

Commit 0199557

Browse files
committed
identify: Add more debug logs
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
1 parent 3d4c886 commit 0199557

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/protocol/libp2p/identify.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,22 @@ impl Identify {
334334
Ok(Some(Ok(payload))) => payload,
335335
};
336336

337-
let info = identify_schema::Identify::decode(payload.to_vec().as_slice())?;
337+
let info = identify_schema::Identify::decode(payload.to_vec().as_slice()).map_err(
338+
|err| {
339+
tracing::debug!(target: LOG_TARGET, ?peer, ?err, "peer identified provided undecodable identify response");
340+
err
341+
})?;
338342

339343
tracing::trace!(target: LOG_TARGET, ?peer, ?info, "peer identified");
340344

341345
// The check ensures the provided public key is the same one as the
342346
// one exchanged during the connection establishment.
343347
if let Some(public_key) = &info.public_key {
344-
let public_key = PublicKey::from_protobuf_encoding(&public_key)?;
348+
let public_key = PublicKey::from_protobuf_encoding(&public_key).map_err(|err| {
349+
tracing::debug!(target: LOG_TARGET, ?peer, ?err, "peer identified provided undecodable public key");
350+
err
351+
})?;
352+
345353
if public_key.to_peer_id() != peer {
346354
tracing::debug!(target: LOG_TARGET, ?peer, "peer identified provided invalid public key");
347355
return Err(Error::InvalidData);
@@ -356,11 +364,12 @@ impl Identify {
356364

357365
// Ensure the address ends with the provided peer ID and is not empty.
358366
if address.is_empty() {
367+
tracing::debug!(target: LOG_TARGET, ?peer, ?address, "peer identified provided empty listen address");
359368
return None;
360369
}
361370
if let Some(multiaddr::Protocol::P2p(peer_id)) = address.iter().last() {
362371
if peer_id != peer.into() {
363-
tracing::debug!(target: LOG_TARGET, ?peer, ?address, "peer identified provided invalid address");
372+
tracing::debug!(target: LOG_TARGET, ?peer, ?address, "peer identified provided invalid listen address");
364373
return None;
365374
}
366375
}
@@ -374,12 +383,13 @@ impl Identify {
374383
let address = Multiaddr::try_from(address).ok()?;
375384

376385
if address.is_empty() {
386+
tracing::debug!(target: LOG_TARGET, ?peer, ?address, "peer identified provided empty observed address");
377387
return None;
378388
}
379389

380390
if let Some(multiaddr::Protocol::P2p(peer_id)) = address.iter().last() {
381391
if peer_id != local_peer_id.into() {
382-
tracing::debug!(target: LOG_TARGET, ?peer, ?address, "peer identified provided invalid address");
392+
tracing::debug!(target: LOG_TARGET, ?peer, ?address, "peer identified provided invalid observed address");
383393
return None;
384394
}
385395
}

0 commit comments

Comments
 (0)