From ef9d965615e0ffab34b58278b864323e5342801d Mon Sep 17 00:00:00 2001 From: wuuuk <76259280+wuuuk@users.noreply.github.com> Date: Wed, 12 Feb 2025 16:31:22 +0800 Subject: [PATCH] fix: gas budget overflow when storage rebate is more than compute cost --- gmsui/transactions/internal.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gmsui/transactions/internal.go b/gmsui/transactions/internal.go index 99607cb..50398a1 100644 --- a/gmsui/transactions/internal.go +++ b/gmsui/transactions/internal.go @@ -76,12 +76,16 @@ func setGasBudget(txb *Transaction) error { return fmt.Errorf("failed to parse storage rebate, err: %v", err) } - gasBudget := baseComputationCostWithOverhead + storageCost - storageRebate - - if gasBudget > baseComputationCostWithOverhead { - txb.GasConfig.Budget = gasBudget - } else { + cost := baseComputationCostWithOverhead + storageCost + if storageRebate > cost { txb.GasConfig.Budget = baseComputationCostWithOverhead + } else { + gasBudget := baseComputationCostWithOverhead + storageCost - storageRebate + if gasBudget > baseComputationCostWithOverhead { + txb.GasConfig.Budget = gasBudget + } else { + txb.GasConfig.Budget = baseComputationCostWithOverhead + } } }