Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions beacon_node/execution_layer/src/engine_api/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde_json::json;
use std::collections::HashSet;
use tokio::sync::Mutex;

use std::time::{Duration, SystemTime};
use std::time::{Duration, Instant};
use types::EthSpec;

pub use deposit_log::{DepositLog, Log};
Expand Down Expand Up @@ -559,14 +559,14 @@ pub mod deposit_methods {
#[derive(Clone, Debug)]
pub struct CapabilitiesCacheEntry {
engine_capabilities: EngineCapabilities,
fetch_time: SystemTime,
fetch_time: Instant,
}

impl CapabilitiesCacheEntry {
pub fn new(engine_capabilities: EngineCapabilities) -> Self {
Self {
engine_capabilities,
fetch_time: SystemTime::now(),
fetch_time: Instant::now(),
}
}

Expand All @@ -575,15 +575,7 @@ impl CapabilitiesCacheEntry {
}

pub fn age(&self) -> Duration {
// duration_since() may fail because measurements taken earlier
// are not guaranteed to always be before later measurements
// due to anomalies such as the system clock being adjusted
// either forwards or backwards
//
// In such cases, we'll just say the age is zero
SystemTime::now()
.duration_since(self.fetch_time)
.unwrap_or(Duration::ZERO)
Instant::now().duration_since(self.fetch_time)
}

/// returns `true` if the entry's age is >= age_limit
Expand Down
4 changes: 0 additions & 4 deletions beacon_node/execution_layer/src/engine_api/json_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ impl<T: EthSpec> From<ExecutionPayloadCapella<T>> for JsonExecutionPayloadV2<T>
withdrawals: payload
.withdrawals
.into_iter()
.cloned()
.map(Into::into)
.collect::<Vec<_>>()
.into(),
Expand Down Expand Up @@ -173,7 +172,6 @@ impl<T: EthSpec> From<ExecutionPayloadEip4844<T>> for JsonExecutionPayloadV3<T>
withdrawals: payload
.withdrawals
.into_iter()
.cloned()
.map(Into::into)
.collect::<Vec<_>>()
.into(),
Expand Down Expand Up @@ -231,7 +229,6 @@ impl<T: EthSpec> From<JsonExecutionPayloadV2<T>> for ExecutionPayloadCapella<T>
withdrawals: payload
.withdrawals
.into_iter()
.cloned()
.map(Into::into)
.collect::<Vec<_>>()
.into(),
Expand Down Expand Up @@ -259,7 +256,6 @@ impl<T: EthSpec> From<JsonExecutionPayloadV3<T>> for ExecutionPayloadEip4844<T>
withdrawals: payload
.withdrawals
.into_iter()
.cloned()
.map(Into::into)
.collect::<Vec<_>>()
.into(),
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/execution_layer/src/engines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ impl Engine {
/// deadlock.
pub async fn request<'a, F, G, H>(self: &'a Arc<Self>, func: F) -> Result<H, EngineError>
where
F: Fn(&'a Engine) -> G,
F: FnOnce(&'a Engine) -> G,
G: Future<Output = Result<H, EngineApiError>>,
{
match func(self).await {
Expand Down
11 changes: 3 additions & 8 deletions beacon_node/execution_layer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1348,16 +1348,11 @@ impl<T: EthSpec> ExecutionLayer<T> {
.set_latest_forkchoice_state(forkchoice_state)
.await;

let payload_attributes_ref = &payload_attributes;
let result = self
.engine()
.request(|engine| async move {
engine
.notify_forkchoice_updated(
forkchoice_state,
payload_attributes_ref.clone(),
self.log(),
)
.notify_forkchoice_updated(forkchoice_state, payload_attributes, self.log())
.await
})
.await;
Expand Down Expand Up @@ -1723,7 +1718,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
capella_block
.withdrawals
.into_iter()
.map(|w| w.into())
.map(Into::into)
.collect(),
)
.map_err(ApiError::DeserializeWithdrawals)?;
Expand All @@ -1750,7 +1745,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
eip4844_block
.withdrawals
.into_iter()
.map(|w| w.into())
.map(Into::into)
.collect(),
)
.map_err(ApiError::DeserializeWithdrawals)?;
Expand Down
9 changes: 9 additions & 0 deletions consensus/ssz_types/src/variable_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,15 @@ impl<'a, T, N: Unsigned> IntoIterator for &'a VariableList<T, N> {
}
}

impl<T, N: Unsigned> IntoIterator for VariableList<T, N> {
type Item = T;
type IntoIter = std::vec::IntoIter<T>;

fn into_iter(self) -> Self::IntoIter {
self.vec.into_iter()
}
}

impl<T, N: Unsigned> tree_hash::TreeHash for VariableList<T, N>
where
T: tree_hash::TreeHash,
Expand Down