|
1311 | 1311 | ] |
1312 | 1312 | </spec> |
1313 | 1313 |
|
| 1314 | +- name: compute_proposer_score#phase0 |
| 1315 | + sources: [] |
| 1316 | + spec: | |
| 1317 | + <spec fn="compute_proposer_score" fork="phase0" hash="43ff8b01"> |
| 1318 | + def compute_proposer_score(state: BeaconState) -> Gwei: |
| 1319 | + committee_weight = get_total_active_balance(state) // SLOTS_PER_EPOCH |
| 1320 | + return (committee_weight * PROPOSER_SCORE_BOOST) // 100 |
| 1321 | + </spec> |
| 1322 | + |
1314 | 1323 | - name: compute_pulled_up_tip#phase0 |
1315 | 1324 | sources: [] |
1316 | 1325 | spec: | |
|
2587 | 2596 | return participation_flag_indices |
2588 | 2597 | </spec> |
2589 | 2598 |
|
| 2599 | +- name: get_attestation_score#phase0 |
| 2600 | + sources: [] |
| 2601 | + spec: | |
| 2602 | + <spec fn="get_attestation_score" fork="phase0" hash="da969f50"> |
| 2603 | + def get_attestation_score(store: Store, root: Root, state: BeaconState) -> Gwei: |
| 2604 | + unslashed_and_active_indices = [ |
| 2605 | + i |
| 2606 | + for i in get_active_validator_indices(state, get_current_epoch(state)) |
| 2607 | + if not state.validators[i].slashed |
| 2608 | + ] |
| 2609 | + return Gwei( |
| 2610 | + sum( |
| 2611 | + state.validators[i].effective_balance |
| 2612 | + for i in unslashed_and_active_indices |
| 2613 | + if ( |
| 2614 | + i in store.latest_messages |
| 2615 | + and i not in store.equivocating_indices |
| 2616 | + and get_ancestor(store, store.latest_messages[i].root, store.blocks[root].slot) |
| 2617 | + == root |
| 2618 | + ) |
| 2619 | + ) |
| 2620 | + ) |
| 2621 | + </spec> |
| 2622 | + |
| 2623 | +- name: get_attestation_score#gloas |
| 2624 | + sources: [] |
| 2625 | + spec: | |
| 2626 | + <spec fn="get_attestation_score" fork="gloas" hash="8a2e4701"> |
| 2627 | + def get_attestation_score( |
| 2628 | + store: Store, |
| 2629 | + # [Modified in Gloas:EIP7732] |
| 2630 | + # Removed `root` |
| 2631 | + # [New in Gloas:EIP7732] |
| 2632 | + node: ForkChoiceNode, |
| 2633 | + state: BeaconState, |
| 2634 | + ) -> Gwei: |
| 2635 | + unslashed_and_active_indices = [ |
| 2636 | + i |
| 2637 | + for i in get_active_validator_indices(state, get_current_epoch(state)) |
| 2638 | + if not state.validators[i].slashed |
| 2639 | + ] |
| 2640 | + return Gwei( |
| 2641 | + sum( |
| 2642 | + state.validators[i].effective_balance |
| 2643 | + for i in unslashed_and_active_indices |
| 2644 | + if ( |
| 2645 | + i in store.latest_messages |
| 2646 | + and i not in store.equivocating_indices |
| 2647 | + # [Modified in Gloas:EIP7732] |
| 2648 | + and is_supporting_vote(store, node, store.latest_messages[i]) |
| 2649 | + ) |
| 2650 | + ) |
| 2651 | + ) |
| 2652 | + </spec> |
| 2653 | + |
2590 | 2654 | - name: get_attestation_signature#phase0 |
2591 | 2655 | sources: |
2592 | 2656 | - file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/signatures/SigningRootUtil.java |
|
4595 | 4659 | return head_root |
4596 | 4660 | </spec> |
4597 | 4661 |
|
| 4662 | +- name: get_proposer_preferences_signature#gloas |
| 4663 | + sources: [] |
| 4664 | + spec: | |
| 4665 | + <spec fn="get_proposer_preferences_signature" fork="gloas" hash="6a34cb73"> |
| 4666 | + def get_proposer_preferences_signature( |
| 4667 | + state: BeaconState, preferences: ProposerPreferences, privkey: int |
| 4668 | + ) -> BLSSignature: |
| 4669 | + domain = get_domain( |
| 4670 | + state, DOMAIN_PROPOSER_PREFERENCES, compute_epoch_at_slot(preferences.proposal_slot) |
| 4671 | + ) |
| 4672 | + signing_root = compute_signing_root(preferences, domain) |
| 4673 | + return bls.Sign(privkey, signing_root) |
| 4674 | + </spec> |
| 4675 | + |
4598 | 4676 | - name: get_proposer_reorg_cutoff_ms#phase0 |
4599 | 4677 | sources: |
4600 | 4678 | - file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/Spec.java |
|
4959 | 5037 | return set(filter(lambda index: not state.validators[index].slashed, participating_indices)) |
4960 | 5038 | </spec> |
4961 | 5039 |
|
| 5040 | +- name: get_upcoming_proposal_slots#gloas |
| 5041 | + sources: [] |
| 5042 | + spec: | |
| 5043 | + <spec fn="get_upcoming_proposal_slots" fork="gloas" hash="802ba480"> |
| 5044 | + def get_upcoming_proposal_slots( |
| 5045 | + state: BeaconState, validator_index: ValidatorIndex |
| 5046 | + ) -> Sequence[Slot]: |
| 5047 | + """ |
| 5048 | + Get the slots in the next epoch for which ``validator_index`` is proposing. |
| 5049 | + """ |
| 5050 | + return [ |
| 5051 | + Slot(compute_start_slot_at_epoch(get_current_epoch(state) + Epoch(1)) + offset) |
| 5052 | + for offset, proposer_index in enumerate(state.proposer_lookahead[SLOTS_PER_EPOCH:]) |
| 5053 | + if validator_index == proposer_index |
| 5054 | + ] |
| 5055 | + </spec> |
| 5056 | + |
4962 | 5057 | - name: get_validator_activation_churn_limit#deneb |
4963 | 5058 | sources: |
4964 | 5059 | - file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/common/helpers/BeaconStateAccessors.java |
|
5804 | 5899 | ) |
5805 | 5900 | </spec> |
5806 | 5901 |
|
| 5902 | +- name: is_eligible_for_partial_withdrawals#electra |
| 5903 | + sources: [] |
| 5904 | + spec: | |
| 5905 | + <spec fn="is_eligible_for_partial_withdrawals" fork="electra" hash="c8d29720"> |
| 5906 | + def is_eligible_for_partial_withdrawals(validator: Validator, balance: Gwei) -> bool: |
| 5907 | + """ |
| 5908 | + Check if ``validator`` can process a pending partial withdrawal. |
| 5909 | + """ |
| 5910 | + has_sufficient_effective_balance = validator.effective_balance >= MIN_ACTIVATION_BALANCE |
| 5911 | + has_excess_balance = balance > MIN_ACTIVATION_BALANCE |
| 5912 | + return ( |
| 5913 | + validator.exit_epoch == FAR_FUTURE_EPOCH |
| 5914 | + and has_sufficient_effective_balance |
| 5915 | + and has_excess_balance |
| 5916 | + ) |
| 5917 | + </spec> |
| 5918 | + |
5807 | 5919 | - name: is_execution_block#bellatrix |
5808 | 5920 | sources: [] |
5809 | 5921 | spec: | |
|
5896 | 6008 | return not store.block_timeliness[head_root] |
5897 | 6009 | </spec> |
5898 | 6010 |
|
| 6011 | +- name: is_head_late#gloas |
| 6012 | + sources: [] |
| 6013 | + spec: | |
| 6014 | + <spec fn="is_head_late" fork="gloas" hash="dd4c9308"> |
| 6015 | + def is_head_late(store: Store, head_root: Root) -> bool: |
| 6016 | + return not store.block_timeliness[head_root][ATTESTATION_TIMELINESS_INDEX] |
| 6017 | + </spec> |
| 6018 | + |
5899 | 6019 | - name: is_head_weak#phase0 |
5900 | 6020 | sources: |
5901 | 6021 | - file: storage/src/main/java/tech/pegasys/teku/storage/store/Store.java |
|
5909 | 6029 | return head_weight < reorg_threshold |
5910 | 6030 | </spec> |
5911 | 6031 |
|
| 6032 | +- name: is_head_weak#gloas |
| 6033 | + sources: [] |
| 6034 | + spec: | |
| 6035 | + <spec fn="is_head_weak" fork="gloas" hash="a763a3db"> |
| 6036 | + def is_head_weak(store: Store, head_root: Root) -> bool: |
| 6037 | + # Calculate weight threshold for weak head |
| 6038 | + justified_state = store.checkpoint_states[store.justified_checkpoint] |
| 6039 | + reorg_threshold = calculate_committee_fraction(justified_state, REORG_HEAD_WEIGHT_THRESHOLD) |
| 6040 | + |
| 6041 | + # Compute head weight including equivocations |
| 6042 | + head_state = store.block_states[head_root] |
| 6043 | + head_block = store.blocks[head_root] |
| 6044 | + epoch = compute_epoch_at_slot(head_block.slot) |
| 6045 | + head_node = ForkChoiceNode(root=head_root, payload_status=PAYLOAD_STATUS_PENDING) |
| 6046 | + head_weight = get_attestation_score(store, head_node, justified_state) |
| 6047 | + for index in range(get_committee_count_per_slot(head_state, epoch)): |
| 6048 | + committee = get_beacon_committee(head_state, head_block.slot, CommitteeIndex(index)) |
| 6049 | + head_weight += Gwei( |
| 6050 | + sum( |
| 6051 | + justified_state.validators[i].effective_balance |
| 6052 | + for i in committee |
| 6053 | + if i in store.equivocating_indices |
| 6054 | + ) |
| 6055 | + ) |
| 6056 | + |
| 6057 | + return head_weight < reorg_threshold |
| 6058 | + </spec> |
| 6059 | + |
5912 | 6060 | - name: is_in_inactivity_leak#phase0 |
5913 | 6061 | sources: |
5914 | 6062 | - file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/common/helpers/BeaconStateAccessors.java |
|
6013 | 6161 | return parent_weight > parent_threshold |
6014 | 6162 | </spec> |
6015 | 6163 |
|
| 6164 | +- name: is_parent_strong#gloas |
| 6165 | + sources: [] |
| 6166 | + spec: | |
| 6167 | + <spec fn="is_parent_strong" fork="gloas" hash="37089462"> |
| 6168 | + def is_parent_strong(store: Store, root: Root) -> bool: |
| 6169 | + justified_state = store.checkpoint_states[store.justified_checkpoint] |
| 6170 | + parent_threshold = calculate_committee_fraction(justified_state, REORG_PARENT_WEIGHT_THRESHOLD) |
| 6171 | + block = store.blocks[root] |
| 6172 | + parent_payload_status = get_parent_payload_status(store, block) |
| 6173 | + parent_node = ForkChoiceNode(root=block.parent_root, payload_status=parent_payload_status) |
| 6174 | + parent_weight = get_attestation_score(store, parent_node, justified_state) |
| 6175 | + return parent_weight > parent_threshold |
| 6176 | + </spec> |
| 6177 | + |
6016 | 6178 | - name: is_partially_withdrawable_validator#capella |
6017 | 6179 | sources: |
6018 | 6180 | - file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/helpers/PredicatesElectra.java |
|
6094 | 6256 | return get_beacon_proposer_index(state) == validator_index |
6095 | 6257 | </spec> |
6096 | 6258 |
|
| 6259 | +- name: is_proposer_equivocation#phase0 |
| 6260 | + sources: [] |
| 6261 | + spec: | |
| 6262 | + <spec fn="is_proposer_equivocation" fork="phase0" hash="8e90bb33"> |
| 6263 | + def is_proposer_equivocation(store: Store, root: Root) -> bool: |
| 6264 | + block = store.blocks[root] |
| 6265 | + proposer_index = block.proposer_index |
| 6266 | + slot = block.slot |
| 6267 | + # roots from the same slot and proposer |
| 6268 | + matching_roots = [ |
| 6269 | + root |
| 6270 | + for root, block in store.blocks.items() |
| 6271 | + if (block.proposer_index == proposer_index and block.slot == slot) |
| 6272 | + ] |
| 6273 | + return len(matching_roots) > 1 |
| 6274 | + </spec> |
| 6275 | + |
6097 | 6276 | - name: is_proposing_on_time#phase0 |
6098 | 6277 | sources: |
6099 | 6278 | - file: storage/src/main/java/tech/pegasys/teku/storage/client/LateBlockReorgLogic.java |
|
6378 | 6557 | return is_valid_merkle_branch(leaf, branch[num_extra:], depth, index, root) |
6379 | 6558 | </spec> |
6380 | 6559 |
|
| 6560 | +- name: is_valid_proposal_slot#gloas |
| 6561 | + sources: [] |
| 6562 | + spec: | |
| 6563 | + <spec fn="is_valid_proposal_slot" fork="gloas" hash="55b8762f"> |
| 6564 | + def is_valid_proposal_slot(state: BeaconState, preferences: ProposerPreferences) -> bool: |
| 6565 | + """ |
| 6566 | + Check if the validator is the proposer for the given slot in the next epoch. |
| 6567 | + """ |
| 6568 | + index = SLOTS_PER_EPOCH + preferences.proposal_slot % SLOTS_PER_EPOCH |
| 6569 | + return state.proposer_lookahead[index] == preferences.validator_index |
| 6570 | + </spec> |
| 6571 | + |
6381 | 6572 | - name: is_valid_switch_to_compounding_request#electra |
6382 | 6573 | sources: |
6383 | 6574 | - file: ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/helpers/BeaconStateMutatorsElectra.java |
|
0 commit comments