Skip to content

Commit fa01c2a

Browse files
authored
fix: make Parity TraceResults output optional (#1102)
* Update parity.rs Bytes to Option<Bytes> That will resolve the issue when the RPC server returns "output": null, as Nethermind does. * Use null_as_default for handling null output and added test
1 parent aac27bc commit fa01c2a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

crates/rpc-types-trace/src/parity.rs

+28
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub enum TraceType {
2929
#[serde(rename_all = "camelCase")]
3030
pub struct TraceResults {
3131
/// Output of the trace
32+
#[serde(deserialize_with = "alloy_serde::null_as_default")]
3233
pub output: Bytes,
3334
/// Enabled if [TraceType::StateDiff] is provided
3435
pub state_diff: Option<StateDiff>,
@@ -821,4 +822,31 @@ mod tests {
821822
let serialized = serde_json::to_string_pretty(&trace).unwrap();
822823
similar_asserts::assert_eq!(serialized, reference_data);
823824
}
825+
#[test]
826+
fn test_nethermind_trace_result_null_output_value() {
827+
let reference_data = r#"{
828+
"output": null,
829+
"stateDiff": {
830+
"0x5e1d1eb61e1164d5a50b28c575da73a29595dff7": {
831+
"balance": "=",
832+
"code": "=",
833+
"nonce": "=",
834+
"storage": {
835+
"0x0000000000000000000000000000000000000000000000000000000000000005": {
836+
"*": {
837+
"from": "0x0000000000000000000000000000000000000000000000000000000000042f66",
838+
"to": "0x0000000000000000000000000000000000000000000000000000000000042f67"
839+
}
840+
}
841+
}
842+
}
843+
},
844+
"trace": [],
845+
"vmTrace": null,
846+
"transactionHash": "0xe56a5e7455c45b1842b35dbcab9d024b21870ee59820525091e183b573b4f9eb"
847+
}"#;
848+
let trace =
849+
serde_json::from_str::<TraceResultsWithTransactionHash>(reference_data).unwrap();
850+
assert_eq!(trace.full_trace.output, Bytes::default());
851+
}
824852
}

0 commit comments

Comments
 (0)