From 83234ee4ceda85ac2b65b497cb9ec65a929d0d3b Mon Sep 17 00:00:00 2001 From: realbigsean Date: Tue, 29 Mar 2022 22:59:55 +0000 Subject: [PATCH] json rpc id to value (#3110) ## 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 --- beacon_node/execution_layer/src/engine_api/http.rs | 2 +- beacon_node/execution_layer/src/engine_api/json_structures.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/beacon_node/execution_layer/src/engine_api/http.rs b/beacon_node/execution_layer/src/engine_api/http.rs index 34b692a62..fc0288bbc 100644 --- a/beacon_node/execution_layer/src/engine_api/http.rs +++ b/beacon_node/execution_layer/src/engine_api/http.rs @@ -75,7 +75,7 @@ impl HttpJsonRpc { jsonrpc: JSONRPC_VERSION, method, params, - id: STATIC_ID, + id: json!(STATIC_ID), }; let mut request = self diff --git a/beacon_node/execution_layer/src/engine_api/json_structures.rs b/beacon_node/execution_layer/src/engine_api/json_structures.rs index 77dc6ff47..c95113092 100644 --- a/beacon_node/execution_layer/src/engine_api/json_structures.rs +++ b/beacon_node/execution_layer/src/engine_api/json_structures.rs @@ -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)] @@ -25,7 +25,7 @@ pub struct JsonResponseBody { pub error: Option, #[serde(default)] pub result: serde_json::Value, - pub id: u32, + pub id: serde_json::Value, } #[derive(Debug, PartialEq, Serialize, Deserialize)]