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

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.

4. Status

This SEP is under draft.

5. Specification

When transactions finish their execution, the returned gas fee is calculated as the following pseudo code:

gas_used = gas_limit - gas_remained
if gas_used * 4 < gas_limit then /*the estimated gas consumption is more than four times of real gas consumption*/
gas_used = gas_limit /* no gas fee will be returned*/
else if gas_used * 2 < gas_limit then /*the estimated gas consumption is more than two times of real gas consumption*/
gas_used = (gas_used + gas_limit) / 2
else then /*the estimated gas consumption is no larger than two times of real gas consumption*/
/* return the gas fee just as ethereum*/
endif
returned_gas_fee = (gas_limit - gas_used) * gas_price

6. License

The content is licensed under CC0.