mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 17:26:04 +00:00
ForkChoice: remove head_block_root field (#4590)
This field is redundant with `ForkchoiceUpdateParameters.head_root`, the same `head_root` is assigned to both fields in [`get_head`](dfcb3363c7/consensus/fork_choice/src/fork_choice.rs (L508-L523)).
This commit is contained in:
@@ -289,9 +289,10 @@ pub enum AttestationFromBlock {
|
|||||||
False,
|
False,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parameters which are cached between calls to `Self::get_head`.
|
/// Parameters which are cached between calls to `ForkChoice::get_head`.
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct ForkchoiceUpdateParameters {
|
pub struct ForkchoiceUpdateParameters {
|
||||||
|
/// The most recent result of running `ForkChoice::get_head`.
|
||||||
pub head_root: Hash256,
|
pub head_root: Hash256,
|
||||||
pub head_hash: Option<ExecutionBlockHash>,
|
pub head_hash: Option<ExecutionBlockHash>,
|
||||||
pub justified_hash: Option<ExecutionBlockHash>,
|
pub justified_hash: Option<ExecutionBlockHash>,
|
||||||
@@ -324,8 +325,6 @@ pub struct ForkChoice<T, E> {
|
|||||||
queued_attestations: Vec<QueuedAttestation>,
|
queued_attestations: Vec<QueuedAttestation>,
|
||||||
/// Stores a cache of the values required to be sent to the execution layer.
|
/// Stores a cache of the values required to be sent to the execution layer.
|
||||||
forkchoice_update_parameters: ForkchoiceUpdateParameters,
|
forkchoice_update_parameters: ForkchoiceUpdateParameters,
|
||||||
/// The most recent result of running `Self::get_head`.
|
|
||||||
head_block_root: Hash256,
|
|
||||||
_phantom: PhantomData<E>,
|
_phantom: PhantomData<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,14 +409,13 @@ where
|
|||||||
head_hash: None,
|
head_hash: None,
|
||||||
justified_hash: None,
|
justified_hash: None,
|
||||||
finalized_hash: None,
|
finalized_hash: None,
|
||||||
|
// This will be updated during the next call to `Self::get_head`.
|
||||||
head_root: Hash256::zero(),
|
head_root: Hash256::zero(),
|
||||||
},
|
},
|
||||||
// This will be updated during the next call to `Self::get_head`.
|
|
||||||
head_block_root: Hash256::zero(),
|
|
||||||
_phantom: PhantomData,
|
_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)?;
|
fork_choice.get_head(current_slot, spec)?;
|
||||||
|
|
||||||
Ok(fork_choice)
|
Ok(fork_choice)
|
||||||
@@ -502,8 +500,6 @@ where
|
|||||||
spec,
|
spec,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
self.head_block_root = head_root;
|
|
||||||
|
|
||||||
// Cache some values for the next forkchoiceUpdate call to the execution layer.
|
// Cache some values for the next forkchoiceUpdate call to the execution layer.
|
||||||
let head_hash = self
|
let head_hash = self
|
||||||
.get_block(&head_root)
|
.get_block(&head_root)
|
||||||
@@ -607,7 +603,7 @@ where
|
|||||||
/// have *differing* finalized and justified information.
|
/// have *differing* finalized and justified information.
|
||||||
pub fn cached_fork_choice_view(&self) -> ForkChoiceView {
|
pub fn cached_fork_choice_view(&self) -> ForkChoiceView {
|
||||||
ForkChoiceView {
|
ForkChoiceView {
|
||||||
head_block_root: self.head_block_root,
|
head_block_root: self.forkchoice_update_parameters.head_root,
|
||||||
justified_checkpoint: self.justified_checkpoint(),
|
justified_checkpoint: self.justified_checkpoint(),
|
||||||
finalized_checkpoint: self.finalized_checkpoint(),
|
finalized_checkpoint: self.finalized_checkpoint(),
|
||||||
}
|
}
|
||||||
@@ -1518,10 +1514,9 @@ where
|
|||||||
head_hash: None,
|
head_hash: None,
|
||||||
justified_hash: None,
|
justified_hash: None,
|
||||||
finalized_hash: None,
|
finalized_hash: None,
|
||||||
|
// Will be updated in the following call to `Self::get_head`.
|
||||||
head_root: Hash256::zero(),
|
head_root: Hash256::zero(),
|
||||||
},
|
},
|
||||||
// Will be updated in the following call to `Self::get_head`.
|
|
||||||
head_block_root: Hash256::zero(),
|
|
||||||
_phantom: PhantomData,
|
_phantom: PhantomData,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user