Simplify Effective Balance Calculation (#8743)

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Nishant Das 2021-04-13 20:44:33 +08:00 committed by GitHub
parent 5f3299e598
commit 45d2df1af7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -252,12 +252,16 @@ func ProcessEffectiveBalanceUpdates(state iface.BeaconState) (iface.BeaconState,
balance := bals[idx] balance := bals[idx]
if balance+downwardThreshold < val.EffectiveBalance || val.EffectiveBalance+upwardThreshold < balance { if balance+downwardThreshold < val.EffectiveBalance || val.EffectiveBalance+upwardThreshold < balance {
newVal := stateV0.CopyValidator(val) effectiveBal := maxEffBalance
newVal.EffectiveBalance = maxEffBalance if effectiveBal > balance-balance%effBalanceInc {
if newVal.EffectiveBalance > balance-balance%effBalanceInc { effectiveBal = balance - balance%effBalanceInc
newVal.EffectiveBalance = 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 return false, val, nil
} }