Skip to content

Commit

Permalink
[refactor] move new_payload_v3 into EngineAPI (#12442)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
  • Loading branch information
kien6034 and mattsse authored Nov 11, 2024
1 parent cdce7ee commit 29b9238
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions crates/rpc/rpc-engine-api/src/engine_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,23 @@ where
.inspect(|_| self.inner.on_new_payload_response())?)
}

// Metrics version of `new_payload_v3`
async fn new_payload_v3_metered(
&self,
payload: ExecutionPayloadV3,
versioned_hashes: Vec<B256>,
parent_beacon_block_root: B256,
) -> RpcResult<PayloadStatus> {
let start = Instant::now();
let gas_used = payload.payload_inner.payload_inner.gas_used;
let res =
Self::new_payload_v3(self, payload, versioned_hashes, parent_beacon_block_root).await;
let elapsed = start.elapsed();
self.inner.metrics.latency.new_payload_v3.record(elapsed);
self.inner.metrics.new_payload_response.update_response_metrics(&res, gas_used, elapsed);
Ok(res?)
}

/// See also <https://github.com/ethereum/execution-apis/blob/7907424db935b93c2fe6a3c0faab943adebe8557/src/engine/prague.md#engine_newpayloadv4>
pub async fn new_payload_v4(
&self,
Expand Down Expand Up @@ -724,14 +741,7 @@ where
parent_beacon_block_root: B256,
) -> RpcResult<PayloadStatus> {
trace!(target: "rpc::engine", "Serving engine_newPayloadV3");
let start = Instant::now();
let gas_used = payload.payload_inner.payload_inner.gas_used;
let res =
Self::new_payload_v3(self, payload, versioned_hashes, parent_beacon_block_root).await;
let elapsed = start.elapsed();
self.inner.metrics.latency.new_payload_v3.record(elapsed);
self.inner.metrics.new_payload_response.update_response_metrics(&res, gas_used, elapsed);
Ok(res?)
Ok(self.new_payload_v3_metered(payload, versioned_hashes, parent_beacon_block_root).await?)
}

/// Handler for `engine_newPayloadV4`
Expand Down

0 comments on commit 29b9238

Please sign in to comment.