Ethereum Gas, Blocks, and the EVM Explained


Blocks
A block is a batch of transactions bundled together. Rather than processing each transaction individually, Ethereum combines dozens or hundreds of transactions into a single block. This strategy allows the network to reach agreement more efficiently. By committing these batches at regular intervals, all network participants can agree on the exact order and status of transactions. This synchronization is critical for ensuring a consistent and agreed-upon history across all nodes.
Crucially, each block includes a cryptographic hash of the previous block in the chain. This linking technique is what gives the blockchain its "chain" structure and keeps it extremely safe. If even a single bit of data in an older block was changed, the hash would change, invalidating the hash of the next block, and so on, cascading through the entire chain. This quick invalidation means that any fraudulent modifications are immediately discovered by all network participants, making the blockchain very resistant to tampering.
How Blocks work on Ethereum
Blocks on Ethereum are strictly ordered, meaning each new block explicitly references its parent block. This strict ordering also applies to transactions within a block, ensuring a precise and immutable historical record.
On Ethereum, a new block is created approximately every twelve seconds. This consistent "block time" is a key feature of Ethereum's Proof-of-Stake (PoS) consensus mechanism. The process unfolds as follows:
Validator Selection: A validator is randomly selected from the network to be the block proposer for a given "slot" (a twelve-second period). These validators must have staked 32 ETH as collateral, which can be partially or entirely destroyed if they act maliciously, protecting the network.
Block Assembly: The selected block proposer bundles pending transactions, executes them, and determines the resulting new state of the Ethereum network
Propagation: The assembled block is then propagated to the rest of the network
Verification: Other validators receive the proposed block and re-execute the transactions contained within it to verify that the proposed state changes are valid and consistent with their own understanding of the network. If valid, they add the block to their local copy of the blockchain.
Fork Choice: If a validator encounters two conflicting blocks for the same slot (a rare occurrence), they use a fork-choice algorithm to select the valid block supported by the majority of the staked ETH.
What’s inside a block?
An Ethereum block contains a wealth of information, structured into a header and a body. The header includes metadata about the block itself, while the body contains the transaction data and other system-level information.
Key fields within a block include:
Slot: The time slot the block belongs to.
Proposer Index: The ID of the validator who proposed the block.
Parent Root: The hash of the previous block, linking it to the chain.
State Root: The root hash of the network's state after all transactions in the block have been executed. This is a critical component for verifying the block's validity.
Body: This object contains various fields, including:
Execution Payload: This holds the actual list of transactions to be executed.
Attestations: Information from other validators confirming the validity of previous blocks or the current one.
Withdrawals: Details on ETH withdrawals from the staking contract.
Other Metadata: Such as
randao_reveal
(for random validator selection),graffiti
(arbitrary data), and lists of validator penalties (proposer_slashings
,attester_slashings
).
The execution_payload
itself contains detailed transaction information and ultimately determines the state_root
. All clients re-execute the transactions in this payload to ensure the state_root
matches, confirming the block's validity.
Block Time
Ethereum divides time into 12-second "slots," with the goal of proposing a new block in each slot. In contrast to previous proof-of-work systems where block durations were erratic, this produces a very constant block time.
Block Size
Blocks have an arbitrary size, with a target of 15 million gas and a maximum of 30 million gas. The total gas consumed by all transactions in a block must remain below this limit. This cap prevents blocks from growing arbitrarily huge, making it harder for less capable nodes to keep up with the network and potentially leading to centralization. Validators can adjust the gas limit through consensus.
Ethereum Virtual Machine (EVM)
The Ethereum Virtual Machine (EVM) is a decentralized, virtual computing environment that runs consistently and securely on all Ethereum nodes. It serves as the core engine that executes smart contracts and decentralized applications (dApps), ensuring that the code behaves exactly the same way everywhere in the network. Unlike traditional blockchains that function solely as distributed ledgers recording transactions, Ethereum operates as a distributed state machine. This means it maintains a global state encompassing account balances, contract storage, and machine state, which changes deterministically with each new block based on the execution of transactions processed by the EVM.
At its core, the EVM acts like a mathematical state transition function: it takes an existing valid state and a set of transactions and produces a new valid state.
This state is stored in a complex data structure called a modified Merkle Patricia Trie, which cryptographically links all accounts and their data, summarized by a single root hash on the blockchain.
Smart contracts deployed on Ethereum are translated into bytecode composed of EVM opcodes such as arithmetic operations (ADD, XOR), control flow, and blockchain-specific commands (e.g., BALANCE, BLOCKHASH). These contracts execute deterministically in the EVM, enabling decentralized logic and automated application behavior without a central intermediary.
Every operation in the EVM consumes gas, a unit measuring computational effort; this system prevents abuse, incentivizes resource efficiency, and secures the network. Gas limits and fees, paid in ether, regulate transaction execution costs.
Over the years, the EVM has evolved and is implemented in multiple programming languages (Python, C++, JavaScript, and Rust) but must maintain compatibility with the formal specification in Ethereum’s Yellowpaper to ensure consensus across nodes.
Gas
In the Ethereum network, gas is the fundamental unit measuring the computational effort required to execute operations such as transactions or running smart contracts. Because every transaction consumes computing resources, gas fees are charged to prevent spam and resource abuse, ensuring that the network stays secure and efficient.
The fee paid for the computation is referred to as gas fees, paid in ether (ETH), usually denominated in gwei, where 1 gwei equals one-billionth of an ETH (1 gwei = 10⁻⁹ ETH). This makes dealing with very small fractions of ETH more user-friendly.
How Gas fees are Calculated
The total gas fee you pay for a transaction depends on:
The amount of gas used by the transaction (how many computational steps it takes),
The base fee per unit of gas set by the network protocol,
The priority fee, or “tip,” you provide to incentivize validators to process your transaction faster.
Mathematically, the total fee is
$$Total Gas Fee=Gas Used×(Base Fee+Priority Fee)$$
Base fee is the minimum fee per gas unit established by the network. You must pay at least this amount for your transaction to be valid, while the Priority fee is an optional extra tip that encourages validators to prioritize your transaction.
Setting Gas Prices and Priority Fees
Because gas fees fluctuate with network demand, you can choose how much priority fee to include. Paying a higher tip incentivizes validators to process your transaction more quickly, while lower tips may delay processing.
The Base Fee
Each Ethereum block has a base fee, which acts as a minimum price per unit of gas needed for a transaction to be included in that block. This base fee is not set by users but is automatically calculated by the protocol based on how full previous blocks were.
The base fee adjusts depending on how much gas the previous block used compared to a target amount. If usage exceeds the target, the base fee rises (up to 12.5% per block) to discourage full blocks; if less, it decreases. This keeps fees responsive to demand while maintaining stability.
For example, if the base fee is currently 202.7 gwei and the block remains full, the next base fee increases by 12.5%:
$$202.7×1.125=228.1 gwei$$
This exponential growth quickly makes continued congestion expensive, preventing long periods of network overload. The base fee paid is burned, removing that amount of ETH from circulation.
Priority Fee (Tip)
In addition to the base fee, users can add a priority fee or tip to incentivize validators to include their transaction sooner. While transactions paying only the base fee are valid, they provide no incentive for validators to prioritize them. Offering a higher tip can speed up processing by outbidding other transactions competing for block space.
Max Fee and Refunds
When submitting a transaction, users specify a maxFeePerGas. This maximum must cover both the base fee and priority fee:
$$maxFeePerGas≥baseFee+priorityFee$$
If the actual fees are lower, the difference is refunded to the user. This protects users from overpaying if base fees drop after transaction submission.
Gas Limit and Transaction Complexity
The gas limit defines how much gas a transaction can consume. Simple ETH transfers generally require 21,000 gas units, while complex smart contract interactions need more. If the gas limit is set too low, the transaction fails and consumes no gas. If a transaction runs out of gas mid-execution, all state changes revert, but the gas spent is not refunded.
Unused gas from overestimations is returned to the sender.
Why Do Gas Fees Rise?
High gas fees happen during periods of heavy network usage. Users bid higher priority fees to get their transactions included faster amid competition. Complex smart contracts typically consume more gas, adding to the cost.
Block Size and Gas Limits
Blocks have a dynamic gas limit averaging 15 million gas but can grow up to 30 million gas based on demand. The protocol dynamically adjusts the base fee to target a stable block size, increasing fees to cool down high demand and decreasing them when demand is lower.
Subscribe to my newsletter
Read articles from Elizabeth Afolabi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
