Skip to content

Commit

Permalink
json rpc id to value (sigp#3110)
Browse files Browse the repository at this point in the history
## Issue Addressed

N/A

## Proposed Changes

- Update the JSON-RPC id field for both our request and response objects to be a `serde_json::Value` rather than a `u32`. This field could be a string or a number according to the JSON-RPC 2.0 spec. We only ever set it to a number, but if, for example, we get a response that wraps this number in quotes, we would fail to deserialize it. I think because we're not doing any validation around this id otherwise, we should be less strict with it in this regard. 

## Additional Info



Co-authored-by: realbigsean <[email protected]>
  • Loading branch information
2 people authored and paulhauner committed May 6, 2022
1 parent 5267d2d commit 2ad8dea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion beacon_node/execution_layer/src/engine_api/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl HttpJsonRpc {
jsonrpc: JSONRPC_VERSION,
method,
params,
id: STATIC_ID,
id: json!(STATIC_ID),
};

let mut request = self
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/execution_layer/src/engine_api/json_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct JsonRequestBody<'a> {
pub jsonrpc: &'a str,
pub method: &'a str,
pub params: serde_json::Value,
pub id: u32,
pub id: serde_json::Value,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
Expand All @@ -25,7 +25,7 @@ pub struct JsonResponseBody {
pub error: Option<JsonError>,
#[serde(default)]
pub result: serde_json::Value,
pub id: u32,
pub id: serde_json::Value,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
Expand Down

0 comments on commit 2ad8dea

Please sign in to comment.