|
22 | 22 | - [New `is_supporting_vote`](#new-is_supporting_vote) |
23 | 23 | - [New `should_extend_payload`](#new-should_extend_payload) |
24 | 24 | - [New `get_payload_status_tiebreaker`](#new-get_payload_status_tiebreaker) |
| 25 | + - [Modified `get_attestation_score`](#modified-get_attestation_score) |
25 | 26 | - [Modified `get_weight`](#modified-get_weight) |
26 | 27 | - [New `get_node_children`](#new-get_node_children) |
27 | 28 | - [Modified `get_head`](#modified-get_head) |
@@ -285,7 +286,6 @@ def is_supporting_vote(store: Store, node: ForkChoiceNode, message: LatestMessag |
285 | 286 | return node.payload_status == PAYLOAD_STATUS_FULL |
286 | 287 | else: |
287 | 288 | return node.payload_status == PAYLOAD_STATUS_EMPTY |
288 | | - |
289 | 289 | else: |
290 | 290 | ancestor = get_ancestor(store, message.root, block.slot) |
291 | 291 | return node.root == ancestor.root and ( |
@@ -330,31 +330,49 @@ def get_payload_status_tiebreaker(store: Store, node: ForkChoiceNode) -> uint8: |
330 | 330 | return 2 if should_extend_payload(store, node.root) else 0 |
331 | 331 | ``` |
332 | 332 |
|
| 333 | +### Modified `get_attestation_score` |
| 334 | + |
| 335 | +```python |
| 336 | +def get_attestation_score( |
| 337 | + store: Store, |
| 338 | + # [Modified in Gloas:EIP7732] |
| 339 | + # Removed `root` |
| 340 | + # [New in Gloas:EIP7732] |
| 341 | + node: ForkChoiceNode, |
| 342 | + state: BeaconState, |
| 343 | +) -> Gwei: |
| 344 | + unslashed_and_active_indices = [ |
| 345 | + i |
| 346 | + for i in get_active_validator_indices(state, get_current_epoch(state)) |
| 347 | + if not state.validators[i].slashed |
| 348 | + ] |
| 349 | + return Gwei( |
| 350 | + sum( |
| 351 | + state.validators[i].effective_balance |
| 352 | + for i in unslashed_and_active_indices |
| 353 | + if ( |
| 354 | + i in store.latest_messages |
| 355 | + and i not in store.equivocating_indices |
| 356 | + # [Modified in Gloas:EIP7732] |
| 357 | + and is_supporting_vote(store, node, store.latest_messages[i]) |
| 358 | + ) |
| 359 | + ) |
| 360 | + ) |
| 361 | +``` |
| 362 | + |
333 | 363 | ### Modified `get_weight` |
334 | 364 |
|
335 | 365 | ```python |
336 | | -def get_weight(store: Store, node: ForkChoiceNode) -> Gwei: |
| 366 | +def get_weight( |
| 367 | + store: Store, |
| 368 | + # [Modified in Gloas:EIP7732] |
| 369 | + node: ForkChoiceNode, |
| 370 | +) -> Gwei: |
337 | 371 | if node.payload_status == PAYLOAD_STATUS_PENDING or store.blocks[ |
338 | 372 | node.root |
339 | 373 | ].slot + 1 != get_current_slot(store): |
340 | 374 | state = store.checkpoint_states[store.justified_checkpoint] |
341 | | - unslashed_and_active_indices = [ |
342 | | - i |
343 | | - for i in get_active_validator_indices(state, get_current_epoch(state)) |
344 | | - if not state.validators[i].slashed |
345 | | - ] |
346 | | - attestation_score = Gwei( |
347 | | - sum( |
348 | | - state.validators[i].effective_balance |
349 | | - for i in unslashed_and_active_indices |
350 | | - if ( |
351 | | - i in store.latest_messages |
352 | | - and i not in store.equivocating_indices |
353 | | - and is_supporting_vote(store, node, store.latest_messages[i]) |
354 | | - ) |
355 | | - ) |
356 | | - ) |
357 | | - |
| 375 | + attestation_score = get_attestation_score(store, node, state) |
358 | 376 | if store.proposer_boost_root == Root(): |
359 | 377 | # Return only attestation score if `proposer_boost_root` is not set |
360 | 378 | return attestation_score |
@@ -597,7 +615,8 @@ def on_payload_attestation_message( |
597 | 615 | store: Store, ptc_message: PayloadAttestationMessage, is_from_block: bool = False |
598 | 616 | ) -> None: |
599 | 617 | """ |
600 | | - Run ``on_payload_attestation_message`` upon receiving a new ``ptc_message`` directly on the wire. |
| 618 | + Run ``on_payload_attestation_message`` upon receiving a new ``ptc_message`` from |
| 619 | + either within a block or directly on the wire. |
601 | 620 | """ |
602 | 621 | # The beacon block root must be known |
603 | 622 | data = ptc_message.data |
|
0 commit comments