Merge branch 'unstable' into merge-unstable-to-deneb-20230816

# Conflicts:
#	beacon_node/http_api/src/lib.rs
This commit is contained in:
Jimmy Chen
2023-08-16 14:31:59 +10:00
26 changed files with 325 additions and 284 deletions

View File

@@ -290,9 +290,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>,
@@ -325,8 +326,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>,
}
@@ -412,14 +411,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)
@@ -468,13 +466,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)),
}
}
@@ -507,8 +502,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)
@@ -612,7 +605,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(),
}
@@ -1524,10 +1517,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,
};