From fcbc60fc11ecaf8a321472041567103405220bae Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Sun, 10 Nov 2024 00:58:56 +0700 Subject: [PATCH 1/2] bet --- crates/rpc/rpc-engine-api/src/engine_api.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/crates/rpc/rpc-engine-api/src/engine_api.rs b/crates/rpc/rpc-engine-api/src/engine_api.rs index a017c50678f0..931a28af55c4 100644 --- a/crates/rpc/rpc-engine-api/src/engine_api.rs +++ b/crates/rpc/rpc-engine-api/src/engine_api.rs @@ -153,6 +153,19 @@ where .inspect(|_| self.inner.on_new_payload_response())?) } + async fn new_payload_v1_metered( + &self, + payload: ExecutionPayloadV1, + ) -> EngineApiResult { + let start = Instant::now(); + let gas_used = payload.gas_used; + let res = Self::new_payload_v1(self, payload).await; + let elapsed = start.elapsed(); + self.inner.metrics.latency.new_payload_v1.record(elapsed); + self.inner.metrics.new_payload_response.update_response_metrics(&res, gas_used, elapsed); + res + } + /// See also pub async fn new_payload_v2( &self, @@ -677,13 +690,7 @@ where /// Caution: This should not accept the `withdrawals` field async fn new_payload_v1(&self, payload: ExecutionPayloadV1) -> RpcResult { trace!(target: "rpc::engine", "Serving engine_newPayloadV1"); - let start = Instant::now(); - let gas_used = payload.gas_used; - let res = Self::new_payload_v1(self, payload).await; - let elapsed = start.elapsed(); - self.inner.metrics.latency.new_payload_v1.record(elapsed); - self.inner.metrics.new_payload_response.update_response_metrics(&res, gas_used, elapsed); - Ok(res?) + Ok(self.new_payload_v1_metered(payload).await?) } /// Handler for `engine_newPayloadV2` From f63196c6acd731f615d9c86a1351bd81fb693e03 Mon Sep 17 00:00:00 2001 From: Tuan Tran Date: Sun, 10 Nov 2024 01:19:08 +0700 Subject: [PATCH 2/2] add docs --- crates/rpc/rpc-engine-api/src/engine_api.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/rpc/rpc-engine-api/src/engine_api.rs b/crates/rpc/rpc-engine-api/src/engine_api.rs index 931a28af55c4..393d19281c8a 100644 --- a/crates/rpc/rpc-engine-api/src/engine_api.rs +++ b/crates/rpc/rpc-engine-api/src/engine_api.rs @@ -153,6 +153,7 @@ where .inspect(|_| self.inner.on_new_payload_response())?) } + /// Metered version of `new_payload_v1`. async fn new_payload_v1_metered( &self, payload: ExecutionPayloadV1,