From dee23c656b043ddda08d415d2a8ffb643fce2c64 Mon Sep 17 00:00:00 2001 From: YuanXingqiang Date: Wed, 15 Feb 2023 09:54:37 +0800 Subject: [PATCH] Merge PR: fix predict gas used (#2948) * fix gas * update version --- Makefile | 2 +- libs/tendermint/mempool/clist_mempool.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 63a66b3f92..924e3d0e8d 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ IGNORE_CHECK_GO=false install_rocksdb_version:=$(ROCKSDB_VERSION) -Version=v1.6.7.7 +Version=v1.6.7.8 CosmosSDK=v0.39.2 Tendermint=v0.33.9 Iavl=v0.14.3 diff --git a/libs/tendermint/mempool/clist_mempool.go b/libs/tendermint/mempool/clist_mempool.go index 595064db19..2f3ccefe0d 100644 --- a/libs/tendermint/mempool/clist_mempool.go +++ b/libs/tendermint/mempool/clist_mempool.go @@ -846,7 +846,7 @@ func (mem *CListMempool) ReapMaxBytesMaxGas(maxBytes, maxGas int64) []types.Tx { // must be non-negative, it follows that this won't overflow. gasWanted := atomic.LoadInt64(&memTx.gasWanted) newTotalGas := totalGas + gasWanted - if gasWanted >= maxGas { + if maxGas > -1 && gasWanted >= maxGas { mem.logger.Error("tx gas overflow", "txHash", hex.EncodeToString(key[:]), "gasWanted", gasWanted, "isSim", memTx.isSim) } if maxGas > -1 && newTotalGas > maxGas && len(txs) > 0 { @@ -1410,13 +1410,13 @@ func (mem *CListMempool) simulationJob(memTx *mempoolTx) { } simuRes, err := mem.simulateTx(memTx.tx) if err != nil { - mem.logger.Error("simulateTx", "error", err, "txHash", memTx.tx.Hash(mem.Height())) + mem.logger.Error("simulateTx", "error", err, "txHash", hex.EncodeToString(memTx.tx.Hash(mem.Height()))) return } gas := int64(simuRes.GasUsed) * int64(cfg.DynamicConfig.GetPGUAdjustment()*100) / 100 - if gas < atomic.LoadInt64(&memTx.gasWanted) { - atomic.StoreInt64(&memTx.gasWanted, gas) - } + mem.logger.Error("simulateTx", "txHash", hex.EncodeToString(memTx.tx.Hash(mem.Height())), "gas", gas, "old gas", atomic.LoadInt64(&memTx.gasWanted)) + atomic.StoreInt64(&memTx.gasWanted, gas) + atomic.AddUint32(&memTx.isSim, 1) mem.gasCache.Add(hex.EncodeToString(memTx.realTx.TxHash()), gas) }