mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-26 01:05:15 +00:00
move proposer negation to inactivity_penalty deltas
This commit is contained in:
parent
85e78223dd
commit
95c3295eeb
@ -1355,6 +1355,12 @@ def get_base_reward(state: BeaconState, index: ValidatorIndex) -> Gwei:
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
```python
|
||||||
|
def get_proposer_reward(state: BeaconState, attesting_index: ValidatorIndex) -> Gwei:
|
||||||
|
return Gwei(get_base_reward(state, attesting_index) // PROPOSER_REWARD_QUOTIENT)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def get_finality_delay(state: BeaconState) -> uint64:
|
def get_finality_delay(state: BeaconState) -> uint64:
|
||||||
return get_previous_epoch(state) - state.finalized_checkpoint.epoch
|
return get_previous_epoch(state) - state.finalized_checkpoint.epoch
|
||||||
@ -1392,6 +1398,7 @@ def get_attestation_component_deltas(state: BeaconState,
|
|||||||
if index in unslashed_attesting_indices:
|
if index in unslashed_attesting_indices:
|
||||||
increment = EFFECTIVE_BALANCE_INCREMENT # Factored out from balance totals to avoid uint64 overflow
|
increment = EFFECTIVE_BALANCE_INCREMENT # Factored out from balance totals to avoid uint64 overflow
|
||||||
if in_inactivity_leak(state):
|
if in_inactivity_leak(state):
|
||||||
|
# Full base reward will be cancelled out by inactivity penalty deltas
|
||||||
rewards[index] += get_base_reward(state, index)
|
rewards[index] += get_base_reward(state, index)
|
||||||
else:
|
else:
|
||||||
reward_numerator = get_base_reward(state, index) * (attesting_balance // increment)
|
reward_numerator = get_base_reward(state, index) * (attesting_balance // increment)
|
||||||
@ -1442,12 +1449,8 @@ def get_inclusion_delay_deltas(state: BeaconState) -> Tuple[Sequence[Gwei], Sequ
|
|||||||
a for a in matching_source_attestations
|
a for a in matching_source_attestations
|
||||||
if index in get_attesting_indices(state, a.data, a.aggregation_bits)
|
if index in get_attesting_indices(state, a.data, a.aggregation_bits)
|
||||||
], key=lambda a: a.inclusion_delay)
|
], key=lambda a: a.inclusion_delay)
|
||||||
proposer_reward = Gwei(get_base_reward(state, index) // PROPOSER_REWARD_QUOTIENT)
|
rewards[attestation.proposer_index] += get_proposer_reward(state, index)
|
||||||
rewards[attestation.proposer_index] += proposer_reward
|
max_attester_reward = get_base_reward(state, index) - get_proposer_reward(state, index)
|
||||||
if in_inactivity_leak(state):
|
|
||||||
max_attester_reward = get_base_reward(state, index)
|
|
||||||
else:
|
|
||||||
max_attester_reward = get_base_reward(state, index) - proposer_reward
|
|
||||||
rewards[index] += Gwei(max_attester_reward // attestation.inclusion_delay)
|
rewards[index] += Gwei(max_attester_reward // attestation.inclusion_delay)
|
||||||
|
|
||||||
# No penalties associated with inclusion delay
|
# No penalties associated with inclusion delay
|
||||||
@ -1465,7 +1468,9 @@ def get_inactivity_penalty_deltas(state: BeaconState) -> Tuple[Sequence[Gwei], S
|
|||||||
matching_target_attestations = get_matching_target_attestations(state, get_previous_epoch(state))
|
matching_target_attestations = get_matching_target_attestations(state, get_previous_epoch(state))
|
||||||
matching_target_attesting_indices = get_unslashed_attesting_indices(state, matching_target_attestations)
|
matching_target_attesting_indices = get_unslashed_attesting_indices(state, matching_target_attestations)
|
||||||
for index in get_eligible_validator_indices(state):
|
for index in get_eligible_validator_indices(state):
|
||||||
penalties[index] += Gwei(BASE_REWARDS_PER_EPOCH * get_base_reward(state, index))
|
# If validator is performing optimally this cancels all rewards for a neutral balance
|
||||||
|
base_reward = get_base_reward(state, index)
|
||||||
|
penalties[index] += Gwei(BASE_REWARDS_PER_EPOCH * base_reward - get_proposer_reward(state, index))
|
||||||
if index not in matching_target_attesting_indices:
|
if index not in matching_target_attesting_indices:
|
||||||
effective_balance = state.validators[index].effective_balance
|
effective_balance = state.validators[index].effective_balance
|
||||||
penalties[index] += Gwei(effective_balance * get_finality_delay(state) // INACTIVITY_PENALTY_QUOTIENT)
|
penalties[index] += Gwei(effective_balance * get_finality_delay(state) // INACTIVITY_PENALTY_QUOTIENT)
|
||||||
|
@ -160,7 +160,8 @@ def run_get_inactivity_penalty_deltas(spec, state):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if finality_delay > spec.MIN_EPOCHS_TO_INACTIVITY_PENALTY:
|
if finality_delay > spec.MIN_EPOCHS_TO_INACTIVITY_PENALTY:
|
||||||
base_penalty = spec.BASE_REWARDS_PER_EPOCH * spec.get_base_reward(state, index)
|
base_reward = spec.get_base_reward(state, index)
|
||||||
|
base_penalty = spec.BASE_REWARDS_PER_EPOCH * base_reward - spec.get_proposer_reward(state, index)
|
||||||
if not has_enough_for_reward(spec, state, index):
|
if not has_enough_for_reward(spec, state, index):
|
||||||
assert penalties[index] == 0
|
assert penalties[index] == 0
|
||||||
elif index in matching_attesting_indices:
|
elif index in matching_attesting_indices:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user