Implement get_attester_head logic

This commit is contained in:
Eitan Seri-Levi
2025-01-16 13:19:07 +07:00
parent 3069b36243
commit f87f83873a
9 changed files with 94 additions and 14 deletions

View File

@@ -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.