Skip to content

Commit ab3e7ac

Browse files
committed
refactor
1 parent d4f669f commit ab3e7ac

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

crates/payload/primitives/src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,17 @@ pub fn validate_payload_timestamp(
157157
return Err(EngineObjectValidationError::UnsupportedFork)
158158
}
159159

160-
// let is_amsterdam = true; /* ///todo chain_spec.is_amstardam_active_at_timestamp(timestamp);
161-
// */ if version.is_v6() && !is_amsterdam {
162-
// // From the Engine API spec:
163-
// // <https://github.com/ethereum/execution-apis/blob/15399c2e2f16a5f800bf3f285640357e2c245ad9/src/engine/osaka.md#specification>
164-
// //
165-
// // For `engine_getPayloadV5`
166-
// //
167-
// // 1. Client software MUST return -38005: Unsupported fork error if the timestamp of the
168-
// // built payload does not fall within the time frame of the Amsterdam fork.
169-
// return Err(EngineObjectValidationError::UnsupportedFork)
170-
// }
160+
let is_amsterdam = chain_spec.is_amsterdam_active_at_timestamp(timestamp);
161+
if version.is_v6() && !is_amsterdam {
162+
// From the Engine API spec:
163+
// <https://github.com/ethereum/execution-apis/blob/15399c2e2f16a5f800bf3f285640357e2c245ad9/src/engine/osaka.md#specification>
164+
//
165+
// For `engine_getPayloadV6`
166+
//
167+
// 1. Client software MUST return -38005: Unsupported fork error if the timestamp of the
168+
// built payload does not fall within the time frame of the Amsterdam fork.
169+
return Err(EngineObjectValidationError::UnsupportedFork)
170+
}
171171

172172
Ok(())
173173
}

crates/rpc/rpc-engine-api/src/engine_api.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,17 @@ where
594594
self.get_payload_inner(payload_id, EngineApiMessageVersion::V6).await
595595
}
596596

597+
/// Metrics version of `get_payload_v6`
598+
pub async fn get_payload_v6_metered(
599+
&self,
600+
payload_id: PayloadId,
601+
) -> EngineApiResult<EngineT::ExecutionPayloadEnvelopeV6> {
602+
let start = Instant::now();
603+
let res = Self::get_payload_v6(self, payload_id).await;
604+
self.inner.metrics.latency.get_payload_v6.record(start.elapsed());
605+
res
606+
}
607+
597608
/// Fetches all the blocks for the provided range starting at `start`, containing `count`
598609
/// blocks and returns the mapped payload bodies.
599610
pub async fn get_payload_bodies_by_range_with<F, R>(

crates/rpc/rpc-engine-api/src/metrics.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ pub(crate) struct EngineApiLatencyMetrics {
5050
pub(crate) get_payload_v4: Histogram,
5151
/// Latency for `engine_getPayloadV5`
5252
pub(crate) get_payload_v5: Histogram,
53+
/// Latency for `engine_getPayloadV6`
54+
pub(crate) get_payload_v6: Histogram,
5355
/// Latency for `engine_getPayloadBodiesByRangeV1`
5456
pub(crate) get_payload_bodies_by_range_v1: Histogram,
5557
/// Latency for `engine_getPayloadBodiesByHashV1`

0 commit comments

Comments
 (0)