During the transaction execution we are counting how much we "gas burned" and how much "gas used". Why do we have to track these counters separately?
gas_used >= gas_burnt
, always;gas_burnt
and gas_used
;X
amount of gas to this call, then X
counts towards gas_used
but not gas_burnt
. This is the only source of discrepancy between gas_used
and gas_burnt
. If the smart contract fails before it finishes the execution then none of the cross-contract calls (or transactions created by the contract) get executed and the attached gas is refunded;gas_used - gas_burnt
is getting refunded back to the account, while gas_burnt
is getting lost for good (because gas_burnt
corresponds to the fees that actually costed some computation efforts to the validators).