mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 11:57:18 +00:00
Prevent balance goes out of bound (#4865)
* Prevent balance goes out of bound * Prevent balance goes out of bound * Merge branch 'master' into fix-balance
This commit is contained in:
parent
6b40fa01ec
commit
4a446329b2
@ -75,9 +75,9 @@ func (v *validator) LogValidatorGainsAndLosses(ctx context.Context, slot uint64)
|
|||||||
if slot < params.BeaconConfig().SlotsPerEpoch {
|
if slot < params.BeaconConfig().SlotsPerEpoch {
|
||||||
v.prevBalance[bytesutil.ToBytes48(pkey)] = params.BeaconConfig().MaxEffectiveBalance
|
v.prevBalance[bytesutil.ToBytes48(pkey)] = params.BeaconConfig().MaxEffectiveBalance
|
||||||
}
|
}
|
||||||
newBalance := float64(resp.BalancesAfterEpochTransition[i]) / float64(params.BeaconConfig().GweiPerEth)
|
|
||||||
|
|
||||||
if v.prevBalance[bytesutil.ToBytes48(pkey)] > 0 {
|
if v.prevBalance[bytesutil.ToBytes48(pkey)] > 0 && len(resp.BalancesAfterEpochTransition) > i {
|
||||||
|
newBalance := float64(resp.BalancesAfterEpochTransition[i]) / float64(params.BeaconConfig().GweiPerEth)
|
||||||
prevBalance := float64(resp.BalancesBeforeEpochTransition[i]) / float64(params.BeaconConfig().GweiPerEth)
|
prevBalance := float64(resp.BalancesBeforeEpochTransition[i]) / float64(params.BeaconConfig().GweiPerEth)
|
||||||
percentNet := (newBalance - prevBalance) / prevBalance
|
percentNet := (newBalance - prevBalance) / prevBalance
|
||||||
log.WithFields(logrus.Fields{
|
log.WithFields(logrus.Fields{
|
||||||
|
Loading…
Reference in New Issue
Block a user