From 253aae5ea99ddff8738228ef6d781d5606e5b15c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 16 Dec 2022 22:57:48 -0300 Subject: [PATCH] RLP decoding error tracing (#499) * Add tracing to ProtocolMessage::decode errors * Change trace message formatting Now it prints the bytes as a hex string. Also changed trace level to WARN and added 'handshake' to one of the traces to differentiate between them * Add prefix to raw message bytes * Specify 'eth' in trace message to differentiate it from other handshakes Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com> Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com> --- Cargo.lock | 1 + crates/common/rlp/Cargo.toml | 3 ++- crates/net/eth-wire/src/ethstream.rs | 10 ++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 886fd57bd5..e2fe0a20de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3660,6 +3660,7 @@ dependencies = [ "rlp", "secp256k1", "smol_str", + "tracing", ] [[package]] diff --git a/crates/common/rlp/Cargo.toml b/crates/common/rlp/Cargo.toml index 8025cfc8e5..c36bd5c336 100644 --- a/crates/common/rlp/Cargo.toml +++ b/crates/common/rlp/Cargo.toml @@ -16,6 +16,7 @@ enr = { version = "0.7", default-features = false, optional = true } rlp = { version = "0.5.2", default-features = false, optional = true } ethereum-types = { version = "0.14", features = ["codec"], optional = true } reth-rlp-derive = { version = "0.1", path = "../rlp-derive", optional = true } +tracing = "0.1.37" [dev-dependencies] reth-rlp = { path = ".", package = "reth-rlp", features = [ @@ -41,4 +42,4 @@ enr = ["dep:enr", "dep:rlp", "enr/rust-secp256k1", "derive"] [[bench]] name = "bench" -harness = false \ No newline at end of file +harness = false diff --git a/crates/net/eth-wire/src/ethstream.rs b/crates/net/eth-wire/src/ethstream.rs index 2b6c54535c..977ee4e07a 100644 --- a/crates/net/eth-wire/src/ethstream.rs +++ b/crates/net/eth-wire/src/ethstream.rs @@ -73,7 +73,10 @@ where let msg = match ProtocolMessage::decode(&mut their_msg.as_ref()) { Ok(m) => m, - Err(err) => return Err(err.into()), + Err(err) => { + tracing::warn!("rlp decode error in eth handshake: msg={their_msg:x}"); + return Err(err.into()) + } }; // TODO: Add any missing checks @@ -191,7 +194,10 @@ where let msg = match ProtocolMessage::decode(&mut bytes.as_ref()) { Ok(m) => m, - Err(err) => return Poll::Ready(Some(Err(err.into()))), + Err(err) => { + tracing::warn!("rlp decode error: msg={bytes:x}"); + return Poll::Ready(Some(Err(err.into()))) + } }; if matches!(msg.message, EthMessage::Status(_)) {