Update Rust Edition to 2024 (#7766)

* #7749

Thanks @dknopik and @michaelsproul for your help!
This commit is contained in:
chonghe
2025-08-13 11:04:31 +08:00
committed by GitHub
parent bd6b8b6a65
commit 522bd9e9c6
468 changed files with 3594 additions and 3396 deletions

View File

@@ -7,28 +7,28 @@
use crate::json_structures::{BlobAndProofV1, BlobAndProofV2};
use crate::payload_cache::PayloadCache;
use arc_swap::ArcSwapOption;
use auth::{strip_prefix, Auth, JwtKey};
use auth::{Auth, JwtKey, strip_prefix};
pub use block_hash::calculate_execution_block_hash;
use builder_client::BuilderHttpClient;
pub use engine_api::EngineCapabilities;
use engine_api::Error as ApiError;
pub use engine_api::*;
pub use engine_api::{http, http::deposit_methods, http::HttpJsonRpc};
pub use engine_api::{http, http::HttpJsonRpc, http::deposit_methods};
use engines::{Engine, EngineError};
pub use engines::{EngineState, ForkchoiceState};
use eth2::types::{builder_bid::SignedBuilderBid, ForkVersionedResponse};
use eth2::types::{BlobsBundle, FullPayloadContents};
use eth2::types::{ForkVersionedResponse, builder_bid::SignedBuilderBid};
use ethers_core::types::Transaction as EthersTransaction;
use fixed_bytes::UintExtended;
use fork_choice::ForkchoiceUpdateParameters;
use logging::crit;
use lru::LruCache;
use payload_status::process_payload_status;
pub use payload_status::PayloadStatus;
use payload_status::process_payload_status;
use sensitive_url::SensitiveUrl;
use serde::{Deserialize, Serialize};
use slot_clock::SlotClock;
use std::collections::{hash_map::Entry, HashMap};
use std::collections::{HashMap, hash_map::Entry};
use std::fmt;
use std::future::Future;
use std::io::Write;
@@ -354,11 +354,11 @@ impl ProposerPreparationDataEntry {
// Update `gas_limit` if `updated.gas_limit` is `Some` and:
// - `self.gas_limit` is `None`, or
// - both are `Some` but the values differ.
if let Some(updated_gas_limit) = updated.gas_limit {
if self.gas_limit != Some(updated_gas_limit) {
self.gas_limit = Some(updated_gas_limit);
changed = true;
}
if let Some(updated_gas_limit) = updated.gas_limit
&& self.gas_limit != Some(updated_gas_limit)
{
self.gas_limit = Some(updated_gas_limit);
changed = true;
}
// Update `update_epoch` if it differs
@@ -740,18 +740,18 @@ impl<E: EthSpec> ExecutionLayer<E> {
/// Returns the `Self::is_synced` response if unable to get latest block.
pub async fn is_synced_for_notifier(&self, current_slot: Slot) -> bool {
let synced = self.is_synced().await;
if synced {
if let Ok(Some(block)) = self
if synced
&& let Ok(Some(block)) = self
.engine()
.api
.get_block_by_number(BlockByNumberQuery::Tag(LATEST_TAG))
.await
{
if block.block_number == 0 && current_slot > 0 {
return false;
}
}
&& block.block_number == 0
&& current_slot > 0
{
return false;
}
synced
}
@@ -1479,17 +1479,17 @@ impl<E: EthSpec> ExecutionLayer<E> {
let payload_attributes = self.payload_attributes(next_slot, head_block_root).await;
// Compute the "lookahead", the time between when the payload will be produced and now.
if let Some(ref payload_attributes) = payload_attributes {
if let Ok(now) = SystemTime::now().duration_since(UNIX_EPOCH) {
let timestamp = Duration::from_secs(payload_attributes.timestamp());
if let Some(lookahead) = timestamp.checked_sub(now) {
metrics::observe_duration(
&metrics::EXECUTION_LAYER_PAYLOAD_ATTRIBUTES_LOOKAHEAD,
lookahead,
);
} else {
debug!(?timestamp, ?now, "Late payload attributes")
}
if let Some(ref payload_attributes) = payload_attributes
&& let Ok(now) = SystemTime::now().duration_since(UNIX_EPOCH)
{
let timestamp = Duration::from_secs(payload_attributes.timestamp());
if let Some(lookahead) = timestamp.checked_sub(now) {
metrics::observe_duration(
&metrics::EXECUTION_LAYER_PAYLOAD_ATTRIBUTES_LOOKAHEAD,
lookahead,
);
} else {
debug!(?timestamp, ?now, "Late payload attributes")
}
}
@@ -1717,14 +1717,13 @@ impl<E: EthSpec> ExecutionLayer<E> {
self.engine()
.request(|engine| async move {
if let Some(pow_block) = self.get_pow_block(engine, block_hash).await? {
if let Some(pow_parent) =
if let Some(pow_block) = self.get_pow_block(engine, block_hash).await?
&& let Some(pow_parent) =
self.get_pow_block(engine, pow_block.parent_hash).await?
{
return Ok(Some(
self.is_valid_terminal_pow_block(pow_block, pow_parent, spec),
));
}
{
return Ok(Some(
self.is_valid_terminal_pow_block(pow_block, pow_parent, spec),
));
}
Ok(None)
})
@@ -2302,12 +2301,13 @@ mod test {
let (mock, block_hash) = MockExecutionLayer::default_params(runtime.task_executor.clone())
.move_to_terminal_block()
.produce_forked_pow_block();
assert!(mock
.el
.is_valid_terminal_pow_block_hash(block_hash, &mock.spec)
.await
.unwrap()
.unwrap());
assert!(
mock.el
.is_valid_terminal_pow_block_hash(block_hash, &mock.spec)
.await
.unwrap()
.unwrap()
);
}
#[tokio::test]