mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-06 10:11:44 +00:00
Update Rust Edition to 2024 (#7766)
* #7749 Thanks @dknopik and @michaelsproul for your help!
This commit is contained in:
@@ -36,9 +36,9 @@ use crate::light_client::{get_light_client_bootstrap, get_light_client_updates};
|
||||
use crate::produce_block::{produce_blinded_block_v2, produce_block_v2, produce_block_v3};
|
||||
use crate::version::beacon_response;
|
||||
use beacon_chain::{
|
||||
attestation_verification::VerifiedAttestation, observed_operations::ObservationOutcome,
|
||||
validator_monitor::timestamp_now, AttestationError as AttnError, BeaconChain, BeaconChainError,
|
||||
BeaconChainTypes, WhenSlotSkipped,
|
||||
AttestationError as AttnError, BeaconChain, BeaconChainError, BeaconChainTypes,
|
||||
WhenSlotSkipped, attestation_verification::VerifiedAttestation,
|
||||
observed_operations::ObservationOutcome, validator_monitor::timestamp_now,
|
||||
};
|
||||
use beacon_processor::BeaconProcessorSend;
|
||||
pub use block_id::BlockId;
|
||||
@@ -54,14 +54,14 @@ use eth2::types::{
|
||||
use eth2::{CONSENSUS_VERSION_HEADER, CONTENT_TYPE_HEADER, SSZ_CONTENT_TYPE_HEADER};
|
||||
use health_metrics::observe::Observe;
|
||||
use lighthouse_network::rpc::methods::MetaData;
|
||||
use lighthouse_network::{types::SyncState, Enr, EnrExt, NetworkGlobals, PeerId, PubsubMessage};
|
||||
use lighthouse_network::{Enr, EnrExt, NetworkGlobals, PeerId, PubsubMessage, types::SyncState};
|
||||
use lighthouse_version::version_with_platform;
|
||||
use logging::{crit, SSELoggingComponents};
|
||||
use logging::{SSELoggingComponents, crit};
|
||||
use network::{NetworkMessage, NetworkSenders, ValidatorSubscriptionMessage};
|
||||
use operation_pool::ReceivedPreCapella;
|
||||
use parking_lot::RwLock;
|
||||
pub use publish_blocks::{
|
||||
publish_blinded_block, publish_block, reconstruct_block, ProvenancedBlock,
|
||||
ProvenancedBlock, publish_blinded_block, publish_block, reconstruct_block,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use slot_clock::SlotClock;
|
||||
@@ -82,8 +82,8 @@ use tokio::sync::{
|
||||
oneshot,
|
||||
};
|
||||
use tokio_stream::{
|
||||
wrappers::{errors::BroadcastStreamRecvError, BroadcastStream},
|
||||
StreamExt,
|
||||
wrappers::{BroadcastStream, errors::BroadcastStreamRecvError},
|
||||
};
|
||||
use tracing::{debug, error, info, warn};
|
||||
use types::{
|
||||
@@ -96,15 +96,15 @@ use types::{
|
||||
};
|
||||
use validator::pubkey_to_validator_index;
|
||||
use version::{
|
||||
add_consensus_version_header, add_ssz_content_type_header,
|
||||
ResponseIncludesVersion, V1, V2, V3, add_consensus_version_header, add_ssz_content_type_header,
|
||||
execution_optimistic_finalized_beacon_response, inconsistent_fork_rejection,
|
||||
unsupported_version_rejection, ResponseIncludesVersion, V1, V2, V3,
|
||||
unsupported_version_rejection,
|
||||
};
|
||||
use warp::Reply;
|
||||
use warp::http::StatusCode;
|
||||
use warp::hyper::Body;
|
||||
use warp::sse::Event;
|
||||
use warp::Reply;
|
||||
use warp::{http::Response, Filter, Rejection};
|
||||
use warp::{Filter, Rejection, http::Response};
|
||||
use warp_utils::{query::multi_key_query, reject::convert_rejection, uor::UnifyingOrFilter};
|
||||
|
||||
const API_PREFIX: &str = "eth";
|
||||
@@ -920,79 +920,76 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
None
|
||||
};
|
||||
|
||||
let committee_cache = if let Some(shuffling) =
|
||||
maybe_cached_shuffling
|
||||
{
|
||||
shuffling
|
||||
} else {
|
||||
let possibly_built_cache =
|
||||
match RelativeEpoch::from_epoch(current_epoch, epoch) {
|
||||
Ok(relative_epoch)
|
||||
if state.committee_cache_is_initialized(
|
||||
relative_epoch,
|
||||
) =>
|
||||
{
|
||||
state.committee_cache(relative_epoch).cloned()
|
||||
let committee_cache =
|
||||
if let Some(shuffling) = maybe_cached_shuffling {
|
||||
shuffling
|
||||
} else {
|
||||
let possibly_built_cache =
|
||||
match RelativeEpoch::from_epoch(current_epoch, epoch) {
|
||||
Ok(relative_epoch)
|
||||
if state.committee_cache_is_initialized(
|
||||
relative_epoch,
|
||||
) =>
|
||||
{
|
||||
state.committee_cache(relative_epoch).cloned()
|
||||
}
|
||||
_ => CommitteeCache::initialized(
|
||||
state,
|
||||
epoch,
|
||||
&chain.spec,
|
||||
),
|
||||
}
|
||||
_ => CommitteeCache::initialized(
|
||||
state,
|
||||
epoch,
|
||||
&chain.spec,
|
||||
),
|
||||
}
|
||||
.map_err(|e| {
|
||||
match e {
|
||||
BeaconStateError::EpochOutOfBounds => {
|
||||
let max_sprp =
|
||||
T::EthSpec::slots_per_historical_root()
|
||||
as u64;
|
||||
let first_subsequent_restore_point_slot =
|
||||
((epoch.start_slot(
|
||||
T::EthSpec::slots_per_epoch(),
|
||||
) / max_sprp)
|
||||
+ 1)
|
||||
* max_sprp;
|
||||
if epoch < current_epoch {
|
||||
warp_utils::reject::custom_bad_request(
|
||||
format!(
|
||||
.map_err(
|
||||
|e| match e {
|
||||
BeaconStateError::EpochOutOfBounds => {
|
||||
let max_sprp =
|
||||
T::EthSpec::slots_per_historical_root()
|
||||
as u64;
|
||||
let first_subsequent_restore_point_slot =
|
||||
((epoch.start_slot(
|
||||
T::EthSpec::slots_per_epoch(),
|
||||
) / max_sprp)
|
||||
+ 1)
|
||||
* max_sprp;
|
||||
if epoch < current_epoch {
|
||||
warp_utils::reject::custom_bad_request(
|
||||
format!(
|
||||
"epoch out of bounds, \
|
||||
try state at slot {}",
|
||||
first_subsequent_restore_point_slot,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
warp_utils::reject::custom_bad_request(
|
||||
"epoch out of bounds, \
|
||||
)
|
||||
} else {
|
||||
warp_utils::reject::custom_bad_request(
|
||||
"epoch out of bounds, \
|
||||
too far in future"
|
||||
.into(),
|
||||
)
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => warp_utils::reject::unhandled_error(
|
||||
BeaconChainError::from(e),
|
||||
),
|
||||
}
|
||||
})?;
|
||||
_ => warp_utils::reject::unhandled_error(
|
||||
BeaconChainError::from(e),
|
||||
),
|
||||
},
|
||||
)?;
|
||||
|
||||
// Attempt to write to the beacon cache (only if the cache
|
||||
// size is not the default value).
|
||||
if chain.config.shuffling_cache_size
|
||||
!= beacon_chain::shuffling_cache::DEFAULT_CACHE_SIZE
|
||||
{
|
||||
if let Some(shuffling_id) = shuffling_id {
|
||||
if let Some(mut cache_write) = chain
|
||||
// Attempt to write to the beacon cache (only if the cache
|
||||
// size is not the default value).
|
||||
if chain.config.shuffling_cache_size
|
||||
!= beacon_chain::shuffling_cache::DEFAULT_CACHE_SIZE
|
||||
&& let Some(shuffling_id) = shuffling_id
|
||||
&& let Some(mut cache_write) = chain
|
||||
.shuffling_cache
|
||||
.try_write_for(std::time::Duration::from_secs(1))
|
||||
{
|
||||
cache_write.insert_committee_cache(
|
||||
shuffling_id,
|
||||
&possibly_built_cache,
|
||||
);
|
||||
}
|
||||
{
|
||||
cache_write.insert_committee_cache(
|
||||
shuffling_id,
|
||||
&possibly_built_cache,
|
||||
);
|
||||
}
|
||||
}
|
||||
possibly_built_cache
|
||||
};
|
||||
|
||||
possibly_built_cache
|
||||
};
|
||||
|
||||
// Use either the supplied slot or all slots in the epoch.
|
||||
let slots =
|
||||
@@ -1340,13 +1337,13 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
// If the parent root was supplied, check that it matches the block
|
||||
// obtained via a slot lookup.
|
||||
if let Some(parent_root) = parent_root_opt {
|
||||
if block.parent_root() != parent_root {
|
||||
return Err(warp_utils::reject::custom_not_found(format!(
|
||||
"no canonical block at slot {} with parent root {}",
|
||||
slot, parent_root
|
||||
)));
|
||||
}
|
||||
if let Some(parent_root) = parent_root_opt
|
||||
&& block.parent_root() != parent_root
|
||||
{
|
||||
return Err(warp_utils::reject::custom_not_found(format!(
|
||||
"no canonical block at slot {} with parent root {}",
|
||||
slot, parent_root
|
||||
)));
|
||||
}
|
||||
|
||||
(root, block, execution_optimistic, finalized)
|
||||
|
||||
Reference in New Issue
Block a user