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>
This commit is contained in:
Tomás
2022-12-16 22:57:48 -03:00
committed by GitHub
parent 0a4bf67c32
commit 253aae5ea9
3 changed files with 11 additions and 3 deletions

1
Cargo.lock generated
View File

@@ -3660,6 +3660,7 @@ dependencies = [
"rlp",
"secp256k1",
"smol_str",
"tracing",
]
[[package]]

View File

@@ -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
harness = false

View File

@@ -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(_)) {