mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-20 14:28:37 +00:00
Source head_payload_status from get_head, not hardcoded Pending
Thread head_payload_status from get_head() return through to CanonicalHead::new(). In restore_from_store, call get_head() on the loaded fork choice to get the correct status. Removes Pending defaults.
This commit is contained in:
@@ -776,7 +776,7 @@ where
|
||||
slot_clock.now().ok_or("Unable to read slot")?
|
||||
};
|
||||
|
||||
let (initial_head_block_root, _head_payload_status) = fork_choice
|
||||
let (initial_head_block_root, head_payload_status) = fork_choice
|
||||
.get_head(current_slot, &self.spec)
|
||||
.map_err(|e| format!("Unable to get fork choice head: {:?}", e))?;
|
||||
|
||||
@@ -923,7 +923,8 @@ where
|
||||
|
||||
let genesis_validators_root = head_snapshot.beacon_state.genesis_validators_root();
|
||||
let genesis_time = head_snapshot.beacon_state.genesis_time();
|
||||
let canonical_head = CanonicalHead::new(fork_choice, Arc::new(head_snapshot));
|
||||
let canonical_head =
|
||||
CanonicalHead::new(fork_choice, Arc::new(head_snapshot), head_payload_status);
|
||||
let shuffling_cache_size = self.chain_config.shuffling_cache_size;
|
||||
let complete_blob_backfill = self.chain_config.complete_blob_backfill;
|
||||
|
||||
|
||||
@@ -268,6 +268,7 @@ impl<T: BeaconChainTypes> CanonicalHead<T> {
|
||||
pub fn new(
|
||||
fork_choice: BeaconForkChoice<T>,
|
||||
snapshot: Arc<BeaconSnapshot<T::EthSpec>>,
|
||||
head_payload_status: proto_array::PayloadStatus,
|
||||
) -> Self {
|
||||
let fork_choice_view = fork_choice.cached_fork_choice_view();
|
||||
let forkchoice_update_params = fork_choice.get_forkchoice_update_parameters();
|
||||
@@ -275,8 +276,7 @@ impl<T: BeaconChainTypes> CanonicalHead<T> {
|
||||
snapshot,
|
||||
justified_checkpoint: fork_choice_view.justified_checkpoint,
|
||||
finalized_checkpoint: fork_choice_view.finalized_checkpoint,
|
||||
// TODO(gloas): compute from snapshot state once #8998 lands.
|
||||
head_payload_status: proto_array::PayloadStatus::Pending,
|
||||
head_payload_status,
|
||||
head_hash: forkchoice_update_params.head_hash,
|
||||
justified_hash: forkchoice_update_params.justified_hash,
|
||||
finalized_hash: forkchoice_update_params.finalized_hash,
|
||||
@@ -304,9 +304,11 @@ impl<T: BeaconChainTypes> CanonicalHead<T> {
|
||||
store: &BeaconStore<T>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
let fork_choice =
|
||||
let mut fork_choice =
|
||||
<BeaconChain<T>>::load_fork_choice(store.clone(), reset_payload_statuses, spec)?
|
||||
.ok_or(Error::MissingPersistedForkChoice)?;
|
||||
let current_slot_for_head = fork_choice.fc_store().get_current_slot();
|
||||
let (_, head_payload_status) = fork_choice.get_head(current_slot_for_head, spec)?;
|
||||
let fork_choice_view = fork_choice.cached_fork_choice_view();
|
||||
let beacon_block_root = fork_choice_view.head_block_root;
|
||||
let beacon_block = store
|
||||
@@ -337,8 +339,7 @@ impl<T: BeaconChainTypes> CanonicalHead<T> {
|
||||
snapshot: Arc::new(snapshot),
|
||||
justified_checkpoint: fork_choice_view.justified_checkpoint,
|
||||
finalized_checkpoint: fork_choice_view.finalized_checkpoint,
|
||||
// TODO(gloas): compute from snapshot state once #8998 lands.
|
||||
head_payload_status: proto_array::PayloadStatus::Pending,
|
||||
head_payload_status,
|
||||
head_hash: forkchoice_update_params.head_hash,
|
||||
justified_hash: forkchoice_update_params.justified_hash,
|
||||
finalized_hash: forkchoice_update_params.finalized_hash,
|
||||
|
||||
Reference in New Issue
Block a user