Crypto Forks Explained: Hard Fork vs. Soft Fork
A crypto fork or blockchain fork occurs when there are multiple versions of a blockchain on a blockchain network. Forks occur frequently, often as part of the blockchain’s normal operation. However, crypto forks can also be created deliberately, as happens when the blockchain client software is updated. Or they can be created maliciously as part of an attack against the blockchain’s security. All blockchains include fork rules to ensure they converge on a single version, so most forks are temporary, but in some cases, they can be permanent.
In this article, we explore what crypto forks are and why they happen, including:
- Why crypto forks are an expected part of blockchain operations.
- How blockchain networks handle forks.
- Forking on Proof of Work (PoW) and Proof of Stake (POS) networks.
- The difference between soft forks and hard forks.
- How cryptocurrencies are protected against malicious forks.
What Is a Crypto Fork?
A crypto fork occurs when a blockchain network hosts more than one version of the blockchain. They happen for various reasons, including intentional changes to the blockchain’s rules and protocols. However, unintended blockchain forks are an inevitable consequence of crypto’s decentralization. We’ll explore these “normal” forks first because they will help you to understand how and why soft forks, hard forks, and malicious forks arise and are dealt with.
What Causes Crypto Forks?
A blockchain is made up of chunks of data called blocks. Each block includes crypto transactions and has a header containing metadata. We explored blockchains in What is a Blockchain and How Does It Work? But, where forks are concerned, the critical point is that each block’s header contains a cryptographic hash of the previous block, connecting block to block and creating a chain from the first block to the newest.
Cryptocurrency blockchain networks comprise hundreds or thousands of independent nodes connected in a peer-to-peer network. Each node downloads the blockchain and new blocks from other nodes. A subset of nodes—miners or proposers—works to create and distribute new blocks.
In some circumstances, more than one node publishes a new valid block and sends it to its peers. If part of the network accepts one block and part accepts another, there is a network fork. Two versions of the blockchain exist simultaneously. Usually, both blocks will eventually make their way to all nodes, which results in another sort of fork, a blockchain fork—nodes have two valid blocks pointing to the head of the accepted chain.
It’s important to understand that forks are a common and expected consequence of how blockchain networks function. The software that runs on blockchain nodes includes rules for choosing the canonical blockchain, for reaching consensus across the network. The details differ between cryptocurrencies, but we can broadly divide consensus mechanisms into two types: PoW and PoS.
Forks in PoW Blockchains
In a PoW blockchain, nodes called miners compete to solve a mathematical challenge that consumes significant computing resources. The winning miner gets to add a new block to the blockchain, provided it’s considered valid by other nodes. The miner creates a block, solves the challenge, and shares the new block with its peer nodes. The peers validate the block, add it to their stored blockchain, and share it with their peers. Eventually, the block propagates across the network, so every node has an identical copy of the blockchain.
However, proof of work systems are probabilistic. The challenge is sufficiently difficult that it is unlikely two or more nodes will solve it simultaneously, but there is no guarantee. Another node could solve it and propagate its block, which may contain different transactions. As both valid blocks continue to propagate, nodes will eventually have two blocks. They will consider the block they received first as the winner, but they can’t ignore the one they received second—other nodes may have received it first. Both are equally valid, and neither is the “correct” version. So how do nodes choose a block and reconcile the fork?
There is no simple solution, so mining continues. Miners build blocks, attempt to solve the challenge, and the successful miner propagates a new winning block. Crucially, the winning miner links its newly created block to the block it considers the winner from the previous round.
As other nodes receive the block, they see which of the two blocks they received earlier it links to. Here is where the forking rules kick in: the canonical blockchain is the longest chain, the one that represents the most computation. As the newest block propagates, miners choose this longest chain and discard the other block. Eventually, all miners will work to add new blocks to the longest chain, and the fork has reconciled.
Because the mining challenge is difficult and mining is divided into time-limited epochs, forks are almost always resolved within a single block. Two-block forks do occur, but they are much rarer.
Forks in PoS Blockchains
In a PoS blockchain, there is no computational challenge to solve. Instead of miners solving challenges, PoS asks nodes called validators to stake cryptocurrency in exchange for the ability to validate blocks and a chance to propose new blocks.
Time on a PoS network is divided into slots of a fixed length, 12 seconds in Ethereum’s case. During each slot, a block proposer is chosen randomly from the pool of validators. The proposer creates a block and distributes it for validation by its peers, which attest to the block’s validity and send their attestation to other nodes. You can think of attestation as voting—nodes that have staked crypto get a vote on which block is included. Once a block is validated, nodes accept it as the end of the chain, and future blocks will be added on top.
The type of fork we discussed above is rarer on a PoS blockchain because the network selects a single proposer to create the next block. However, some circumstances, often network latency, lead to more than one valid new block propagating around the network.
We’re left with the same problem we faced above. How does the network settle on a canonical chain? The mechanism used by PoS networks is more complex than on PoW networks. You can read about how it works on Ethereum, but, in a nutshell, the version that represents the greatest weight of attestations is selected. Or, to put it another way, the version that represents the most staked cryptocurrency.
Soft Fork vs. Hard Fork?
The forks we’ve discussed so far are accidental. However, blockchains are frequently forked deliberately, usually during an update to the blockchain’s client software that changes its protocols. Deliberate forks can be divided into two main types: soft forks and hard forks.
The distinction between fork types can be confusing because “fork” is used in two different ways. The first is the blockchain fork we’ve discussed. The second is a software fork. When developers change software, they often copy it and edit the copy’s code. The original and the edited copy are forks of the same codebase. Crypto software forks can cause blockchain network forks, and those that do are called hard forks. Software forks that do not cause blockchain network forks are called soft forks.
Crypto Hard Forks Explained
A crypto hard fork occurs when the blockchain’s protocols and rules are updated, making newly created blocks incompatible with nodes running the old software. For example, the change might expand the rules governing a valid block. When nodes update to the new version, they will begin generating blocks considered invalid by nodes running the old software. The result is a fork: two different versions of the blockchain are accepted by different parts of the divided network.
Blockchain hard forks are typically short-lived. Most nodes will update, and block creation will continue according to the new rules. The small number of nodes that don’t update will no longer be considered part of the network, and their blockchains will rapidly become outdated. That is, hard forks require all nodes on the network to update.
A Blockchain Hard Fork Example
In some cases, blockchain hard forks are not quickly resolved. Long-lived forks can occur when part of the network disagrees about rule and protocol changes. In 2016, the Ethereum network published an update that caused a hard fork. The update was a response to an attack against the blockchain; it fixed the vulnerability and reversed the attack’s impact. Some network members did not approve of the fork, so they refused to update, resulting in a permanent fork and the creation of a derivative cryptocurrency that continues to this day.
Crypto Soft Forks Explained
A soft fork occurs when developers release a protocol change that is forward-compatible. They are typically used to add new features to a blockchain. Nodes that don’t update recognize that blocks created by updated nodes are valid. For example, the developers might add a new transaction type. Nodes that update to the new software validate and include the transaction in their blocks. Nodes that don’t update ignore the new transaction type while still accepting the new blocks and including them in their stored blockchain.
One way of thinking about soft forks is that they aren’t blockchain forks at all. They are software forks that do not cause network and blockchain forks. The name was chosen to distinguish forward-compatible software forks from hard forks.
A Crypto Soft Fork Example
In 2017, the Bitcoin network implemented the Segregated Witness (SegWit) soft fork. Bitcoin’s original block size limit was causing scalability challenges that resulted in slow transaction speeds. SegWit changed the Bitcoin protocol to improve scalability and enhance the security of the Bitcoin currency. It did so with a soft fork to avoid creating a fork within the Bitcoin network and the creation of a new blockchain.
How Do Blockchains Prevent Malicious Forks?
Blockchain network nodes are independently operated, and the operators control the nodes’ software. A malicious node operator might want to add fraudulent blocks to the blockchain to send themselves crypto they didn’t earn or spend the same crypto more than once. In theory, they could do so by creating a fork and influencing other miners or proposers to accept it. How difficult is that to achieve?
This type of attack is called a 51% attack because it requires an attacker to control over 50% of the staked crypto of a PoS currency and over 50% of the hash rate on a PoW currency. Remember, it’s not enough to simply create a fraudulent block and send it out to the network. Blocks are validated by other miners and proposers, and they would reject any block with fraudulent transactions. However, if the attacker controls most of the validating nodes, the balance tilts in their favor.
Fortunately, PoS and PoW blockchain consensus mechanisms make it very expensive to deliberately create a malicious fork with sufficient support. On a PoS blockchain, a malicious actor would have to stake a massive amount of crypto to make sufficient attestations to force acceptance of a fraudulent fork, an amount equivalent to many billions of dollars on a well-established currency like Ethereum’s Ether. On a PoW blockchain, they’d have to invest in vast amounts of processing power. For large cryptocurrencies like Ethereum and Bitcoin, the risk is practically non-existent.
How to Get Started With Cryptocurrency The Bittrex cryptocurrency exchange makes buying and selling cryptocurrencies including Bitcoin as straightforward as possible. Simply register and create an account, deposit U.S. dollars or crypto, and you’re good to go—visit our cryptocurrency marketplaces or Instant Buy & Sell to get started