0%
Overview page background
HomeOverviewsEthereum
What is a shadow fork?

What is a shadow fork?

Alchemy headshot

Written by Alchemy

Brady Werkheiser headshot

Reviewed by Brady Werkheiser

Published on 2022-06-244 min read

What is a shadow fork?

Shadow forks are similar to devnets, but instead of having their own state, they copy the state of another network (devnet or mainnet). 

For example, a shadow fork of the main Ethereum network still accepts all transactions that go to the mainnet. 

This branch could switch to Proof-of-Stake, but it would still keep mainnet transactions and other state/history data. 

After a successful merge on the shadow fork, it moves on to the Proof-of-Stake chain and ignores any Proof-of-Work blocks that were added to the mainnet.

How is a shadow fork different from a normal fork?

Unlike a shadow fork which is intentionally created to test network upgrades with existing state data from the original chain, a normal fork happens when the development community modifies the protocol or is affected by hacks. When a fork occurs, the blockchain splits, making a second (new) blockchain with the same history as the first but a different path.

One example of how upgrades to a blockchain from core developers causes a fork, is the London Hard Fork which introduced EIP-1559 to optimize Ethereum’s transaction fee structure.

Bitcoin and Ethereum are both based on blockchain technology and run on open-source software. They are called "blockchains" because they are made up of blocks of data that can be linked back to the first transaction on the network. 

Because they are open source, their communities are responsible for maintaining and enhancing the source code. As a result, a fork may happen to make a blockchain more secure, to add new features, or to mitigate the effects of a hack, which occurred in 2016  after The DAO hack. 

In 2016 the Ethereum blockchain forked into Ethereum Classic which maintained an accurate ledger that reflected the 3.6 million ETH that was stolen, and Ethereum which forked to reverse the hack.

What is the difference between soft forks and hard forks?

The difference between soft forks and hard forks is that soft forks change the code of an existing blockchain and hard forks divide the blockchain into two distinct blockchains. 

Soft Fork 

A soft fork can be thought of as an update to the software that runs the blockchain. As long as everyone uses it, it will become the new set of rules for the network. 

Soft forks have been used to add new features or functions to Ethereum, usually by changing the codebase and client software. The changes work with blocks that were made before the fork because the end result is a single blockchain.

Hard Fork 

When the code changes so much that the new version can't be used with older blocks, this is called a "hard fork." In this case, the blockchain splits into two parts: 

  1. the old blockchain that follows the old rules

  2. the new blockchain that follows the new rules

This makes a brand-new cryptocurrency and is where many well-known currencies got their start. A hard fork created Bitcoin Cash from the original Bitcoin blockchain, and Ethereum Classic (ETC) was made from Ethereum (ETH).

Why are shadow forks important?

Shadow forks are important tools for web3 developers because it allows them to test their assumptions about the network's upcoming upgrades against the most current conditions of the mainnet’s production environment.

The Kiln test network is the last testnet for developers to test in preparation for The Merge, which changes Ethereum's Execution Layer from Proof-of-Work to Proof-of-Stake. 

Shadow forks are important to show that the Merge will come to fruition without a detrimental transition for existing dApps that run on the network. 

Testnets that have these shadow forks will be the testing grounds to ensure a smooth merge transition occurs, and will help engender trust to node operators and builders. 

How do shadow forks work?

An image showing how a shadow fork is created out of an existing Goerli chain
An image showing how a shadow fork is created out of an existing Goerli chain. Source: AllCoreDevs Update #011 https://tim.mirror.xyz/PWFVaHY3Mrx7srarMmuBWya0J5kioR1l2xaH3p5APDk

In the picture above, the top row of Goerli blocks shows a node on the canonical (i.e. original) blockchain that doesn't know about the shadow fork. 

The middle row of Goerli blocks represents a node on the shadow-forked chain with a different configuration that tells it to split when it reaches the terminal total difficulty (TTD) or the total mining difficulty that is used as a trigger for clients to stop mining and transition to PoS.
In the last row, there is a picture of a Beacon Chain that was made just for the shadow fork. When the TTD is reached, the nodes in the canonical chain keep making blocks as if nothing had happened and the nodes whose configurations have changed split off go through the Merge. 

Then, the next validator makes the first block for the Beacon Chain after the Merge

Shadow forking is the best way to do this because it lets developers test how well the fork and merge process works without affecting the public testnet or mainnet.

By doing this shadow fork operation over and over again, developers can test the merging transition under different situations.

What are well-known shadow forks?

Two testnets stand out as having some of the most well-known shadow forks: Goerli has gone through three shadow forks, while mainnet has gone through six. The main difference between the two mainnet shadow forks was that all client combinations made it through a shadow fork transfer and stayed in sync. 

This shadow fork also uses the develop/unstable branch for each client. This means that developers no longer need to merge branches. On the mainnet, the deposit contract was used again, but with a different fork ID. 

This implies that on the shadow fork, every mainnet deposit must be processed and marked as invalid. This resource-intensive computation caused some edge conditions for a small number of clients, but the network still worked fine. 

How to shadow fork Ethereum

If you’re interested in forking Ethereum, you can follow Alchemy’s step-by-step guide on how to fork Ethereum mainnet with a free Alchemy account, HardHat, and a command line interface (CLI).

Shadow Forks Are Critical Ethereum Developer Tools

Shadow forks play an important role in the ongoing development and scaling improvements of the Ethereum blockchain. With shadow forks, core Ethereum developers, node providers, and independent stakers can prepare for upcoming network-wide changes so the Ethereum application ecosystem is not interrupted.

Overview cards background graphic
Section background image

Build blockchain magic

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.

Get your API key