mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 12:47:05 +00:00
Implement get_attester_head logic
This commit is contained in:
@@ -110,6 +110,7 @@ impl ForkChoiceTestDefinition {
|
||||
&justified_balances,
|
||||
Hash256::zero(),
|
||||
&equivocating_indices,
|
||||
Hash256::zero(),
|
||||
Slot::new(0),
|
||||
&spec,
|
||||
)
|
||||
@@ -141,6 +142,7 @@ impl ForkChoiceTestDefinition {
|
||||
&justified_balances,
|
||||
proposer_boost_root,
|
||||
&equivocating_indices,
|
||||
Hash256::zero(),
|
||||
Slot::new(0),
|
||||
&spec,
|
||||
)
|
||||
@@ -169,6 +171,7 @@ impl ForkChoiceTestDefinition {
|
||||
&justified_balances,
|
||||
Hash256::zero(),
|
||||
&equivocating_indices,
|
||||
Hash256::zero(),
|
||||
Slot::new(0),
|
||||
&spec,
|
||||
);
|
||||
|
||||
@@ -159,6 +159,7 @@ 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> {
|
||||
@@ -195,17 +196,20 @@ impl ProtoArray {
|
||||
|
||||
let execution_status_is_invalid = node.execution_status.is_invalid();
|
||||
|
||||
let mut node_delta = if execution_status_is_invalid {
|
||||
// If the node has an invalid execution payload, 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))?
|
||||
};
|
||||
// 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))?
|
||||
};
|
||||
|
||||
// If we find the node for which the proposer boost was previously applied, decrease
|
||||
// the delta by the previous score amount.
|
||||
|
||||
@@ -467,6 +467,7 @@ impl ProtoArrayForkChoice {
|
||||
justified_state_balances: &JustifiedBalances,
|
||||
proposer_boost_root: Hash256,
|
||||
equivocating_indices: &BTreeSet<u64>,
|
||||
unsatisfied_inclusion_list_block: Hash256,
|
||||
current_slot: Slot,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<Hash256, String> {
|
||||
@@ -489,6 +490,7 @@ impl ProtoArrayForkChoice {
|
||||
finalized_checkpoint,
|
||||
new_balances,
|
||||
proposer_boost_root,
|
||||
unsatisfied_inclusion_list_block,
|
||||
current_slot,
|
||||
spec,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user