SEP102: Adjustment of Used Gas
1. Summary
This SEP proposes an algorithm to adjust the used gas considering the real used gas and user-specified gas limit.
2. Abstract
In ethereum, at the beginning of a transaction, all the gas fee (gas_limit * gas_price
) is deducted from the sender's balance. When it is finished, some gas fee (gas_remained * gas_price
) is returned to the sender. So the sender effectively pays gas_used * gas_price
to the network, where gas_used = gas_limit - gas_remained
.
Here we propose a different way to calculate the returned fee, which also means chances to the fee that the sender effectively pays.
3. Motivation
Unlike go-ethereum, smartBCH's validator just packs all the transactions into block and propose it. The transactions are not executed before the block is proposed. Thus we can do the tx-reordering and parallel execution: the exact tx ordering is not decided until every node gets the transactions. So when a validator proposes a block, it does not know the exact gas consumption of the transactions. But we do need to set a block level gas consumption upper bound, such that a block does not takes too long to execute.
So, in smartBCH, the block's total gas limit is the threshold of the sum of all the transactions' gas limit, which is different from ethereum, where it is the sum of all the transactions' real used gas. Since the senders can specify a very high gas limit for the transactions which only use a small amount of gas, a block may only contain a small number of transactions with high gas limit, which stops the other transactions get packed into block.
So we must encourage users to estimated their transactions' gas consumptions more accurately and make sure the transaction's gas limit is close to the gas it really consumes. If your gas limit is not a good estimation of the actual gas consumption, there will be some penalty.
4. Status
This SEP has been implemented since genesis.
5. Specification
When transactions finish their execution, the returned gas fee is calculated as the following pseudo code:
6. License
The content is licensed under CC0.
Last updated