Skip to content

Commit

Permalink
fix: make Parity TraceResults output optional (#1102)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
m1stoyanov authored Jul 26, 2024
1 parent aac27bc commit fa01c2a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions crates/rpc-types-trace/src/parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub enum TraceType {
#[serde(rename_all = "camelCase")]
pub struct TraceResults {
/// Output of the trace
#[serde(deserialize_with = "alloy_serde::null_as_default")]
pub output: Bytes,
/// Enabled if [TraceType::StateDiff] is provided
pub state_diff: Option<StateDiff>,
Expand Down Expand Up @@ -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::<TraceResultsWithTransactionHash>(reference_data).unwrap();
assert_eq!(trace.full_trace.output, Bytes::default());
}
}

0 comments on commit fa01c2a

Please sign in to comment.