mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 18:32:42 +00:00
Merge unstable 20230925 into deneb-free-blobs.
This commit is contained in:
@@ -2869,12 +2869,8 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
})?;
|
||||
|
||||
if let Some(peer_info) = network_globals.peers.read().peer_info(&peer_id) {
|
||||
let address = if let Some(socket_addr) = peer_info.seen_addresses().next() {
|
||||
let mut addr = lighthouse_network::Multiaddr::from(socket_addr.ip());
|
||||
addr.push(lighthouse_network::multiaddr::Protocol::Tcp(
|
||||
socket_addr.port(),
|
||||
));
|
||||
addr.to_string()
|
||||
let address = if let Some(multiaddr) = peer_info.seen_multiaddrs().next() {
|
||||
multiaddr.to_string()
|
||||
} else if let Some(addr) = peer_info.listening_addresses().first() {
|
||||
addr.to_string()
|
||||
} else {
|
||||
@@ -2922,13 +2918,8 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.peers()
|
||||
.for_each(|(peer_id, peer_info)| {
|
||||
let address =
|
||||
if let Some(socket_addr) = peer_info.seen_addresses().next() {
|
||||
let mut addr =
|
||||
lighthouse_network::Multiaddr::from(socket_addr.ip());
|
||||
addr.push(lighthouse_network::multiaddr::Protocol::Tcp(
|
||||
socket_addr.port(),
|
||||
));
|
||||
addr.to_string()
|
||||
if let Some(multiaddr) = peer_info.seen_multiaddrs().next() {
|
||||
multiaddr.to_string()
|
||||
} else if let Some(addr) = peer_info.listening_addresses().first() {
|
||||
addr.to_string()
|
||||
} else {
|
||||
@@ -3055,6 +3046,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.and(warp::path::end())
|
||||
.and(not_while_syncing_filter.clone())
|
||||
.and(warp::query::<api_types::ValidatorBlocksQuery>())
|
||||
.and(warp::header::optional::<api_types::Accept>("accept"))
|
||||
.and(task_spawner_filter.clone())
|
||||
.and(chain_filter.clone())
|
||||
.and(log_filter.clone())
|
||||
@@ -3062,6 +3054,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|endpoint_version: EndpointVersion,
|
||||
slot: Slot,
|
||||
query: api_types::ValidatorBlocksQuery,
|
||||
accept_header: Option<api_types::Accept>,
|
||||
task_spawner: TaskSpawner<T::EthSpec>,
|
||||
chain: Arc<BeaconChain<T>>,
|
||||
log: Logger| {
|
||||
@@ -3109,9 +3102,24 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
let block_contents =
|
||||
build_block_contents::build_block_contents(fork_name, block, maybe_blobs)?;
|
||||
|
||||
fork_versioned_response(endpoint_version, fork_name, block_contents)
|
||||
.map(|response| warp::reply::json(&response).into_response())
|
||||
.map(|res| add_consensus_version_header(res, fork_name))
|
||||
match accept_header {
|
||||
Some(api_types::Accept::Ssz) => Response::builder()
|
||||
.status(200)
|
||||
.header("Content-Type", "application/octet-stream")
|
||||
.body(block_contents.as_ssz_bytes().into())
|
||||
.map(|res: Response<Bytes>| {
|
||||
add_consensus_version_header(res, fork_name)
|
||||
})
|
||||
.map_err(|e| {
|
||||
warp_utils::reject::custom_server_error(format!(
|
||||
"failed to create response: {}",
|
||||
e
|
||||
))
|
||||
}),
|
||||
_ => fork_versioned_response(endpoint_version, fork_name, block_contents)
|
||||
.map(|response| warp::reply::json(&response).into_response())
|
||||
.map(|res| add_consensus_version_header(res, fork_name)),
|
||||
}
|
||||
})
|
||||
},
|
||||
);
|
||||
@@ -3128,11 +3136,13 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.and(warp::path::end())
|
||||
.and(not_while_syncing_filter.clone())
|
||||
.and(warp::query::<api_types::ValidatorBlocksQuery>())
|
||||
.and(warp::header::optional::<api_types::Accept>("accept"))
|
||||
.and(task_spawner_filter.clone())
|
||||
.and(chain_filter.clone())
|
||||
.then(
|
||||
|slot: Slot,
|
||||
query: api_types::ValidatorBlocksQuery,
|
||||
accept_header: Option<api_types::Accept>,
|
||||
task_spawner: TaskSpawner<T::EthSpec>,
|
||||
chain: Arc<BeaconChain<T>>| {
|
||||
task_spawner.spawn_async_with_rejection(Priority::P0, async move {
|
||||
@@ -3176,10 +3186,25 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
maybe_blobs,
|
||||
)?;
|
||||
|
||||
// Pose as a V2 endpoint so we return the fork `version`.
|
||||
fork_versioned_response(V2, fork_name, block_contents)
|
||||
.map(|response| warp::reply::json(&response).into_response())
|
||||
.map(|res| add_consensus_version_header(res, fork_name))
|
||||
match accept_header {
|
||||
Some(api_types::Accept::Ssz) => Response::builder()
|
||||
.status(200)
|
||||
.header("Content-Type", "application/octet-stream")
|
||||
.body(block_contents.as_ssz_bytes().into())
|
||||
.map(|res: Response<Bytes>| {
|
||||
add_consensus_version_header(res, fork_name)
|
||||
})
|
||||
.map_err(|e| {
|
||||
warp_utils::reject::custom_server_error(format!(
|
||||
"failed to create response: {}",
|
||||
e
|
||||
))
|
||||
}),
|
||||
// Pose as a V2 endpoint so we return the fork `version`.
|
||||
_ => fork_versioned_response(V2, fork_name, block_contents)
|
||||
.map(|response| warp::reply::json(&response).into_response())
|
||||
.map(|res| add_consensus_version_header(res, fork_name)),
|
||||
}
|
||||
})
|
||||
},
|
||||
);
|
||||
@@ -3697,12 +3722,13 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
// send the response back to our original HTTP request
|
||||
// task via a channel.
|
||||
let builder_future = async move {
|
||||
let builder = chain
|
||||
let arc_builder = chain
|
||||
.execution_layer
|
||||
.as_ref()
|
||||
.ok_or(BeaconChainError::ExecutionLayerMissing)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?
|
||||
.builder()
|
||||
.builder();
|
||||
let builder = arc_builder
|
||||
.as_ref()
|
||||
.ok_or(BeaconChainError::BuilderMissing)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)?;
|
||||
@@ -4363,7 +4389,8 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.then(
|
||||
|task_spawner: TaskSpawner<T::EthSpec>, chain: Arc<BeaconChain<T>>| {
|
||||
task_spawner.spawn_async_with_rejection(Priority::P1, async move {
|
||||
let merge_readiness = chain.check_merge_readiness().await;
|
||||
let current_slot = chain.slot_clock.now_or_genesis().unwrap_or(Slot::new(0));
|
||||
let merge_readiness = chain.check_merge_readiness(current_slot).await;
|
||||
Ok::<_, warp::reject::Rejection>(
|
||||
warp::reply::json(&api_types::GenericResponse::from(merge_readiness))
|
||||
.into_response(),
|
||||
|
||||
Reference in New Issue
Block a user