mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 08:52:54 +00:00
Merge branch 'release-v7.0.0' into unstable
This commit is contained in:
@@ -4007,7 +4007,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
&mut state,
|
||||
)
|
||||
.unwrap_or_else(|e| {
|
||||
error!("error caching light_client data {:?}", e);
|
||||
debug!("error caching light_client data {:?}", e);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7135,6 +7135,31 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Retrieves block roots (in ascending slot order) within some slot range from fork choice.
|
||||
pub fn block_roots_from_fork_choice(&self, start_slot: u64, count: u64) -> Vec<Hash256> {
|
||||
let head_block_root = self.canonical_head.cached_head().head_block_root();
|
||||
let fork_choice_read_lock = self.canonical_head.fork_choice_read_lock();
|
||||
let block_roots_iter = fork_choice_read_lock
|
||||
.proto_array()
|
||||
.iter_block_roots(&head_block_root);
|
||||
let end_slot = start_slot.saturating_add(count);
|
||||
let mut roots = vec![];
|
||||
|
||||
for (root, slot) in block_roots_iter {
|
||||
if slot < end_slot && slot >= start_slot {
|
||||
roots.push(root);
|
||||
}
|
||||
if slot < start_slot {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
drop(fork_choice_read_lock);
|
||||
// return in ascending slot order
|
||||
roots.reverse();
|
||||
roots
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: BeaconChainTypes> Drop for BeaconChain<T> {
|
||||
|
||||
@@ -362,6 +362,12 @@ pub struct DummyEth1ChainBackend<E: EthSpec>(PhantomData<E>);
|
||||
impl<E: EthSpec> Eth1ChainBackend<E> for DummyEth1ChainBackend<E> {
|
||||
/// Produce some deterministic junk based upon the current epoch.
|
||||
fn eth1_data(&self, state: &BeaconState<E>, _spec: &ChainSpec) -> Result<Eth1Data, Error> {
|
||||
// [New in Electra:EIP6110]
|
||||
if let Ok(deposit_requests_start_index) = state.deposit_requests_start_index() {
|
||||
if state.eth1_deposit_index() == deposit_requests_start_index {
|
||||
return Ok(state.eth1_data().clone());
|
||||
}
|
||||
}
|
||||
let current_epoch = state.current_epoch();
|
||||
let slots_per_voting_period = E::slots_per_eth1_voting_period() as u64;
|
||||
let current_voting_period: u64 = current_epoch.as_u64() / slots_per_voting_period;
|
||||
@@ -456,6 +462,12 @@ impl<E: EthSpec> CachingEth1Backend<E> {
|
||||
|
||||
impl<E: EthSpec> Eth1ChainBackend<E> for CachingEth1Backend<E> {
|
||||
fn eth1_data(&self, state: &BeaconState<E>, spec: &ChainSpec) -> Result<Eth1Data, Error> {
|
||||
// [New in Electra:EIP6110]
|
||||
if let Ok(deposit_requests_start_index) = state.deposit_requests_start_index() {
|
||||
if state.eth1_deposit_index() == deposit_requests_start_index {
|
||||
return Ok(state.eth1_data().clone());
|
||||
}
|
||||
}
|
||||
let period = E::SlotsPerEth1VotingPeriod::to_u64();
|
||||
let voting_period_start_slot = (state.slot() / period) * period;
|
||||
let voting_period_start_seconds = slot_start_seconds(
|
||||
|
||||
Reference in New Issue
Block a user