From 60730b782637dcbb3b2a82eab0bdf8581ac5089b Mon Sep 17 00:00:00 2001 From: Oleg Nikonychev Date: Sat, 28 Dec 2024 13:52:00 +0400 Subject: [PATCH] fix: flooring 1/64 of the gas limit --- x/evm/keeper/erc20.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x/evm/keeper/erc20.go b/x/evm/keeper/erc20.go index 216a7d23e..ef8140f92 100644 --- a/x/evm/keeper/erc20.go +++ b/x/evm/keeper/erc20.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + "math" "math/big" "cosmossdk.io/errors" @@ -30,7 +31,7 @@ const ( // protection against recursive calls ERC20 -> precompile -> ERC20. func getCallGasWithLimit(ctx sdk.Context, gasLimit uint64) uint64 { availableGas := ctx.GasMeter().GasRemaining() - callGas := (availableGas * 63) / 64 + callGas := availableGas - uint64(math.Floor(float64(availableGas)/64)) return min(callGas, gasLimit) }