diff --git a/Cargo.lock b/Cargo.lock index 692159b..2a48854 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3079,7 +3079,7 @@ dependencies = [ [[package]] name = "rproxy" -version = "0.0.7" +version = "0.0.8" dependencies = [ "actix", "actix-http", diff --git a/crates/rproxy/Cargo.toml b/crates/rproxy/Cargo.toml index 214a538..c11244d 100644 --- a/crates/rproxy/Cargo.toml +++ b/crates/rproxy/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rproxy" -version = "0.0.7" +version = "0.0.8" edition = "2024" default-run = "rproxy" diff --git a/crates/rproxy/src/jrpc/jrpc_request.rs b/crates/rproxy/src/jrpc/jrpc_request.rs index f1aa59d..7a65411 100644 --- a/crates/rproxy/src/jrpc/jrpc_request.rs +++ b/crates/rproxy/src/jrpc/jrpc_request.rs @@ -12,13 +12,15 @@ const JRPC_METHOD_FCUV2_WITH_PAYLOAD: Cow<'static, str> = const JRPC_METHOD_FCUV3_WITH_PAYLOAD: Cow<'static, str> = Cow::Borrowed("engine_forkchoiceUpdatedV3_withPayload"); +const EMPTY_PARAMS: &Vec = &Vec::new(); + pub(crate) struct JrpcRequestMeta { id: Id, method: Cow<'static, str>, method_enriched: Cow<'static, str>, - params: Vec, + params: serde_json::Value, } impl JrpcRequestMeta { @@ -39,7 +41,7 @@ impl JrpcRequestMeta { #[inline] pub(crate) fn params(&self) -> &Vec { - &self.params + self.params.as_array().unwrap_or(EMPTY_PARAMS) } } @@ -52,15 +54,17 @@ impl<'a> Deserialize<'a> for JrpcRequestMeta { struct JrpcRequestMetaWire { id: Id, method: Cow<'static, str>, - params: Vec, + params: serde_json::Value, } let wire = JrpcRequestMetaWire::deserialize(deserializer)?; let mut params_count = 0; - for param in wire.params.iter() { - if !param.is_null() { - params_count += 1; + if let Some(params) = wire.params.as_array() { + for param in params.iter() { + if !param.is_null() { + params_count += 1; + } } } diff --git a/crates/rproxy/src/server/proxy/http/proxy.rs b/crates/rproxy/src/server/proxy/http/proxy.rs index 5846ebc..88e549e 100644 --- a/crates/rproxy/src/server/proxy/http/proxy.rs +++ b/crates/rproxy/src/server/proxy/http/proxy.rs @@ -455,6 +455,7 @@ where request_id = %req_id, connection_id = %conn_id, worker_id = %this.id, + http_request = if this.shared.config().log_proxied_responses() { str::from_utf8(&decompressed_body).unwrap_or_default() } else { "" }, error = ?err, "Failed to parse json-rpc request", ); @@ -619,6 +620,7 @@ where request_id = %clnt_req.info.req_id, connection_id = %clnt_req.info.conn_id, worker_id = %worker_id, + http_request = if inner.config().log_proxied_responses() { str::from_utf8(&clnt_req.decompressed_body).unwrap_or_default() } else { "" }, error = ?err, "Failed to parse json-rpc request", );