From c9b884ff8c6c7032dcea3cfc312b20087cb26f15 Mon Sep 17 00:00:00 2001 From: Jonathan Downing Date: Sun, 24 Nov 2024 12:43:08 -0600 Subject: [PATCH] Properly checked Qi usedGas and don't break tx processing prematurely --- core/worker.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/core/worker.go b/core/worker.go index 1228f698c..1b28b566e 100644 --- a/core/worker.go +++ b/core/worker.go @@ -1326,15 +1326,8 @@ func (w *worker) commitTransactions(env *environment, primeTerminus *types.WorkO qiTxsToRemove = append(qiTxsToRemove, &hash) continue } - if env.gasPool.Gas() < txGas { - w.logger.WithFields(log.Fields{ - "have": env.gasPool, - "want": txGas, - }).Trace("Not enough gas for further transactions") - break - } if err := w.processQiTx(tx, env, primeTerminus, parent, firstQiTx); err != nil { - if strings.Contains(err.Error(), "emits too many") || strings.Contains(err.Error(), "double spends") || strings.Contains(err.Error(), "combine smaller denominations") { + if strings.Contains(err.Error(), "emits too many") || strings.Contains(err.Error(), "double spends") || strings.Contains(err.Error(), "combine smaller denominations") || strings.Contains(err.Error(), "uses too much gas") { // This is not an invalid tx, our block is just full of ETXs // Alternatively, a tx double spends a cached deleted UTXO, likely replaced-by-fee txs.PopNoSort() @@ -2039,9 +2032,6 @@ func (w *worker) processQiTx(tx *types.Transaction, env *environment, primeTermi if err := env.gasPool.SubGas(intrinsicGas); err != nil { return err } - if gasUsed > env.wo.GasLimit() { - return fmt.Errorf("tx %032x uses too much gas, have used %d out of %d", tx.Hash(), gasUsed, env.wo.GasLimit()) - } addresses := make(map[common.AddressBytes]struct{}) totalQitIn := big.NewInt(0) @@ -2237,6 +2227,9 @@ func (w *worker) processQiTx(tx *types.Transaction, env *environment, primeTermi txFeeInQit.Sub(txFeeInQit, txFeeInQit) // Fee goes entirely to gas to pay for conversion } } + if gasUsed > env.wo.GasLimit() { + return fmt.Errorf("tx %032x uses too much gas, have used %d out of %d", tx.Hash(), gasUsed, env.wo.GasLimit()) + } env.wo.Header().SetGasUsed(gasUsed) env.etxRLimit -= ETXRCount env.etxPLimit -= ETXPCount