Modify incentives to preserve invariant

This commit is contained in:
Barnabé Monnot 2021-03-26 12:18:51 +08:00
parent 5e83e60a59
commit 59134fb0ae
2 changed files with 11 additions and 11 deletions

View File

@ -84,11 +84,12 @@ Altair is the first beacon chain hard fork. Its main features are:
| Name | Value |
| - | - |
| `TIMELY_HEAD_WEIGHT` | `12` |
| `TIMELY_SOURCE_WEIGHT` | `12` |
| `TIMELY_TARGET_WEIGHT` | `24` |
| `SYNC_REWARD_WEIGHT` | `8` |
| `WEIGHT_DENOMINATOR` | `64` |
| `TIMELY_HEAD_WEIGHT` | `3` |
| `TIMELY_SOURCE_WEIGHT` | `3` |
| `TIMELY_TARGET_WEIGHT` | `6` |
| `SYNC_REWARD_WEIGHT` | `2` |
| `NON_PROPOSER_TOTAL` | `14` |
| `WEIGHT_DENOMINATOR` | `16` |
*Note*: The sum of the weight fractions (7/8) plus the proposer inclusion fraction (1/8) equals 1.
@ -477,7 +478,7 @@ def process_attestation(state: BeaconState, attestation: Attestation) -> None:
proposer_reward_numerator += get_base_reward(state, index) * weight
# Reward proposer
proposer_reward = Gwei(proposer_reward_numerator // (WEIGHT_DENOMINATOR * PROPOSER_REWARD_QUOTIENT))
proposer_reward = Gwei(proposer_reward_numerator // (NON_PROPOSER_TOTAL * PROPOSER_REWARD_QUOTIENT))
increase_balance(state, get_beacon_proposer_index(state), proposer_reward)
```
@ -550,9 +551,9 @@ def process_sync_committee(state: BeaconState, aggregate: SyncAggregate) -> None
for included_index in included_indices:
effective_balance = state.validators[included_index].effective_balance
inclusion_reward = Gwei(max_slot_rewards * effective_balance // committee_effective_balance)
proposer_reward = Gwei(inclusion_reward // PROPOSER_REWARD_QUOTIENT)
proposer_reward = Gwei((inclusion_reward * WEIGHT_DENOMINATOR) // (NON_PROPOSER_TOTAL * PROPOSER_REWARD_QUOTIENT))
increase_balance(state, get_beacon_proposer_index(state), proposer_reward)
increase_balance(state, included_index, inclusion_reward - proposer_reward)
increase_balance(state, included_index, inclusion_reward)
```
### Epoch processing

View File

@ -126,8 +126,7 @@ def compute_sync_committee_participant_reward(spec, state, participant_index, co
inclusion_reward = compute_sync_committee_inclusion_reward(
spec, state, participant_index, committee, committee_bits,
)
proposer_reward = spec.Gwei(inclusion_reward // spec.PROPOSER_REWARD_QUOTIENT)
return spec.Gwei((inclusion_reward - proposer_reward) * multiplicities[participant_index])
return spec.Gwei(inclusion_reward * multiplicities[participant_index])
def compute_sync_committee_proposer_reward(spec, state, committee, committee_bits):
@ -138,7 +137,7 @@ def compute_sync_committee_proposer_reward(spec, state, committee, committee_bit
inclusion_reward = compute_sync_committee_inclusion_reward(
spec, state, index, committee, committee_bits,
)
proposer_reward += spec.Gwei(inclusion_reward // spec.PROPOSER_REWARD_QUOTIENT)
proposer_reward += spec.Gwei((inclusion_reward * spec.WEIGHT_DENOMINATOR) // (spec.NON_PROPOSER_TOTAL * spec.PROPOSER_REWARD_QUOTIENT))
return proposer_reward