Fix incorrect ideal rewards calculation (#4520)

## Issue Addressed

The PR fixes a bug where the the ideal rewards for source and head were incorrectly set.

Output from testing a validator that performed optimally in a Phase 0 epoch , note the `source` and `target` under ideal rewards is incorrect (compared to the actual `total_rewards` below):

```json
{ 
   "ideal_rewards": [
    ...
      {
        "effective_balance": "32000000000",
        "head": "18771",
        "target": "18770",
        "source": "18729",
        "inclusion_delay": "17083",
        "inactivity": "0"
      }
    ],
    "total_rewards": [
      {
        "validator_index": "0",
        "head": "18729",
        "target": "18770",
        "source": "18771",
        "inclusion_delay": "17083",
        "inactivity": "0"
      }
    ]
```
This commit is contained in:
Jimmy Chen 2023-07-31 01:53:06 +00:00
parent b96cfcaaa4
commit b5337c0ea5

View File

@ -330,7 +330,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// compute ideal head rewards
let head = get_attestation_component_delta(
true,
total_balances.previous_epoch_attesters(),
total_balances.previous_epoch_head_attesters(),
total_balances,
base_reward,
finality_delay,
@ -352,7 +352,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// compute ideal source rewards
let source = get_attestation_component_delta(
true,
total_balances.previous_epoch_head_attesters(),
total_balances.previous_epoch_attesters(),
total_balances,
base_reward,
finality_delay,