diff --git a/beacon-chain/core/epoch/precompute/attestation.go b/beacon-chain/core/epoch/precompute/attestation.go index 730e69b772..11f54a2089 100644 --- a/beacon-chain/core/epoch/precompute/attestation.go +++ b/beacon-chain/core/epoch/precompute/attestation.go @@ -183,7 +183,7 @@ func UpdateBalance(vp []*Validator, bBal *Balance, stateVersion int) *Balance { if stateVersion == version.Phase0 && v.IsPrevEpochAttester { bBal.PrevEpochAttested += v.CurrentEpochEffectiveBalance } - if (stateVersion == version.Altair || stateVersion == version.Bellatrix) && v.IsPrevEpochSourceAttester { + if stateVersion >= version.Altair && v.IsPrevEpochSourceAttester { bBal.PrevEpochAttested += v.CurrentEpochEffectiveBalance } if v.IsPrevEpochTargetAttester { diff --git a/beacon-chain/core/epoch/precompute/attestation_test.go b/beacon-chain/core/epoch/precompute/attestation_test.go index 05fa5e76cd..720282c331 100644 --- a/beacon-chain/core/epoch/precompute/attestation_test.go +++ b/beacon-chain/core/epoch/precompute/attestation_test.go @@ -70,7 +70,7 @@ func TestUpdateBalance(t *testing.T) { assert.DeepEqual(t, wantedPBal, pBal, "Incorrect balance calculations") } -func TestUpdateBalanceBellatrixVersion(t *testing.T) { +func TestUpdateBalanceDifferentVersions(t *testing.T) { vp := []*precompute.Validator{ {IsCurrentEpochAttester: true, CurrentEpochEffectiveBalance: 100 * params.BeaconConfig().EffectiveBalanceIncrement}, {IsCurrentEpochTargetAttester: true, IsCurrentEpochAttester: true, CurrentEpochEffectiveBalance: 100 * params.BeaconConfig().EffectiveBalanceIncrement}, @@ -92,6 +92,9 @@ func TestUpdateBalanceBellatrixVersion(t *testing.T) { } pBal := precompute.UpdateBalance(vp, &precompute.Balance{}, version.Bellatrix) assert.DeepEqual(t, wantedPBal, pBal, "Incorrect balance calculations") + + pBal = precompute.UpdateBalance(vp, &precompute.Balance{}, version.Capella) + assert.DeepEqual(t, wantedPBal, pBal, "Incorrect balance calculations") } func TestSameHead(t *testing.T) {