From 81436cbccae87bc8fe2105e5b68f416e31cd4b71 Mon Sep 17 00:00:00 2001 From: m1stoyanov <133634888+m1stoyanov@users.noreply.github.com> Date: Thu, 25 Jul 2024 16:38:35 +0300 Subject: [PATCH 1/2] Update parity.rs Bytes to Option That will resolve the issue when the RPC server returns "output": null, as Nethermind does. --- crates/rpc-types-trace/src/parity.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rpc-types-trace/src/parity.rs b/crates/rpc-types-trace/src/parity.rs index 21abea91bb2..0bebece6bea 100644 --- a/crates/rpc-types-trace/src/parity.rs +++ b/crates/rpc-types-trace/src/parity.rs @@ -29,7 +29,7 @@ pub enum TraceType { #[serde(rename_all = "camelCase")] pub struct TraceResults { /// Output of the trace - pub output: Bytes, + pub output: Option, /// Enabled if [TraceType::StateDiff] is provided pub state_diff: Option, /// Enabled if [TraceType::Trace] is provided, otherwise an empty vec From 5724d735ad4f8a9be88ea3342ca1b185873ae088 Mon Sep 17 00:00:00 2001 From: m1stoyanov <133634888+m1stoyanov@users.noreply.github.com> Date: Fri, 26 Jul 2024 13:27:14 +0300 Subject: [PATCH 2/2] Use null_as_default for handling null output and added test --- crates/rpc-types-trace/src/parity.rs | 30 +++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/crates/rpc-types-trace/src/parity.rs b/crates/rpc-types-trace/src/parity.rs index 0bebece6bea..b6794694eb7 100644 --- a/crates/rpc-types-trace/src/parity.rs +++ b/crates/rpc-types-trace/src/parity.rs @@ -29,7 +29,8 @@ pub enum TraceType { #[serde(rename_all = "camelCase")] pub struct TraceResults { /// Output of the trace - pub output: Option, + #[serde(deserialize_with = "alloy_serde::null_as_default")] + pub output: Bytes, /// Enabled if [TraceType::StateDiff] is provided pub state_diff: Option, /// Enabled if [TraceType::Trace] is provided, otherwise an empty vec @@ -821,4 +822,31 @@ mod tests { let serialized = serde_json::to_string_pretty(&trace).unwrap(); similar_asserts::assert_eq!(serialized, reference_data); } + #[test] + fn test_nethermind_trace_result_null_output_value() { + let reference_data = r#"{ + "output": null, + "stateDiff": { + "0x5e1d1eb61e1164d5a50b28c575da73a29595dff7": { + "balance": "=", + "code": "=", + "nonce": "=", + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000005": { + "*": { + "from": "0x0000000000000000000000000000000000000000000000000000000000042f66", + "to": "0x0000000000000000000000000000000000000000000000000000000000042f67" + } + } + } + } + }, + "trace": [], + "vmTrace": null, + "transactionHash": "0xe56a5e7455c45b1842b35dbcab9d024b21870ee59820525091e183b573b4f9eb" +}"#; + let trace = + serde_json::from_str::(reference_data).unwrap(); + assert_eq!(trace.full_trace.output, Bytes::default()); + } }