What does gas limit mean? Are there two meanings of gas limit?
- gas limit in a transaction
- block gas limit
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.Sign up to join this community
Yes. Each transaction has a gas limit. For example, there could be 5 unmined transactions where each has a gas limit of 10, 20, 30, 40, 50. The block gas limit determines how many transactions can fit in a block. For example, if the block gas limit is 100, then the first four transactions can fit in the block. Miners decide which transactions to include in a block. A different miner could try including the last 2 transactions in the block (50+40), and they only have space to include the first transaction (10).
Every person who creates a transaction can decide what their transaction's gas limit is: but it would not make sense for them to specify something higher than the block gas limit, so Geth and other clients would prevent them from setting too high. It is a gas limit because it is the maximum amount of gas the person creating the transaction is willing to use: they do not pay for any extra gas that is not used. But if they set the limit too low, their transaction can run out of gas and they pay for all of it to the miner.
With the block gas limit, miners are the ones who decide. The bigger it is the more they can get from transaction fees, but the more bandwidth and computing they would have to do. Miners cannot change the block gas limit too much within one block: they can only change it by a factor of 1/1024.
The transaction gas limit is the
gas property in a
transactionObject. The block gas limit is a parameter in the genesis file created (it is client dependent and typically means the minimum block gas limit: a block with a gas limit smaller than it will not be accepted by the nodes on that blockchain).