mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-31 13:17:09 +00:00
Update fork choice
This commit is contained in:
@@ -134,6 +134,7 @@ pub struct ProtoArray {
|
||||
pub finalized_checkpoint: Checkpoint,
|
||||
pub nodes: Vec<ProtoNode>,
|
||||
pub indices: HashMap<Hash256, usize>,
|
||||
pub unsatisfied_inclusion_list_block: Hash256,
|
||||
pub previous_proposer_boost: ProposerBoost,
|
||||
}
|
||||
|
||||
@@ -159,7 +160,6 @@ impl ProtoArray {
|
||||
finalized_checkpoint: Checkpoint,
|
||||
new_justified_balances: &JustifiedBalances,
|
||||
proposer_boost_root: Hash256,
|
||||
unsatisfied_inclusion_list_block: Hash256,
|
||||
current_slot: Slot,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
@@ -197,19 +197,20 @@ impl ProtoArray {
|
||||
let execution_status_is_invalid = node.execution_status.is_invalid();
|
||||
|
||||
// TODO(focil) seems sketchy...
|
||||
let mut node_delta =
|
||||
if execution_status_is_invalid || node.root == unsatisfied_inclusion_list_block {
|
||||
// If the node has an invalid execution payload, or the payload doesn't satisfy
|
||||
// an inclusion list, reduce its weight to zero.
|
||||
0_i64
|
||||
.checked_sub(node.weight as i64)
|
||||
.ok_or(Error::InvalidExecutionDeltaOverflow(node_index))?
|
||||
} else {
|
||||
deltas
|
||||
.get(node_index)
|
||||
.copied()
|
||||
.ok_or(Error::InvalidNodeDelta(node_index))?
|
||||
};
|
||||
let mut node_delta = if execution_status_is_invalid
|
||||
|| node.root == self.unsatisfied_inclusion_list_block
|
||||
{
|
||||
// If the node has an invalid execution payload, or the payload doesn't satisfy
|
||||
// an inclusion list, reduce its weight to zero.
|
||||
0_i64
|
||||
.checked_sub(node.weight as i64)
|
||||
.ok_or(Error::InvalidExecutionDeltaOverflow(node_index))?
|
||||
} else {
|
||||
deltas
|
||||
.get(node_index)
|
||||
.copied()
|
||||
.ok_or(Error::InvalidNodeDelta(node_index))?
|
||||
};
|
||||
|
||||
// If we find the node for which the proposer boost was previously applied, decrease
|
||||
// the delta by the previous score amount.
|
||||
@@ -891,6 +892,10 @@ impl ProtoArray {
|
||||
return false;
|
||||
}
|
||||
|
||||
if node.root == self.unsatisfied_inclusion_list_block {
|
||||
return false;
|
||||
}
|
||||
|
||||
let genesis_epoch = Epoch::new(0);
|
||||
let current_epoch = current_slot.epoch(E::slots_per_epoch());
|
||||
let node_epoch = node.slot.epoch(E::slots_per_epoch());
|
||||
|
||||
Reference in New Issue
Block a user