# on experiencing the merge

By [bt3gl's symposium](https://paragraph.com/@go-outside) · 2022-09-26

---

tl; dr
------

today i go over the ethereum merge, taking place at block **15,537,393**, with the main purpose of transiting the blockchain from proof-of-work to proof-of-stake.

the event was perhaps one of the most important checkpoints in the story of blockchain technology, but most of all, _a nerd ecstatic moment_ 😎.

* * *

🎶 today’s mood
---------------

[https://open.spotify.com/track/7ztFsRXXKrkUjMaLn1siHJ?si=266af943170642db](https://open.spotify.com/track/7ztFsRXXKrkUjMaLn1siHJ?si=266af943170642db)

* * *

PART I: THE MOTIVATION
----------------------

🧱⛓ Consensus mechanisms
------------------------

Consensus mechanisms define how a peer-to-peer network decides on its current status and on which blocks are to be added to the chain (and their order).

Block production is a general term that describes the act of scanning the _mempool_ to pick up pending transitions (txs), ordering these transactions into blocks, and attaching this new block to the chain.

> 🔮 _The mempool (a contraction of memory and pool) is the node’s mechanism for storing information on unconfirmed txs. It acts as a sort of waiting room for txs that have not yet been included in a block._

[In a PoW model,](https://ethereum.org/en/developers/docs/consensus-mechanisms/pow/#top) the network is secured by miners and their expensive mining hardware and electricity bills. The work is done in exchange for a portion of transaction fees for block issuance.

[In the PoS model,](https://ethereum.org/en/developers/docs/consensus-mechanisms/pos/#top) the network is secured by validators who have staked 32 ETH in order to validate the network (think as a collateral against bad behavior). Moving to PoS makes Ethereum much more energy efficient: the power consumption is projected to be [around 99.95% (making Ethereum ESG compliant)](https://ethereum.org/en/upgrades/merge/#merge-and-energy).

After the Merge, a [validator](https://ethereum.org/en/developers/docs/consensus-mechanisms/pos/#validators) is randomly selected in every slot (spaced 12 seconds apart) to be the block proposer. The validator bundles transactions together, execute them, and determine a new 'state' in the chain (passing it around to other validators). In this context, a finalized block is one that has been accepted as canonical by more than 2/3 of the validators.

🦇🔊 ETH issuance
-----------------

Another motivation for the Merge is the reduction of [ETH issuance](https://ethereum.org/en/upgrades/merge/issuance/#how-the-merge-impacts-ETH-supply).

The _issuance_ of ETH is the process of _creating_ ETH, and the _burning_ of ETH (from transaction fees) is the process of removing existing ETH from circulation (_destroying_).

The rate of issuance and burning gets calculated on several parameters, and the balance between them determines ETH's resulting inflation or deflation rate.

[EIP 1559](https://notes.ethereum.org/@vbuterin/eip-1559-faq) introduced the `BASEFEE` burning mechanism last August ([shipped by the London hardfork](https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/london.md)), so the bulk of Ethereum transaction fees already has been burned for a few months. The remaining fees that are not burned (called "tips" or "priority fees") are now to be paid to the block proposer.

Ethereum's issuance will be **_deflationary_** during periods of high user activity. According to [ultrasound.money](https://ultrasound.money/), at the time of this post, 2.3k ETH has been burned to the date, and the total ETH supply is 120M, with 14M ETH skated.

> 🔮 _The “Triple Halvening” is a term borrowed from Bitcoin to denominate the drop in ETH issuance after The Merge. While Bitcoin halves its issuance rate every 4 years, Ethereum will see its issuance rate reduced by roughly 90% at the Merge._

* * *

PART II: THE COMPONENTS
-----------------------

Since the Ethereum blockchain holds hundreds of billions of dollars of economic activity, instead of transitioning the chain to PoS in one large change, the Ethereum developers decided to first create a separate PoS blockchain, the _Beacon Chain_, in December 2020.

The Merge was the process of moving this chain, which has been running in parallel, to the EVM state of the Ethereum PoW chain. In this transition, the chain’s _execution_ and _consensus_ layers unbundle and run separately.

After the Merge, all applications running on Ethereum now run exactly as pre-Merge, with the state and transaction history maintained.

📡✨ The Beacon Chain
--------------------

The Beacon Chain was created to ensure the PoS consensus logic was sound before enabling it on Ethereum, and also to aggregate enough validators ([~400k by the time of the Merge](https://beaconscan.com/validators#active)).

The Beacon Chain was a ledger of accounts that conducted and coordinated the network of Ethereum, without really processing Mainnet transactions or handling smart contract interactions. Instead, the chain was reaching a consensus on its own state by agreeing on active validators and their account balances.

🌑🚜 Shadow forks and testnets
------------------------------

As one can expect, this transition has been through multiple rounds of tests that included merging _shadow forks_ and testnets.

A shadow fork is a devnet created by forking a live network with a small number of nodes, keeping the chain’s state & history (and, therefore, able to replay transactions from the main network).

In the context of the Merge, shadow forks allowed developers to test how the upgrade would happen, but without the vast majority of the nodes being aware.

In addition, the Ethereum public testnets went to the Merge process and persisted as PoS networks, helping developers to test their applications. However, shadow forks provided a more realistic testing environment, as existing testnets already had transactions happening on them.

🪖🏁 Terminal total difficulty (TTD)
------------------------------------

The trigger for the Merge switch was determined by a new variable, `TERMINAL_TOTAL_DIFFICULTY`, which represents the sum of the PoW difficulties of every block accumulated on the Ethereum PoW network (the sum of the `Ethash` mining difficulty for all blocks). The Merge would happen when [TTD reached 58750000000000000000000](https://bordel.wtf/).

> 🔮 _The_ [_Ethash algorithm_](https://ethereum.org/en/developers/docs/consensus-mechanisms/pow/mining-algorithms/ethash/) _is used to dynamically adjust the mining difficulty of the blockchain that implements it._

When the chain accumulated enough PoW to exceed the total difficulty, nodes switched to following the PoS chain. It was the first time an Ethereum upgrade was triggered by this variable, as opposed to the _block height_. The reasoning was to avoid an attacker mining malicious forks that would satisfy the block height requirement at the time of the Merge.

⛲️⚡️ The execution layer
------------------------

Before the transition to PoS, to validate the Ethereum network, node operators run one of the client implementations:

*   [geth](https://geth.ethereum.org/)
    
*   [erigon](https://github.com/ledgerwatch/erigon)
    
*   [nethermind](https://nethermind.io/)
    
*   [besu](https://besu.hyperledger.org/en/stable/)
    
*   [akula](https://akula.app/)
    

Before the Merge, these clients bundled the execution layer (EVM) and the consensus layer (PoW).

After the Merge, they transited to being strictly execution layer clients, working with the consensus layer clients to form a full Ethereum node.

Communication between the execution and consensus layers is now facilitated by the [Engine API](https://github.com/ethereum/execution-apis/blob/main/src/engine/specification.md). This requires authentication using a [JWT secret](https://jwt.io/introduction), which is provided to both clients.

🗳⚡️ The consensus layer
------------------------

The Beacon chain was launched by decoupling the consensus layer from the execution client. In PoS, the validity of transactions contained within an execution payload depends on the validity of the "consensus block" it is contained within.

> 🔮 `LMD-GHOST` is an acronym for "Latest Message Driven Greediest Heaviest Observed SubTree" and the [fork-choice algorithm](https://ethereum.org/en/glossary/#fork-choice-algorithm) used by Ethereum's consensus clients to identify the head of the chain (the head of the chain is the block with the greatest accumulation of [attestations](https://ethereum.org/en/developers/docs/consensus-mechanisms/pos/attestations/#:~:text=The%20attestation%20is%20for%20a,as%20source%20and%20target%20checkpoints\).) in its history).

Some popular consensus clients are:

*   [prysm](https://github.com/prysmaticlabs/prysm)
    
*   [lighthouse](https://github.com/sigp/lighthouse)
    
*   [teku](https://github.com/ConsenSys/teku)
    
*   [nimbus](https://nimbus.team/)
    
*   [lodestar](https://lodestar.chainsafe.io/)
    

With multiple client implementations on both layers, there are several different combinations of execution and consensus clients. [Here is a dashboard on the client statistics in the Ethereum blockchain](https://ethernodes.org/).

> 🔮 _Having multiple client implementations allows for quickly switching to different clients in case a bug or vulnerability is found, ensuring a better resilience of the network._ [_Here is a dashboard conveying data on Ethereum client diversity._](https://clientdiversity.org/)

* * *

PART III: THE MERGE
-------------------

🪢⚙️ Node operators
-------------------

The changes for non-validating Ethereum node operators were the requirement to run clients for both the execution layer and the consensus layer.

Stakers running their own node setup or infrastructure had to make sure:

1.  both a consensus client and an execution client are running
    
2.  both clients are authenticated with a shared JWT secret
    
3.  a fee recipient address was set (to receive earned transaction fee tips/MEV)
    

> 🔮 _If you are interested in running your own Ethereum mainnet or testnet node, check my comprehensive notes_ [_here_](https://github.com/bt3gl-labs/1337_mev_toolkit/tree/main/nodes)_._

🐼💾 The moment of the Merge
----------------------------

![our terminals during the merge 💚](https://storage.googleapis.com/papyrus_images/c989be11eb89a41081253e74a72a727f448d0e9fba90f780e8b4601877e6cbc9.png)

our terminals during the merge 💚

At the moment of the Merge, execution clients started listening to blocks coming from the PoS chain.

![https://twitter.com/lvanseters/status/1570303438705295362](https://storage.googleapis.com/papyrus_images/e4c0255a9788ada26eb606b4986f46e8ee65ec8aa573296fd96dfa3d0ee61b98.png)

https://twitter.com/lvanseters/status/1570303438705295362

Once PoS took over from PoW, execution engines stopped gossiping blocks. This meant deprecating the `NewBlockHashes` and `NewBlock` handlers at the peer-to-peer layer.

![https://twitter.com/gakonst/status/1570303163680583680](https://storage.googleapis.com/papyrus_images/af2cbc8d8eb5bab4c86f4827a8dbe075b0dc469d7db4f6810d043d7b26e2b396.png)

https://twitter.com/gakonst/status/1570303163680583680

The execution layer was still in charge of syncing the network state, gossiping transactions, handling transaction fees, and maintaining its transaction pool.

![https://twitter.com/CirrusNFT/status/1570308547107516418](https://storage.googleapis.com/papyrus_images/7ebd232fa970a6bf3616d5fd97c63005d5c47410935a66f3825de45f1acbf30f.png)

https://twitter.com/CirrusNFT/status/1570308547107516418

😎🧮 The new kids in the block
------------------------------

Since the Merge came with changes to consensus, this included changes related to block structure, slot/block timing, opcode changes, sources of on-chain randomness, and the concept of _safe head_ and _finalized blocks._

The `ExecutionPayloads` is the post-merge equivalent of blocks in the PoW chain, and the execution engine ensures that all transaction senders can pay at least the current `baseFeePerGas` and that any extra fees are sent to `feeReceipient` (a "legacy" Ethereum address).

Anything related to mining (`difficulty`, `mixHash`, `nonce`) or ommers (`ommers`, `ommersHash`) had to be changed. Several block fields were set to 0 (or their data structure's equivalent). The length of `extraData` was also capped to 32 bytes on mainnet.

This is a high-level overview of how blocks are processed after the Merge:

1.  a validator is chosen to propose a block
    
2.  this validator asks its execution layer, via the Engine API, to send them an `ExecutionPayload`
    
3.  the execution layer returns a payload that contains the most profitable set of valid transactions
    
4.  the consensus layer proposes a block including this payload and propagates it on the chain
    

⏰🥓 Block time and variance
---------------------------

While the block time on PoW averages around 13 seconds, on PoS the time is divided into fixed-duration slots of 12 seconds (however, some slots can miss a block making the average block time higher than 12 seconds but still lower than 13 seconds).

![https://twitter.com/natemaddrey/status/1570856077788585984](https://storage.googleapis.com/papyrus_images/8589f72e2b7c64612dfbb1723cecd26c6543eedcba1243c2e168a4f2272bc164.png)

https://twitter.com/natemaddrey/status/1570856077788585984

The merge also reduced the block time variance, and on average, we can expect faster transaction confirmations.

* * *

tl; dr: what’s next
-------------------

*   The Shanghai update, predicted for 2023, will introduce [EIP-3540](https://eips.ethereum.org/EIPS/eip-3540) (also known as the EVM object format) and enable withdrawals.
    
*   **The Surge is a** massive scalability increase for rollups through [sharding](https://ethereum.org/en/upgrades/sharding/), planned for 2023. The main innovation of [Danksharding](https://notes.ethereum.org/@vbuterin/proto_danksharding_faq) is a merged fee market. Instead of a fixed number of shards with different blocks and proposers, one randomly-chosen proposer picks all transactions and data for each slot.
    
*   **The Verge** will be implementing [Verkle trees](https://vitalik.ca/general/2021/06/18/verkle.html) (which are much more efficient in proof size) and stateless clients.
    
*   **The Purge** will be eliminating historical data (hence, reducing the amount of data needed to be stored by a validator).
    
*   **The Splurge** will be looking at consensus & MEV. Ethereum will implement [Proposal-Builder Separation](https://notes.ethereum.org/@vbuterin/pbs_censorship_resistance) for the consensus layer, achieving centralized block production and decentralized block verification.
    

![https://twitter.com/VitalikButerin/status/1588669782471368704](https://storage.googleapis.com/papyrus_images/578f1da91d1a059190b469c2962d9fdd074a09828e369afc3da8d7750d014164.jpg)

https://twitter.com/VitalikButerin/status/1588669782471368704

* * *

### bonus: the day after the merge ( :

[![]({{DOMAIN}}/editor/youtube/play.png)](https://www.youtube.com/watch?v=FvflDadgf2I)

* * *

**◻️ motherofbots.eth**
-----------------------

---

*Originally published on [bt3gl's symposium](https://paragraph.com/@go-outside/on-experiencing-the-merge)*
