Skip to content

Commit

Permalink
Fix attestations reward calculation inaccuracy (#12076)
Browse files Browse the repository at this point in the history
This typo (epoch vs. prevEpoch) caused little calculation differences
compared to reality (as shown by balance changes on eth2).

Unfortunate, that we didn't have some kind of type system check catch
this, as debugging took 2 days, and the name of the parameter showed
that the function wants the previous epoch and not the current one.

Maybe previous epoch and epoch shouldn't be the same type...
  • Loading branch information
errge authored Sep 24, 2024
1 parent 4549700 commit ab0cee7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions cl/beacon/handler/attestation_rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,13 @@ func (a *ApiHandler) baseReward(version clparams.StateVersion, effectiveBalance,

func (a *ApiHandler) computeAttestationsRewardsForAltair(validatorSet *solid.ValidatorSet, inactivityScores solid.Uint64ListSSZ, previousParticipation *solid.BitList, inactivityLeak bool, filterIndicies []uint64, epoch uint64) (*beaconhttp.BeaconResponse, error) {
totalActiveBalance := uint64(0)
flagsUnslashedIndiciesSet := statechange.GetUnslashedIndiciesSet(a.beaconChainCfg, epoch, validatorSet, previousParticipation)
weights := a.beaconChainCfg.ParticipationWeights()
flagsTotalBalances := make([]uint64, len(weights))

prevEpoch := uint64(0)
if epoch > 0 {
prevEpoch = epoch - 1
}
flagsUnslashedIndiciesSet := statechange.GetUnslashedIndiciesSet(a.beaconChainCfg, prevEpoch, validatorSet, previousParticipation)
weights := a.beaconChainCfg.ParticipationWeights()
flagsTotalBalances := make([]uint64, len(weights))

validatorSet.Range(func(validatorIndex int, v solid.Validator, l int) bool {
if v.Active(epoch) {
Expand Down

0 comments on commit ab0cee7

Please sign in to comment.