What is the function of Gas Limit parameter in Ethereum? Is it involved in mining or something else?

up vote 58 down vote accepted
+50

In Ethereum, gas is a measure of computational effort. To each operation, a fixed amount of gas is assigned (e.g. adding two numbers costs 3 gas, calculating a hash costs 30 gas, sending a transaction costs 21000 gas [1]).

Since computation is expensive (mind that it has to be done by every full node in the network), excessive consumption of gas needs to be discouraged. Therefore, each unit of gas must be paid for (in Ether) by the sender of the transaction that triggered the computation.

Unfortunately, it is often not easy and in general even impossible to know in advance how much gas a transaction will need eventually. Therefore, transactions have a gas limit field to specify the maximum amount of gas the sender is willing to buy. If the gas used exceeds this limit during execution, processing is stopped. The sender still has to pay for the performed computation, but they are protected from running completely out of funds.

The transaction gas limit also protects full nodes from attackers, who could, without a gas limit, make them execute effective infinity loops. If such a transaction would take longer than one block to process, it could never be included in a block, and, thus, the attacker wouldn't need to pay for it. [2]

Additionally, blocks, too, have a field called gas limit. It defines the maximum amount of gas all transactions in the whole block combined are allowed to consume. Similar to the maximum block size in Bitcoin (measured in bytes), its purpose is to keep block propagation and processing time low, thereby allowing for a sufficiently decentralized network. In contrast to Bitcoin, it is however not a constant. Instead, miners have the option to increase or decrease it every block by a certain factor. [3]

  • 1
    yellow paper was updated, now [3] refers to equations 45-47. – ronme Oct 26 '16 at 6:35

The current gas limit can be checked on the network stats page.

It's currently 3,141,592 (pi million). The gas limit per block is not fixed, though. The number of contract calls and standard transactions is limited by the gas limit, which is 1.2x of the exponential moving average. So there's only so much gas that can be expended per block, even though it can grow, of course.

Note that each call to the contract to the caller cost an amount of Ether defined by (gas sent to contract)*(price of gas as defined by caller) so sending 10 thousend transactions per block could end up quite a pricey endeavour.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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