Skip to content

Commit

Permalink
fix 'gas limit reached' bug
Browse files Browse the repository at this point in the history
  • Loading branch information
andyzhang2023 committed Sep 13, 2024
1 parent 3e46fd5 commit e4a3b21
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core/parallel_state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,14 @@ func (p *ParallelStateProcessor) confirmTxResults(result *ParallelTxResult, stat
return result
}
// we must check the gas limit before merge
if err := gp.SubGas(result.receipt.GasUsed); err != nil {
err := gp.SubGas(result.receipt.GasUsed)
defer func() {
if result.err != nil {
// some error happends, refund the gas
gp.AddGas(result.receipt.GasUsed)
}
}()
if err != nil {
log.Error("parallel: confirmTxResults() gas limit reached", "block", result.txReq.block.Number(),
"txIndex", result.txReq.txIndex, "GasUsed", result.receipt.GasUsed, "gp.Gas", gp.Gas(), "total.GasUsed", *gasUsed)
result.err = err
Expand All @@ -490,7 +497,7 @@ func (p *ParallelStateProcessor) confirmTxResults(result *ParallelTxResult, stat
// calculate the gasUsed
*gasUsed = *gasUsed + result.receipt.GasUsed
result.receipt.CumulativeGasUsed = *gasUsed
log.Info("parallel: confirmResult() gas used in tx", "block.gasLimit", result.txReq.block.GasLimit(), "block.number", result.txReq.block.Number(), "tx.index", result.txReq.txIndex, "tx.Hash", result.txReq.tx.Hash().String(), "tx.gasUsed", result.receipt.GasUsed, "tx.gas", result.txReq.tx.Gas(), "txmsg.gasLimit", result.txReq.msg.GasLimit, "totalGasUsed", *gasUsed)
log.Debug("parallel: confirmResult() gas used in tx", "block.gasLimit", result.txReq.block.GasLimit(), "block.number", result.txReq.block.Number(), "tx.index", result.txReq.txIndex, "tx.Hash", result.txReq.tx.Hash().String(), "tx.gasUsed", result.receipt.GasUsed, "tx.gas", result.txReq.tx.Gas(), "txmsg.gasLimit", result.txReq.msg.GasLimit, "totalGasUsed", *gasUsed)

var root []byte
header := result.txReq.block.Header()
Expand Down

0 comments on commit e4a3b21

Please sign in to comment.