From 2225c467bb032f890dcdc2de894a5679daf5dfe0 Mon Sep 17 00:00:00 2001 From: Matee Ullah Malik Date: Thu, 4 Sep 2025 16:22:50 +0500 Subject: [PATCH] Fix fee calculation to always round up --- pkg/lumera/modules/tx/impl.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/lumera/modules/tx/impl.go b/pkg/lumera/modules/tx/impl.go index 8f973b1c..37481751 100644 --- a/pkg/lumera/modules/tx/impl.go +++ b/pkg/lumera/modules/tx/impl.go @@ -3,6 +3,7 @@ package tx import ( "context" "fmt" + "math" "strconv" "github.com/LumeraProtocol/supernode/v2/pkg/logtrace" @@ -225,14 +226,14 @@ func (m *module) CalculateFee(gasAmount uint64, config *TxConfig) string { denom = DefaultFeeDenom } - feeAmount := gasPriceF * float64(gasAmount) + // Calculate fee and always round up to meet chain minimums + feeFloat := gasPriceF * float64(gasAmount) + feeInt := uint64(math.Ceil(feeFloat)) // Ensure we have at least 1 unit of fee to meet minimal requirements - if feeAmount < 1 { - feeAmount = 1 - } + feeInt = max(feeInt, 1) - return fmt.Sprintf("%.0f%s", feeAmount, denom) + return fmt.Sprintf("%d%s", feeInt, denom) } // ProcessTransaction handles the complete flow: simulate, build, sign, and broadcast