0

Assume a miner selects 10 transactions where their total gas is equivalent to the block gas limit (e.g., 6 million gas). But once the miner executed those transactions, he figured out the actual used gas by those transactions is less than the block gas limit (say e.g., 4 millions). Will the miner be able to select other transactions in order to fill the block?

In other words, whether the block gas limit is calculated based on the total gas provided by transaction or by the total used gas, since a user can send a transaction with 1 million gas, but actually their transaction can only use 500,000 gas.

I hope i made it clear!

Thanks

1 Answer 1

1

Every transaction includes a sender-specified gas limit: the maximum amount of gas the transaction's sender wants the transaction to be able to consume. The sender only pays for gas consumed. Every block also has a gas limit, set by network consensus (on average): the maximum amount of gas that can be consumed by all the transactions it contains.

The actual amount of gas consumed by a transaction can be less than the transaction gas limit. I think a miner is free to add more transactions to a block so long as the sum of consumed gas is less than or equal to the block gas limit. That means that a malicious user cannot launch a denial of service attack at low cost by sending a few transactions with a high transaction gas limit that over-reserve space in a block.

2
  • Thank you so much for your contribution! but miners are restricted by the block limit, so how they can decide on which transactions to include if they are willing to max their income, given only the max gas that can be consumed by a transaction?
    – MWH
    Jul 24, 2017 at 13:55
  • They can choose any transactions they want to include so long as the maximum spent gas is less than the block limit. It's up to the miner's node what strategy to use to maximize collected transaction fees.
    – lungj
    Jul 24, 2017 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.