Execution engine suggestions from code review
Co-authored-by: Paul Hauner <paul@paulhauner.com>
This commit is contained in:
parent
918b688f72
commit
461bda6e85
@ -570,8 +570,8 @@ impl CapabilitiesCacheEntry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn engine_capabilities(&self) -> &EngineCapabilities {
|
pub fn engine_capabilities(&self) -> EngineCapabilities {
|
||||||
&self.engine_capabilities
|
self.engine_capabilities
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn age(&self) -> Duration {
|
pub fn age(&self) -> Duration {
|
||||||
@ -817,7 +817,9 @@ impl HttpJsonRpc {
|
|||||||
|
|
||||||
Ok(GetPayloadResponse::Merge(GetPayloadResponseMerge {
|
Ok(GetPayloadResponse::Merge(GetPayloadResponseMerge {
|
||||||
execution_payload: payload_v1.into(),
|
execution_payload: payload_v1.into(),
|
||||||
// Have to guess zero here as we don't know the value
|
// Set the V1 payload values from the EE to be zero. This simulates
|
||||||
|
// the pre-block-value functionality of always choosing the builder
|
||||||
|
// block.
|
||||||
block_value: Uint256::zero(),
|
block_value: Uint256::zero(),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -984,16 +986,12 @@ impl HttpJsonRpc {
|
|||||||
) -> Result<EngineCapabilities, Error> {
|
) -> Result<EngineCapabilities, Error> {
|
||||||
let mut lock = self.engine_capabilities_cache.lock().await;
|
let mut lock = self.engine_capabilities_cache.lock().await;
|
||||||
|
|
||||||
if lock
|
if let Some(lock) = lock.as_ref().filter(|entry| !entry.older_than(age_limit)) {
|
||||||
.as_ref()
|
Ok(lock.engine_capabilities())
|
||||||
.map_or(true, |entry| entry.older_than(age_limit))
|
} else {
|
||||||
{
|
|
||||||
let engine_capabilities = self.exchange_capabilities().await?;
|
let engine_capabilities = self.exchange_capabilities().await?;
|
||||||
*lock = Some(CapabilitiesCacheEntry::new(engine_capabilities));
|
*lock = Some(CapabilitiesCacheEntry::new(engine_capabilities));
|
||||||
Ok(engine_capabilities)
|
Ok(engine_capabilities)
|
||||||
} else {
|
|
||||||
// here entry is guaranteed to exist so unwrap() is safe
|
|
||||||
Ok(*lock.as_ref().unwrap().engine_capabilities())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,7 @@ use types::ExecutionBlockHash;
|
|||||||
|
|
||||||
/// The number of payload IDs that will be stored for each `Engine`.
|
/// The number of payload IDs that will be stored for each `Engine`.
|
||||||
///
|
///
|
||||||
/// Since the size of each value is small (~100 bytes) a large number is used for safety.
|
/// Since the size of each value is small (~800 bytes) a large number is used for safety.
|
||||||
/// FIXME: check this assumption now that the key includes entire payload attributes which now includes withdrawals
|
|
||||||
const PAYLOAD_ID_LRU_CACHE_SIZE: usize = 512;
|
const PAYLOAD_ID_LRU_CACHE_SIZE: usize = 512;
|
||||||
const CACHED_ENGINE_CAPABILITIES_AGE_LIMIT: Duration = Duration::from_secs(900); // 15 minutes
|
const CACHED_ENGINE_CAPABILITIES_AGE_LIMIT: Duration = Duration::from_secs(900); // 15 minutes
|
||||||
|
|
||||||
@ -276,7 +275,7 @@ impl Engine {
|
|||||||
|
|
||||||
let mut state = self.state.write().await;
|
let mut state = self.state.write().await;
|
||||||
state.update(EngineStateInternal::AuthFailed);
|
state.update(EngineStateInternal::AuthFailed);
|
||||||
(**state, CapabilitiesCacheAction::None)
|
(**state, CapabilitiesCacheAction::Clear)
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!(
|
error!(
|
||||||
|
Loading…
Reference in New Issue
Block a user