RareSkills Solidity Interview Question #21 Answered: As of the Shanghai upgrade, what is the gas limit per block?
This series will provide answers to the list of Solidity interview questions that were published by RareSkills..
Question #21 (Easy): As of the Shanghai upgrade, what is the gas limit per block?
Answer: As of the Shanghai upgrade, the gas limit per block is 30 million. This means that the total amount of gas spent on all transactions in a block must be less than 30 million. This is how the number of transactions per block is limited.
Demonstration:
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
contract GasLimitExample {
uint256 public counter = 0;
/**
* This function's gas usage could hit the block limit of 30 million gas,
* if it is called with a high enough "_count" and enough gas is provided
* for execution.
*/
function loopIncrement(uint256 _count) public {
for (uint256 i = 0; i < _count; i++) {
counter += 1;
}
}
}
Further Discussion:
Although the gas limit per block is 30 million, the gas target per block is 15 million.
Connect with me:
- Github: https://github.com/FaybianB
- LinkedIn: https://www.linkedin.com/in/faybianbyrd/
Previous articles:
- Question 11 (Easy): Why shouldn’t tx.origin be used for authentication?
- Question #12 (Easy): What hash function does Ethereum primarily use?
- Question #13 (Easy): How much is 1 gwei of Ether?
- Question #14 (Easy): How much is 1 wei of Ether?
- Question #15 (Easy): What is the difference between assert and require?
- Question #16 (Easy): What is a flash loan?
- Question #17 (Easy): What is the check-effects pattern?
- Question #18 (Easy): What is the minimum amount of Ether required to run a solo staking node?
- Question #19 (Easy): What is the difference between fallback and receive?
- Question #20 (Easy): What is reentrancy?
Disclosure: Some content may have been generated with the help of artificial intelligence.