From 925e81b05eb91f6bb6f8edf7e192023d7d37145e Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 2 Jan 2024 16:12:14 -0500 Subject: [PATCH] fix: avoid int64() usage b/c it may overflow --- app/posthandler/refund_gas_remaining.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/posthandler/refund_gas_remaining.go b/app/posthandler/refund_gas_remaining.go index d7300e3f50..fd82d57bea 100644 --- a/app/posthandler/refund_gas_remaining.go +++ b/app/posthandler/refund_gas_remaining.go @@ -123,7 +123,7 @@ func (d RefundGasRemainingDecorator) processRefund(ctx sdk.Context, refund sdk.C // getRefund returns the coins that should be refunded to the recipient. func getRefund(gasMeter sdk.GasMeter, feeTx sdk.FeeTx) sdk.Coins { gasPrice := getGasPrice(feeTx) - toRefund := gasPrice.Amount.MulInt64(int64(gasMeter.GasRemaining())).TruncateInt() + toRefund := gasPrice.Amount.MulInt(sdk.NewIntFromUint64(gasMeter.GasRemaining())).TruncateInt() maxToRefund := MaxPortionOfFeeToRefund.MulInt(feeTx.GetFee().AmountOf(appconsts.BondDenom)).TruncateInt() amountToRefund := minimum(toRefund, maxToRefund) return sdk.NewCoins(sdk.NewCoin(appconsts.BondDenom, amountToRefund))