Skip to content

Commit

Permalink
Merge PR: fix predict gas used (#2948)
Browse files Browse the repository at this point in the history
* fix gas

* update version
  • Loading branch information
yann-sjtu authored Feb 15, 2023
1 parent 9a1c01f commit dee23c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions libs/tendermint/mempool/clist_mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit dee23c6

Please sign in to comment.