mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-31 05:07:12 +00:00
Implement get_attester_head logic
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user