Skip to content

Commit

Permalink
Simplify Effective Balance Calculation (#8743)
Browse files Browse the repository at this point in the history
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
  • Loading branch information
nisdas and prylabs-bulldozer[bot] committed Apr 13, 2021
1 parent 5f3299e commit 45d2df1
Showing 1 changed file with 9 additions and 5 deletions.
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

0 comments on commit 45d2df1

Please sign in to comment.