From fd231a618aae76a47fc63a79074d561effb2942e Mon Sep 17 00:00:00 2001 From: Shane Bammel Date: Tue, 13 Dec 2022 16:59:50 -0600 Subject: [PATCH] Prevent overflow during inactivity leak --- beacon-chain/core/altair/epoch_precompute.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/beacon-chain/core/altair/epoch_precompute.go b/beacon-chain/core/altair/epoch_precompute.go index 9aff4f2f2..6f8cb3d9f 100644 --- a/beacon-chain/core/altair/epoch_precompute.go +++ b/beacon-chain/core/altair/epoch_precompute.go @@ -345,11 +345,11 @@ func attestationDelta( // Process finality delay penalty // Apply an additional penalty to validators that did not vote on the correct target or slashed if !val.IsPrevEpochTargetAttester || val.IsSlashed { - n, err := math.Mul64(effectiveBalance, val.InactivityScore) - if err != nil { - return &AttDelta{}, err - } - attDelta.InactivityPenalty = n / inactivityDenominator + // effectiveBalance * val.InactivityScore / inactivityDenominator + inactivityPenalty := new(big.Int).SetUint64(effectiveBalance) + inactivityPenalty.Mul(inactivityPenalty, new(big.Int).SetUint64(val.InactivityScore)) + inactivityPenalty.Div(inactivityPenalty, new(big.Int).SetUint64(inactivityDenominator)) + attDelta.InactivityPenalty = inactivityPenalty.Uint64() } return attDelta, nil