mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 04:31:51 +00:00
Merge branch 'release-v7.0.0' into unstable
This commit is contained in:
@@ -68,6 +68,7 @@ use serde_json::Value;
|
||||
use slot_clock::SlotClock;
|
||||
use ssz::Encode;
|
||||
pub use state_id::StateId;
|
||||
use std::collections::HashSet;
|
||||
use std::future::Future;
|
||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||
use std::path::PathBuf;
|
||||
@@ -86,13 +87,14 @@ use tokio_stream::{
|
||||
StreamExt,
|
||||
};
|
||||
use tracing::{debug, error, info, warn};
|
||||
use types::AttestationData;
|
||||
use types::{
|
||||
fork_versioned_response::EmptyMetadata, Attestation, AttestationData, AttestationShufflingId,
|
||||
AttesterSlashing, BeaconStateError, ChainSpec, Checkpoint, CommitteeCache, ConfigAndPreset,
|
||||
Epoch, EthSpec, ForkName, ForkVersionedResponse, Hash256, ProposerPreparationData,
|
||||
ProposerSlashing, RelativeEpoch, SignedAggregateAndProof, SignedBlindedBeaconBlock,
|
||||
SignedBlsToExecutionChange, SignedContributionAndProof, SignedValidatorRegistrationData,
|
||||
SignedVoluntaryExit, Slot, SyncCommitteeMessage, SyncContributionData,
|
||||
fork_versioned_response::EmptyMetadata, Attestation, AttestationShufflingId, AttesterSlashing,
|
||||
BeaconStateError, ChainSpec, Checkpoint, CommitteeCache, ConfigAndPreset, Epoch, EthSpec,
|
||||
ForkName, ForkVersionedResponse, Hash256, ProposerPreparationData, ProposerSlashing,
|
||||
RelativeEpoch, SignedAggregateAndProof, SignedBlindedBeaconBlock, SignedBlsToExecutionChange,
|
||||
SignedContributionAndProof, SignedValidatorRegistrationData, SignedVoluntaryExit, Slot,
|
||||
SyncCommitteeMessage, SyncContributionData,
|
||||
};
|
||||
use validator::pubkey_to_validator_index;
|
||||
use version::{
|
||||
@@ -1145,6 +1147,39 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
},
|
||||
);
|
||||
|
||||
// GET beacon/states/{state_id}/pending_consolidations
|
||||
let get_beacon_state_pending_consolidations = beacon_states_path
|
||||
.clone()
|
||||
.and(warp::path("pending_consolidations"))
|
||||
.and(warp::path::end())
|
||||
.then(
|
||||
|state_id: StateId,
|
||||
task_spawner: TaskSpawner<T::EthSpec>,
|
||||
chain: Arc<BeaconChain<T>>| {
|
||||
task_spawner.blocking_json_task(Priority::P1, move || {
|
||||
let (data, execution_optimistic, finalized) = state_id
|
||||
.map_state_and_execution_optimistic_and_finalized(
|
||||
&chain,
|
||||
|state, execution_optimistic, finalized| {
|
||||
let Ok(consolidations) = state.pending_consolidations() else {
|
||||
return Err(warp_utils::reject::custom_bad_request(
|
||||
"Pending consolidations not found".to_string(),
|
||||
));
|
||||
};
|
||||
|
||||
Ok((consolidations.clone(), execution_optimistic, finalized))
|
||||
},
|
||||
)?;
|
||||
|
||||
Ok(api_types::ExecutionOptimisticFinalizedResponse {
|
||||
data,
|
||||
execution_optimistic: Some(execution_optimistic),
|
||||
finalized: Some(finalized),
|
||||
})
|
||||
})
|
||||
},
|
||||
);
|
||||
|
||||
// GET beacon/headers
|
||||
//
|
||||
// Note: this endpoint only returns information about blocks in the canonical chain. Given that
|
||||
@@ -1927,11 +1962,11 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
chain: Arc<BeaconChain<T>>,
|
||||
query: api_types::AttestationPoolQuery| {
|
||||
task_spawner.blocking_response_task(Priority::P1, move || {
|
||||
let query_filter = |data: &AttestationData| {
|
||||
let query_filter = |data: &AttestationData, committee_indices: HashSet<u64>| {
|
||||
query.slot.is_none_or(|slot| slot == data.slot)
|
||||
&& query
|
||||
.committee_index
|
||||
.is_none_or(|index| index == data.index)
|
||||
.is_none_or(|index| committee_indices.contains(&index))
|
||||
};
|
||||
|
||||
let mut attestations = chain.op_pool.get_filtered_attestations(query_filter);
|
||||
@@ -1940,7 +1975,9 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.naive_aggregation_pool
|
||||
.read()
|
||||
.iter()
|
||||
.filter(|&att| query_filter(att.data()))
|
||||
.filter(|&att| {
|
||||
query_filter(att.data(), att.get_committee_indices_map())
|
||||
})
|
||||
.cloned(),
|
||||
);
|
||||
// Use the current slot to find the fork version, and convert all messages to the
|
||||
@@ -4737,6 +4774,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.uor(get_beacon_state_randao)
|
||||
.uor(get_beacon_state_pending_deposits)
|
||||
.uor(get_beacon_state_pending_partial_withdrawals)
|
||||
.uor(get_beacon_state_pending_consolidations)
|
||||
.uor(get_beacon_headers)
|
||||
.uor(get_beacon_headers_block_id)
|
||||
.uor(get_beacon_block)
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::version::{
|
||||
use beacon_chain::{BeaconChain, BeaconChainError, BeaconChainTypes};
|
||||
use eth2::types::{
|
||||
self as api_types, ChainSpec, ForkVersionedResponse, LightClientUpdate,
|
||||
LightClientUpdateResponseChunk, LightClientUpdateSszResponse, LightClientUpdatesQuery,
|
||||
LightClientUpdateResponseChunk, LightClientUpdateResponseChunkInner, LightClientUpdatesQuery,
|
||||
};
|
||||
use ssz::Encode;
|
||||
use std::sync::Arc;
|
||||
@@ -37,15 +37,9 @@ pub fn get_light_client_updates<T: BeaconChainTypes>(
|
||||
.map(|update| map_light_client_update_to_ssz_chunk::<T>(&chain, update))
|
||||
.collect::<Vec<LightClientUpdateResponseChunk>>();
|
||||
|
||||
let ssz_response = LightClientUpdateSszResponse {
|
||||
response_chunk_len: (light_client_updates.len() as u64).to_le_bytes().to_vec(),
|
||||
response_chunk: response_chunks.as_ssz_bytes(),
|
||||
}
|
||||
.as_ssz_bytes();
|
||||
|
||||
Response::builder()
|
||||
.status(200)
|
||||
.body(ssz_response)
|
||||
.body(response_chunks.as_ssz_bytes())
|
||||
.map(|res: Response<Vec<u8>>| add_ssz_content_type_header(res))
|
||||
.map_err(|e| {
|
||||
warp_utils::reject::custom_server_error(format!(
|
||||
@@ -159,16 +153,24 @@ fn map_light_client_update_to_ssz_chunk<T: BeaconChainTypes>(
|
||||
) -> LightClientUpdateResponseChunk {
|
||||
let fork_name = chain
|
||||
.spec
|
||||
.fork_name_at_slot::<T::EthSpec>(*light_client_update.signature_slot());
|
||||
.fork_name_at_slot::<T::EthSpec>(light_client_update.attested_header_slot());
|
||||
|
||||
let fork_digest = ChainSpec::compute_fork_digest(
|
||||
chain.spec.fork_version_for_name(fork_name),
|
||||
chain.genesis_validators_root,
|
||||
);
|
||||
|
||||
LightClientUpdateResponseChunk {
|
||||
let payload = light_client_update.as_ssz_bytes();
|
||||
let response_chunk_len = fork_digest.len() + payload.len();
|
||||
|
||||
let response_chunk = LightClientUpdateResponseChunkInner {
|
||||
context: fork_digest,
|
||||
payload: light_client_update.as_ssz_bytes(),
|
||||
payload,
|
||||
};
|
||||
|
||||
LightClientUpdateResponseChunk {
|
||||
response_chunk_len: response_chunk_len as u64,
|
||||
response_chunk,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user