Skip to content

Commit

Permalink
Minor adjustments (#948)
Browse files Browse the repository at this point in the history
1. Rename `earliest_attestation` to `get_earliest_attestation` to
avoiding conflicting to variable name
2. Extract `proposer_index` out of
`process_proposer_attestation_rewards` loops
  • Loading branch information
hwwhww authored and JustinDrake committed Apr 17, 2019
1 parent 882937b commit 5871930
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions specs/core/0_beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,7 @@ def get_winning_root_and_participants(state: BeaconState, shard: Shard) -> Tuple
```

```python
def earliest_attestation(state: BeaconState, attestations: List[PendingAttestation], index: ValidatorIndex) -> PendingAttestation:
def get_earliest_attestation(state: BeaconState, attestations: List[PendingAttestation], index: ValidatorIndex) -> PendingAttestation:
return min([
a for a in attestations if index in get_attestation_participants(state, a.data, a.aggregation_bitfield)
], key=lambda a: a.inclusion_slot)
Expand Down Expand Up @@ -1827,7 +1827,7 @@ def get_justification_and_finalization_deltas(state: BeaconState) -> Tuple[List[
if index in get_unslashed_attesting_indices(state, state.previous_epoch_attestations):
rewards[index] += base_reward * total_attesting_balance // total_balance
# Inclusion speed bonus
earliest_attestation = earliest_attestation(state, state.previous_epoch_attestations, index)
earliest_attestation = get_earliest_attestation(state, state.previous_epoch_attestations, index)
inclusion_delay = earliest_attestation.inclusion_slot - earliest_attestation.data.slot
rewards[index] += base_reward * MIN_ATTESTATION_INCLUSION_DELAY // inclusion_delay
else:
Expand Down Expand Up @@ -2172,11 +2172,12 @@ Run `process_proposer_attestation_rewards(state)`.

```python
def process_proposer_attestation_rewards(state: BeaconState) -> None:
proposer_index = get_beacon_proposer_index(state)
for pending_attestations in (state.previous_epoch_attestations, state.current_epoch_attestations):
for index in get_unslashed_attesting_indices(state, pending_attestations):
if earliest_attestation(state, pending_attestations, index).inclusion_slot == state.slot:
if get_earliest_attestation(state, pending_attestations, index).inclusion_slot == state.slot:
base_reward = get_base_reward_from_total_balance(state, get_current_total_balance(state), index)
increase_balance(state, get_beacon_proposer_index(state), base_reward // PROPOSER_REWARD_QUOTIENT)
increase_balance(state, proposer_index, base_reward // PROPOSER_REWARD_QUOTIENT)
```

##### Deposits
Expand Down

0 comments on commit 5871930

Please sign in to comment.