The Ethereum Merge

9 minute read

Since a few years, the Ethereum Foundation and Community are working on a massive upgrade of the Ethereum protocol, that will switch Proof of Work consensus to Proof of Stake and introduce Sharding to scale the Ethereum chain.

One of the step of this upgrade is The Merge, which main goal is to switch the consensus of the chain to Proof of Stake.

The main advantages of this consensus change are:

  1. 99.5% less energy required to run the Ethereum blockchain
  2. better decentralization as all ETH holders can now participate in the consensus, as opposed to Proof of Work which is almost exclusive to users with good GPUs
  3. introduction of a total economic finality with the Casper consensus protocol. In Proof of Work Ethereum, if a new block X is mined, it is not finalized, meaning that the chain can still be reorganized without the block X. Usually we consider that a block is “finalized” on PoW after 6 blocks. With the consensus protocol used in Ethereum PoS, Casper, when a block is added to the chain (ie 23 validators agree that it should be added), the block is economically finalized, validators that disagree have penalties
  4. block time is constant and will take 12 seconds: one validator is randomly selected every slot (12s) to propose a block, whereas PoW is more like a race and the first to propose wins, this takes ~13s

Current state (pre-Merge)

Currently, a lot of work has already been made to prepare The Merge, like the deployment of the Beacon Chain to setup Ethereum validators. Since then, everyone can deposit 32 ETH to the deposit contract to stake (ie to participate to the Beacon Chain consensus).

Two chains

There are currently 2 chains running almost independently. The Ethereum chain on one-side, a Proof of Work chain that keeps track of the Ethereum network state and transactions. The Beacon chain on the other side, a Proof of Stake chain which keeps track of validators participation to the consensus, and of the 32 ETH deposits. Recently, the community celebrated a new achievement for the Beacon Chain: more than 10 million ETH are deposited and thus staked, this represents more than 300k validators!

Ethereum blocks: execution

Ethereum blocks currently contain all execution data: the current blockchain state, the executed transactions and their receipts.

Ethereum block -> An example here

In this block we can find all data related to transactions execution and their effect on the chain state (stateRoot, transactionsRoot, receiptsRoot). We can also find information about the gas consumption of the transactions in the block: gasLimit, gasUsed and baseFeePerGas. Since EIP-1559, baseFeePerGas * gasUsed is burnt by the network for each block.

The miner specifies a coinbase address, which will receive all the transaction fees and bribes associated with the block. The miner rewards are composed of:

  • 2 ETH issued by the network (inflation)
  • Tips included in the transactions of the block

Beacon Chain blocks: consensus

Beacon chain does not have an execution layer like Ethereum, it is only a consensus chain which stores the votes of the validators (attestations), and the deposits (transactions made on the Ethereum chain).

Beacon block -> An example here

In this block we can find all data related to the votes made by validators (all aggregated attestations are stored in the block: ATTEST-0, ATTEST-1…) which agree on the current state of the chain (stateRoot). The blocks also store the validators joining the consensus (by saving deposits DEPOSIT-0, DEPOSIT-1…), and those exiting the consensus (EXIT-0, EXIT-1…).

“Eth1” and “Eth2” clients

Those 2 blockchains currently run with different software clients.

For Ethereum chain (“eth1”) the main clients are Geth, Erigon, Besu, Nethermind. They manage the transactions mempool, the EVM execution and are connected with the p2p network of Ethereum nodes to share the Ethereum blocks. Ethereum clients can either run in full node mode, or in miner mode. In the latest they will compete with other miners to propose the next block of the network (Proof of Work consensus).

Ethereum client

For Beacon chain (“eth2”) the most popular are Prysm, Teku, Lighthouse, Nimbus, Lodestar. They are connected to the P2P network of Beacon nodes to share the Beacon chain blocks. They are also connected with an Ethereum node in order to fetch the deposits made on the Ethereum chain, that will then be verified to activate a validator.

Beacon client

What will change? (post-Merge)

The goal of The Merge upgrade is to unify those two chains to make Ethereum blocks validated by Proof of Stake consensus. From now on Ethereum chain (“eth1”) will be called the execution layer and the Beacon chain (“eth2”) the consensus layer.

One chain

After The Merge, only one blockchain will exist and its blocks will include the execution data and the Proof of Stake consensus data.

Merge block -> An example here

The Post-Merge Ethereum chain will manage 2 parallel states: the execution state (ETH accounts, smart contracts variables etc.), and the consensus state (active validators, deposits, validators balance etc.).

New Client Architecture

To manage those 2 different states, the chain will still be run by the 2 types of clients we saw previously: execution clients will manage execution state, whereas consensus clients will manage the consensus state.

The consensus nodes are still peered together, and the execution nodes too, but a new Engine API enables more communications between consensus and execution clients.

Merge client

Rewards

Pre-Merge, Beacon chain validators earned rewards for submitting attestations (every slot, ie every 12 seconds), voting in sync committees and proposing blocks. Post-Merge, those rewards will continue to exist and they will stay on the consensus state.

When The Merge update is complete, miners will no longer exist and transaction fees rewards and tips will be sent to the address specified as the feeRecipient (which replaces the coinbase address used in Proof of Work) in the execution data of each block. This will be set by the validator proposing the block. Note that the 2 ETH issued per block by the network on Ethereum PoW will be reduced by ~90% after the Merge.

Therefore, there will be multiple reward streams post-Merge for validators, some in the consensus state and other on the execution state. The Merge will not enable withdrawals, meaning that the 32 staked ETH used to activate a validator + their consensus rewards will still be locked on the consensus level. But stakers will enjoy new liquid rewards, that they will receive and use on the execution layer directly.

The feeRecipient will be defined in the Consensus client configuration, and passed at runtime to the Execution client which will include it in executed blocks. If you use a third party for the execution client, make sure that it will take into account your feeRecipient!

Inflation/Deflation equilibrium

The Merge will also impact the inflation of the protocol. Since EIP-1559 the baseFeePerGas * gasUsed of each transaction is burnt by the network. The more the network usage, the more the base fee, the more burned tokens. In PoW mode, Ethereum issues 2 ETH per block for miner’s reward. After The Merge this 2 ETH issuance will be reduced by ~90% (should be ~0.2 ETH) and will go to the feeRecipient address we saw earlier. Then the difference between issued tokens and burnt tokens will vary depending on the network usage:

If the network has a high congestion, the base fee will be higher for transactions and therefore more ETH will be burnt. At some point, more ETH will be burnt that ETH issued. This will make the supply deflationary.

If the network has a low congestion, the base fee will be smaller for transactions and therefore less ETH will be burnt. At some point, less ETH will be burnt that ETH issued. This will make the supply inflationary.

Roadmap

The Merge is a big step to achieve, switching a p2p network consensus without downtime is a big challenge, but it will be the first of a series of big upgrades that will enable Ethereum to scale more and more.

To the Merge..

The current checklist to achieve The Merge is here. At the time of this post, the main tasks blocking the Merge are almost all about testing (fuzzing, stress tests etc). To test The Merge in “almost real conditions”, multiple devnets were launch.

The long-lived devnets

The #TestingTheMerge community deployed some devnets to simulate The Merge and the post-merge environment on a network similar to the current Ethereum chain. Here are the 2 latest long-lived devnets they used:

Kintsugi

Launched on December 20th 2021. This network was used to simulate a post-merge environment, with consensus and execution clients communications. It worked well until one of the Geth developers released a fuzzer that aimed to produce invalid blocks to test how execution clients would react. An error happened when the fuzzer changed the blockhash to the parenthash.

Nodes should reject such a changed block. However, since the parent hash pointed to a valid block itself, some implementations did not actually execute and verify the block but looked it up in a cache instead. Since the previous block was valid and in the cache, they assumed the new block to be valid as well

This caused the network to split, with many forks in parallel. It was a great achievement for the #TestingTheMerge community because it helped clients developers to find and fix bugs (especially Geth and Teku for this split bug).

Kintsugi is now offline.

Kiln

Launched on March 14th 2022, it started with a PoW execution chain and a Beacon chain (basically the current mainnet setup), and triggered the Merge on March 15th at 3pm GMT. The Merge was successful: no downtime in transactions process, no chain split and the finalization worked straight ahead.

Kiln testnet helped identified some issues on Prysm, Nethermind and Erigon clients.

At the time of this post, it is still up and running in a post-Merge mode.

The short-lived devnets

In parallel of the tests on long-lived testnets, the #TestingTheMerge community, and especially clients core teams are also testing the Merge on many shadow forks of existing public testnets and even of mainnet. You can find the list here.

Wen?

On April 11th, Tim Beiko told the community that the Merge won’t happen in June. It is more likely that it will happen by the end of the summer.

A difficulty bomb is planned, that will increase the complexity of miners’ work to make it less and less attractive to mine. This difficulty bomb is progressive and will start in May. In a few months it will make it really hard to mine new blocks. This means that block time on Ethereum might become longer than ~13s until the Merge does not happen.

If the Merge is delayed too much, the difficulty bomb will be delayed too.

..and beyond

While a big part of Ethereum researchers are focused on The Merge, future upgrades are in progress.

Shanghai Upgrade

The Shanghai upgrade will be the next major step after the Merge on the Ethereum Roadmap. The work on this upgrade already started and will basically include 3 major changes:

  1. Beacon Chain Withdrawals (ie consensus layer rewards withdrawals). EIP-4895 will introduce withdrawals as push operations. Withdrawal Receipts will be included in Consensus blocks (like the deposits) with the withdrawal amount, the destination address and an index. Stakers will be able to make partial or full withdrawals and receive their stake and consensus rewards on the execution layer.
  2. New EVM objects, see EIP-3640
  3. Lower Layer 2 Fees, EIP-4488 will reduce the transaction calldata gas cost, and therefore the transaction cost of Ethereum Layers 2 like Optimism, Arbitrum or Zk rollups like zksync. Note that this is a short term solution as Sharding will solve this problem. But Sharding will not happen in the Shanghai upgrade. EIP-4844 will introduce Shard Blob Transactions, which is the first step toward Sharding on Ethereum.

Sources

Special thanks to the EthStaker, #TestingTheMerge and EthR&D communities for all the great content and reports they make and share. Special thanks to Ben Eddington for the amazing Eth2News, Tim Beiko and Marius VanDerWijden for their Twitter content, and Jim McDonald for his posts on the Beacon Chain and The Merge.