Skip to content

Commit

Permalink
Properly checked Qi usedGas and don't break tx processing prematurely
Browse files Browse the repository at this point in the history
  • Loading branch information
jdowning100 committed Nov 25, 2024
1 parent 131c391 commit c9b884f
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions core/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c9b884f

Please sign in to comment.