Skip to content

Commit 39eb814

Browse files
committed
Merge branch 'release-v7.0.0' into unstable
2 parents d96b731 + af51d50 commit 39eb814

File tree

40 files changed

+820
-427
lines changed

40 files changed

+820
-427
lines changed

Cargo.lock

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4007,7 +4007,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
40074007
&mut state,
40084008
)
40094009
.unwrap_or_else(|e| {
4010-
error!("error caching light_client data {:?}", e);
4010+
debug!("error caching light_client data {:?}", e);
40114011
});
40124012
}
40134013

@@ -7135,6 +7135,31 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
71357135
}
71367136
}
71377137
}
7138+
7139+
/// Retrieves block roots (in ascending slot order) within some slot range from fork choice.
7140+
pub fn block_roots_from_fork_choice(&self, start_slot: u64, count: u64) -> Vec<Hash256> {
7141+
let head_block_root = self.canonical_head.cached_head().head_block_root();
7142+
let fork_choice_read_lock = self.canonical_head.fork_choice_read_lock();
7143+
let block_roots_iter = fork_choice_read_lock
7144+
.proto_array()
7145+
.iter_block_roots(&head_block_root);
7146+
let end_slot = start_slot.saturating_add(count);
7147+
let mut roots = vec![];
7148+
7149+
for (root, slot) in block_roots_iter {
7150+
if slot < end_slot && slot >= start_slot {
7151+
roots.push(root);
7152+
}
7153+
if slot < start_slot {
7154+
break;
7155+
}
7156+
}
7157+
7158+
drop(fork_choice_read_lock);
7159+
// return in ascending slot order
7160+
roots.reverse();
7161+
roots
7162+
}
71387163
}
71397164

71407165
impl<T: BeaconChainTypes> Drop for BeaconChain<T> {

beacon_node/beacon_chain/src/eth1_chain.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,12 @@ pub struct DummyEth1ChainBackend<E: EthSpec>(PhantomData<E>);
362362
impl<E: EthSpec> Eth1ChainBackend<E> for DummyEth1ChainBackend<E> {
363363
/// Produce some deterministic junk based upon the current epoch.
364364
fn eth1_data(&self, state: &BeaconState<E>, _spec: &ChainSpec) -> Result<Eth1Data, Error> {
365+
// [New in Electra:EIP6110]
366+
if let Ok(deposit_requests_start_index) = state.deposit_requests_start_index() {
367+
if state.eth1_deposit_index() == deposit_requests_start_index {
368+
return Ok(state.eth1_data().clone());
369+
}
370+
}
365371
let current_epoch = state.current_epoch();
366372
let slots_per_voting_period = E::slots_per_eth1_voting_period() as u64;
367373
let current_voting_period: u64 = current_epoch.as_u64() / slots_per_voting_period;
@@ -456,6 +462,12 @@ impl<E: EthSpec> CachingEth1Backend<E> {
456462

457463
impl<E: EthSpec> Eth1ChainBackend<E> for CachingEth1Backend<E> {
458464
fn eth1_data(&self, state: &BeaconState<E>, spec: &ChainSpec) -> Result<Eth1Data, Error> {
465+
// [New in Electra:EIP6110]
466+
if let Ok(deposit_requests_start_index) = state.deposit_requests_start_index() {
467+
if state.eth1_deposit_index() == deposit_requests_start_index {
468+
return Ok(state.eth1_data().clone());
469+
}
470+
}
459471
let period = E::SlotsPerEth1VotingPeriod::to_u64();
460472
let voting_period_start_slot = (state.slot() / period) * period;
461473
let voting_period_start_seconds = slot_start_seconds(

beacon_node/execution_layer/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ pub enum BlockProposalContents<E: EthSpec, Payload: AbstractExecPayload<E>> {
210210
/// `None` for blinded `PayloadAndBlobs`.
211211
blobs_and_proofs: Option<(BlobsList<E>, KzgProofs<E>)>,
212212
// TODO(electra): this should probably be a separate variant/superstruct
213+
// See: https://github.com/sigp/lighthouse/issues/6981
213214
requests: Option<ExecutionRequests<E>>,
214215
},
215216
}

beacon_node/http_api/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ metrics = { workspace = true }
2828
network = { workspace = true }
2929
operation_pool = { workspace = true }
3030
parking_lot = { workspace = true }
31+
proto_array = { workspace = true }
3132
rand = { workspace = true }
3233
safe_arith = { workspace = true }
3334
sensitive_url = { workspace = true }

beacon_node/http_api/src/lib.rs

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ use serde_json::Value;
6868
use slot_clock::SlotClock;
6969
use ssz::Encode;
7070
pub use state_id::StateId;
71+
use std::collections::HashSet;
7172
use std::future::Future;
7273
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
7374
use std::path::PathBuf;
@@ -86,13 +87,14 @@ use tokio_stream::{
8687
StreamExt,
8788
};
8889
use tracing::{debug, error, info, warn};
90+
use types::AttestationData;
8991
use types::{
90-
fork_versioned_response::EmptyMetadata, Attestation, AttestationData, AttestationShufflingId,
91-
AttesterSlashing, BeaconStateError, ChainSpec, Checkpoint, CommitteeCache, ConfigAndPreset,
92-
Epoch, EthSpec, ForkName, ForkVersionedResponse, Hash256, ProposerPreparationData,
93-
ProposerSlashing, RelativeEpoch, SignedAggregateAndProof, SignedBlindedBeaconBlock,
94-
SignedBlsToExecutionChange, SignedContributionAndProof, SignedValidatorRegistrationData,
95-
SignedVoluntaryExit, Slot, SyncCommitteeMessage, SyncContributionData,
92+
fork_versioned_response::EmptyMetadata, Attestation, AttestationShufflingId, AttesterSlashing,
93+
BeaconStateError, ChainSpec, Checkpoint, CommitteeCache, ConfigAndPreset, Epoch, EthSpec,
94+
ForkName, ForkVersionedResponse, Hash256, ProposerPreparationData, ProposerSlashing,
95+
RelativeEpoch, SignedAggregateAndProof, SignedBlindedBeaconBlock, SignedBlsToExecutionChange,
96+
SignedContributionAndProof, SignedValidatorRegistrationData, SignedVoluntaryExit, Slot,
97+
SyncCommitteeMessage, SyncContributionData,
9698
};
9799
use validator::pubkey_to_validator_index;
98100
use version::{
@@ -1145,6 +1147,39 @@ pub fn serve<T: BeaconChainTypes>(
11451147
},
11461148
);
11471149

1150+
// GET beacon/states/{state_id}/pending_consolidations
1151+
let get_beacon_state_pending_consolidations = beacon_states_path
1152+
.clone()
1153+
.and(warp::path("pending_consolidations"))
1154+
.and(warp::path::end())
1155+
.then(
1156+
|state_id: StateId,
1157+
task_spawner: TaskSpawner<T::EthSpec>,
1158+
chain: Arc<BeaconChain<T>>| {
1159+
task_spawner.blocking_json_task(Priority::P1, move || {
1160+
let (data, execution_optimistic, finalized) = state_id
1161+
.map_state_and_execution_optimistic_and_finalized(
1162+
&chain,
1163+
|state, execution_optimistic, finalized| {
1164+
let Ok(consolidations) = state.pending_consolidations() else {
1165+
return Err(warp_utils::reject::custom_bad_request(
1166+
"Pending consolidations not found".to_string(),
1167+
));
1168+
};
1169+
1170+
Ok((consolidations.clone(), execution_optimistic, finalized))
1171+
},
1172+
)?;
1173+
1174+
Ok(api_types::ExecutionOptimisticFinalizedResponse {
1175+
data,
1176+
execution_optimistic: Some(execution_optimistic),
1177+
finalized: Some(finalized),
1178+
})
1179+
})
1180+
},
1181+
);
1182+
11481183
// GET beacon/headers
11491184
//
11501185
// Note: this endpoint only returns information about blocks in the canonical chain. Given that
@@ -1927,11 +1962,11 @@ pub fn serve<T: BeaconChainTypes>(
19271962
chain: Arc<BeaconChain<T>>,
19281963
query: api_types::AttestationPoolQuery| {
19291964
task_spawner.blocking_response_task(Priority::P1, move || {
1930-
let query_filter = |data: &AttestationData| {
1965+
let query_filter = |data: &AttestationData, committee_indices: HashSet<u64>| {
19311966
query.slot.is_none_or(|slot| slot == data.slot)
19321967
&& query
19331968
.committee_index
1934-
.is_none_or(|index| index == data.index)
1969+
.is_none_or(|index| committee_indices.contains(&index))
19351970
};
19361971

19371972
let mut attestations = chain.op_pool.get_filtered_attestations(query_filter);
@@ -1940,7 +1975,9 @@ pub fn serve<T: BeaconChainTypes>(
19401975
.naive_aggregation_pool
19411976
.read()
19421977
.iter()
1943-
.filter(|&att| query_filter(att.data()))
1978+
.filter(|&att| {
1979+
query_filter(att.data(), att.get_committee_indices_map())
1980+
})
19441981
.cloned(),
19451982
);
19461983
// Use the current slot to find the fork version, and convert all messages to the
@@ -4737,6 +4774,7 @@ pub fn serve<T: BeaconChainTypes>(
47374774
.uor(get_beacon_state_randao)
47384775
.uor(get_beacon_state_pending_deposits)
47394776
.uor(get_beacon_state_pending_partial_withdrawals)
4777+
.uor(get_beacon_state_pending_consolidations)
47404778
.uor(get_beacon_headers)
47414779
.uor(get_beacon_headers_block_id)
47424780
.uor(get_beacon_block)

beacon_node/http_api/src/light_client.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::version::{
44
use beacon_chain::{BeaconChain, BeaconChainError, BeaconChainTypes};
55
use eth2::types::{
66
self as api_types, ChainSpec, ForkVersionedResponse, LightClientUpdate,
7-
LightClientUpdateResponseChunk, LightClientUpdateSszResponse, LightClientUpdatesQuery,
7+
LightClientUpdateResponseChunk, LightClientUpdateResponseChunkInner, LightClientUpdatesQuery,
88
};
99
use ssz::Encode;
1010
use std::sync::Arc;
@@ -37,15 +37,9 @@ pub fn get_light_client_updates<T: BeaconChainTypes>(
3737
.map(|update| map_light_client_update_to_ssz_chunk::<T>(&chain, update))
3838
.collect::<Vec<LightClientUpdateResponseChunk>>();
3939

40-
let ssz_response = LightClientUpdateSszResponse {
41-
response_chunk_len: (light_client_updates.len() as u64).to_le_bytes().to_vec(),
42-
response_chunk: response_chunks.as_ssz_bytes(),
43-
}
44-
.as_ssz_bytes();
45-
4640
Response::builder()
4741
.status(200)
48-
.body(ssz_response)
42+
.body(response_chunks.as_ssz_bytes())
4943
.map(|res: Response<Vec<u8>>| add_ssz_content_type_header(res))
5044
.map_err(|e| {
5145
warp_utils::reject::custom_server_error(format!(
@@ -159,16 +153,24 @@ fn map_light_client_update_to_ssz_chunk<T: BeaconChainTypes>(
159153
) -> LightClientUpdateResponseChunk {
160154
let fork_name = chain
161155
.spec
162-
.fork_name_at_slot::<T::EthSpec>(*light_client_update.signature_slot());
156+
.fork_name_at_slot::<T::EthSpec>(light_client_update.attested_header_slot());
163157

164158
let fork_digest = ChainSpec::compute_fork_digest(
165159
chain.spec.fork_version_for_name(fork_name),
166160
chain.genesis_validators_root,
167161
);
168162

169-
LightClientUpdateResponseChunk {
163+
let payload = light_client_update.as_ssz_bytes();
164+
let response_chunk_len = fork_digest.len() + payload.len();
165+
166+
let response_chunk = LightClientUpdateResponseChunkInner {
170167
context: fork_digest,
171-
payload: light_client_update.as_ssz_bytes(),
168+
payload,
169+
};
170+
171+
LightClientUpdateResponseChunk {
172+
response_chunk_len: response_chunk_len as u64,
173+
response_chunk,
172174
}
173175
}
174176

0 commit comments

Comments
 (0)