mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-20 14:28:37 +00:00
Merge remote-tracking branch 'origin/unstable' into tree-states
This commit is contained in:
@@ -276,9 +276,10 @@ pub enum AttestationFromBlock {
|
||||
False,
|
||||
}
|
||||
|
||||
/// Parameters which are cached between calls to `Self::get_head`.
|
||||
/// Parameters which are cached between calls to `ForkChoice::get_head`.
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct ForkchoiceUpdateParameters {
|
||||
/// The most recent result of running `ForkChoice::get_head`.
|
||||
pub head_root: Hash256,
|
||||
pub head_hash: Option<ExecutionBlockHash>,
|
||||
pub justified_hash: Option<ExecutionBlockHash>,
|
||||
@@ -311,8 +312,6 @@ pub struct ForkChoice<T, E> {
|
||||
queued_attestations: Vec<QueuedAttestation>,
|
||||
/// Stores a cache of the values required to be sent to the execution layer.
|
||||
forkchoice_update_parameters: ForkchoiceUpdateParameters,
|
||||
/// The most recent result of running `Self::get_head`.
|
||||
head_block_root: Hash256,
|
||||
_phantom: PhantomData<E>,
|
||||
}
|
||||
|
||||
@@ -343,7 +342,7 @@ where
|
||||
spec: &ChainSpec,
|
||||
) -> Result<Self, Error<T::Error>> {
|
||||
// Sanity check: the anchor must lie on an epoch boundary.
|
||||
if anchor_block.slot() % E::slots_per_epoch() != 0 {
|
||||
if anchor_state.slot() % E::slots_per_epoch() != 0 {
|
||||
return Err(Error::InvalidAnchor {
|
||||
block_slot: anchor_block.slot(),
|
||||
state_slot: anchor_state.slot(),
|
||||
@@ -379,6 +378,7 @@ where
|
||||
let current_slot = current_slot.unwrap_or_else(|| fc_store.get_current_slot());
|
||||
|
||||
let proto_array = ProtoArrayForkChoice::new::<E>(
|
||||
current_slot,
|
||||
finalized_block_slot,
|
||||
finalized_block_state_root,
|
||||
*fc_store.justified_checkpoint(),
|
||||
@@ -397,14 +397,13 @@ where
|
||||
head_hash: None,
|
||||
justified_hash: None,
|
||||
finalized_hash: None,
|
||||
// This will be updated during the next call to `Self::get_head`.
|
||||
head_root: Hash256::zero(),
|
||||
},
|
||||
// This will be updated during the next call to `Self::get_head`.
|
||||
head_block_root: Hash256::zero(),
|
||||
_phantom: PhantomData,
|
||||
};
|
||||
|
||||
// Ensure that `fork_choice.head_block_root` is updated.
|
||||
// Ensure that `fork_choice.forkchoice_update_parameters.head_root` is updated.
|
||||
fork_choice.get_head(current_slot, spec)?;
|
||||
|
||||
Ok(fork_choice)
|
||||
@@ -453,13 +452,10 @@ where
|
||||
// for lower slots to account for skip slots.
|
||||
.find(|(_, slot)| *slot <= ancestor_slot)
|
||||
.map(|(root, _)| root)),
|
||||
Ordering::Less => Ok(Some(block_root)),
|
||||
Ordering::Equal =>
|
||||
// Root is older than queried slot, thus a skip slot. Return most recent root prior
|
||||
// to slot.
|
||||
{
|
||||
Ok(Some(block_root))
|
||||
}
|
||||
Ordering::Less => Ok(Some(block_root)),
|
||||
Ordering::Equal => Ok(Some(block_root)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -492,8 +488,6 @@ where
|
||||
spec,
|
||||
)?;
|
||||
|
||||
self.head_block_root = head_root;
|
||||
|
||||
// Cache some values for the next forkchoiceUpdate call to the execution layer.
|
||||
let head_hash = self
|
||||
.get_block(&head_root)
|
||||
@@ -597,7 +591,7 @@ where
|
||||
/// have *differing* finalized and justified information.
|
||||
pub fn cached_fork_choice_view(&self) -> ForkChoiceView {
|
||||
ForkChoiceView {
|
||||
head_block_root: self.head_block_root,
|
||||
head_block_root: self.forkchoice_update_parameters.head_root,
|
||||
justified_checkpoint: self.justified_checkpoint(),
|
||||
finalized_checkpoint: self.finalized_checkpoint(),
|
||||
}
|
||||
@@ -744,7 +738,7 @@ where
|
||||
.unrealized_justified_checkpoint
|
||||
.zip(parent_block.unrealized_finalized_checkpoint)
|
||||
.filter(|(parent_justified, parent_finalized)| {
|
||||
parent_justified.epoch == block_epoch && parent_finalized.epoch + 1 >= block_epoch
|
||||
parent_justified.epoch == block_epoch && parent_finalized.epoch + 1 == block_epoch
|
||||
});
|
||||
|
||||
let (unrealized_justified_checkpoint, unrealized_finalized_checkpoint) =
|
||||
@@ -1463,10 +1457,9 @@ where
|
||||
head_hash: None,
|
||||
justified_hash: None,
|
||||
finalized_hash: None,
|
||||
// Will be updated in the following call to `Self::get_head`.
|
||||
head_root: Hash256::zero(),
|
||||
},
|
||||
// Will be updated in the following call to `Self::get_head`.
|
||||
head_block_root: Hash256::zero(),
|
||||
_phantom: PhantomData,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user