Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Effective Balance Calculation #8743

Merged
merged 9 commits into from Apr 13, 2021
14 changes: 9 additions & 5 deletions beacon-chain/core/epoch/epoch_processing.go
Expand Up @@ -252,12 +252,16 @@ func ProcessEffectiveBalanceUpdates(state iface.BeaconState) (iface.BeaconState,
balance := bals[idx]

if balance+downwardThreshold < val.EffectiveBalance || val.EffectiveBalance+upwardThreshold < balance {
newVal := stateV0.CopyValidator(val)
newVal.EffectiveBalance = maxEffBalance
if newVal.EffectiveBalance > balance-balance%effBalanceInc {
newVal.EffectiveBalance = balance - balance%effBalanceInc
effectiveBal := maxEffBalance
if effectiveBal > balance-balance%effBalanceInc {
effectiveBal = balance - balance%effBalanceInc
}
return true, newVal, nil
if effectiveBal != val.EffectiveBalance {
newVal := stateV0.CopyValidator(val)
newVal.EffectiveBalance = effectiveBal
return true, newVal, nil
}
return false, val, nil
}
return false, val, nil
}
Expand Down