Skip to content

Commit

Permalink
Use gas used to subtract from the gas pool
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Rodygin committed Nov 22, 2023
1 parent abeb597 commit 84c6991
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions miner/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,22 @@ loop:
}
}

err = b.multiGasPool.PoolFor(tx.FeeCurrency()).SubGas(tx.Gas())
if len(b.receipts) == 0 {
// this shouldn't happen as if there was no error on commitTransaction
// a new receipt gets added
log.Warn("Unexpectedly empty receipts list")
return fmt.Errorf("No new receipts added for tx %s", tx.Hash())
}

receipt := b.receipts[len(b.receipts)-1]

err = b.multiGasPool.PoolFor(tx.FeeCurrency()).SubGas(receipt.GasUsed)
// Should never happen as we check it above
if err != nil {
log.Warn(
"Unexpectedly reached limit for fee currency",
"hash", tx.Hash(), "gas", b.multiGasPool.PoolFor(tx.FeeCurrency()).Gas(),
"txgas", tx.Gas(),
"tx gas used", receipt.GasUsed,
)
return err
}
Expand Down

0 comments on commit 84c6991

Please sign in to comment.