Add capella to epoch precompute (#11661)

This commit is contained in:
terencechain
2022-11-14 10:05:58 -05:00
committed by GitHub
parent cf466702df
commit b5f8e69b6b
2 changed files with 5 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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) {