adding debugging traces

This commit is contained in:
benedettadavico
2026-04-24 14:11:19 +02:00
parent 42aade29eb
commit f94d6d51cf
4 changed files with 38 additions and 3 deletions
+17 -1
View File
@@ -81,6 +81,16 @@ impl IprClientConnect {
async fn send_connect_request(&self, ip_packet_router_address: Recipient) -> Result<u64> {
let (request, request_id) = nym_ip_packet_requests::v9::new_connect_request(None);
tracing::info!(
request_id = request_id,
protocol_version = request.protocol.version,
current_version = crate::current::VERSION,
"Sending IPR connect request"
);
if let Ok(bytes) = request.to_bytes() {
let prefix = bytes.get(0..2).unwrap_or(&bytes);
tracing::info!(request_id = request_id, bytes_0_2 = ?prefix, "IPR connect bytes");
}
// We use 20 surbs for the connect request because typically the IPR is configured to have
// a min threshold of 10 surbs that it reserves for itself to request additional surbs.
@@ -129,7 +139,13 @@ impl IprClientConnect {
for msg in msgs {
// Confirm that the version is correct
if let Err(err) = check_ipr_message_version(&msg) {
tracing::info!("Mixnet message version mismatch: {err}");
let raw: &[u8] = msg.message.as_ref();
tracing::info!(
first_byte = raw.first().copied(),
expected = crate::current::VERSION,
len = raw.len(),
"Mixnet message version mismatch: {err}"
);
continue;
}
@@ -218,7 +218,16 @@ fn create_ip_packet_response(
ClientVersion::V6 => IpPacketResponseV6::new_ip_packet(packets).to_bytes(),
ClientVersion::V7 => IpPacketResponseV7::new_ip_packet(packets).to_bytes(),
ClientVersion::V8 => IpPacketResponseV8::new_ip_packet(packets).to_bytes(),
ClientVersion::V9 => v9::new_ip_packet_response(packets).to_bytes(),
ClientVersion::V9 => {
let resp = v9::new_ip_packet_response(packets);
log::info!("IPR send data resp version byte: {}", resp.version);
let bytes = resp.to_bytes()?;
log::info!(
"IPR send data resp first byte: {:?}",
bytes.first().copied()
);
Ok(bytes)
}
}
}
@@ -88,6 +88,7 @@ impl TryFrom<&ReconstructedMessage> for IpPacketRequest {
.message
.first_chunk::<2>()
.ok_or(IpPacketRouterError::EmptyPacket)?;
log::info!("IPR recv header bytes: {:02x?}", request_version);
// With version v8 and onwards, the type of the service provider is included in the
// header.
@@ -103,6 +104,7 @@ impl TryFrom<&ReconstructedMessage> for IpPacketRequest {
}
let request_version = request_version[0];
log::info!("IPR recv version byte: {request_version}");
match request_version {
6 => {
let request_v6 = IpPacketRequestV6::from_reconstructed_message(reconstructed)
@@ -133,7 +133,15 @@ impl VersionedResponse {
ClientVersion::V9 => {
let mut resp = IpPacketResponseV8::try_from(self)?;
resp.version = nym_ip_packet_requests::v9::VERSION;
resp.to_bytes()
log::info!("IPR send control resp version byte: {}", resp.version);
let bytes = resp.to_bytes();
if let Ok(ref bytes) = bytes {
log::info!(
"IPR send control resp first byte: {:?}",
bytes.first().copied()
);
}
bytes
}
}
.map_err(|err| IpPacketRouterError::FailedToSerializeResponsePacket { source: err })