-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Track time diff between new_payload
and FCU
#12245
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -27,7 +27,10 @@ use reth_rpc_types_compat::engine::payload::{ | |||||
use reth_storage_api::{BlockReader, HeaderProvider, StateProviderFactory}; | ||||||
use reth_tasks::TaskSpawner; | ||||||
use reth_transaction_pool::TransactionPool; | ||||||
use std::{sync::Arc, time::Instant}; | ||||||
use std::{ | ||||||
sync::{Arc, Mutex}, | ||||||
time::Instant, | ||||||
}; | ||||||
use tokio::sync::oneshot; | ||||||
use tracing::{trace, warn}; | ||||||
|
||||||
|
@@ -44,6 +47,7 @@ const MAX_BLOB_LIMIT: usize = 128; | |||||
/// functions in the Execution layer that are crucial for the consensus process. | ||||||
pub struct EngineApi<Provider, EngineT: EngineTypes, Pool, Validator, ChainSpec> { | ||||||
inner: Arc<EngineApiInner<Provider, EngineT, Pool, Validator, ChainSpec>>, | ||||||
start_time: Mutex<Option<Instant>>, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should go into the inner type, because the |
||||||
} | ||||||
|
||||||
struct EngineApiInner<Provider, EngineT: EngineTypes, Pool, Validator, ChainSpec> { | ||||||
|
@@ -103,7 +107,7 @@ where | |||||
tx_pool, | ||||||
validator, | ||||||
}); | ||||||
Self { inner } | ||||||
Self { inner, start_time: Mutex::new(None) } | ||||||
} | ||||||
|
||||||
/// Fetches the client version. | ||||||
|
@@ -140,11 +144,18 @@ where | |||||
self.inner | ||||||
.validator | ||||||
.validate_version_specific_fields(EngineApiMessageVersion::V1, payload_or_attrs)?; | ||||||
Ok(self | ||||||
|
||||||
let response = self | ||||||
.inner | ||||||
.beacon_consensus | ||||||
.new_payload(payload, ExecutionPayloadSidecar::none()) | ||||||
.await?) | ||||||
.await?; | ||||||
|
||||||
// Instant of the new payload response | ||||||
let mut start_time = self.start_time.lock().unwrap(); | ||||||
*start_time = Some(Instant::now()); | ||||||
|
||||||
Ok(response) | ||||||
} | ||||||
|
||||||
/// See also <https://github.com/ethereum/execution-apis/blob/584905270d8ad665718058060267061ecfd79ca5/src/engine/shanghai.md#engine_newpayloadv2> | ||||||
|
@@ -239,6 +250,15 @@ where | |||||
state: ForkchoiceState, | ||||||
payload_attrs: Option<EngineT::PayloadAttributes>, | ||||||
) -> EngineApiResult<ForkchoiceUpdated> { | ||||||
let elapsed_time = self | ||||||
.start_time | ||||||
.lock() | ||||||
.unwrap() | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
.expect("start_time should be set before fork_choice_updated_v1 is called") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and this can't use unwrap here, and should only update if there is an instant |
||||||
.elapsed(); | ||||||
|
||||||
self.inner.metrics.payload_to_fcu_latency.new_payload_v1_time_diff.record(elapsed_time); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can make this a standalone function of the inner type |
||||||
|
||||||
self.validate_and_execute_forkchoice(EngineApiMessageVersion::V1, state, payload_attrs) | ||||||
.await | ||||||
} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should use parking_lot::Mutex