diff --git a/beacon-chain/core/epoch/precompute/reward_penalty.go b/beacon-chain/core/epoch/precompute/reward_penalty.go index ac2dfa513..74064c72c 100644 --- a/beacon-chain/core/epoch/precompute/reward_penalty.go +++ b/beacon-chain/core/epoch/precompute/reward_penalty.go @@ -70,8 +70,7 @@ func AttestationsDelta(state iface.ReadOnlyBeaconState, pBal *Balance, vp []*Val } func attestationDelta(pBal *Balance, v *Validator, prevEpoch, finalizedEpoch types.Epoch) (uint64, uint64) { - eligible := v.IsActivePrevEpoch || (v.IsSlashed && !v.IsWithdrawableCurrentEpoch) - if !eligible || pBal.ActiveCurrentEpoch == 0 { + if !EligibleForRewards(v) || pBal.ActiveCurrentEpoch == 0 { return 0, 0 } @@ -177,3 +176,11 @@ func ProposersDelta(state iface.ReadOnlyBeaconState, pBal *Balance, vp []*Valida } return rewards, nil } + +// EligibleForRewards for validator. +// +// Spec code: +// if is_active_validator(v, previous_epoch) or (v.slashed and previous_epoch + 1 < v.withdrawable_epoch) +func EligibleForRewards(v *Validator) bool { + return v.IsActivePrevEpoch || (v.IsSlashed && !v.IsWithdrawableCurrentEpoch) +}