Join, compete & win! Prize pool of $100,000
Our Scheduled Maintenance starts on August 10th from 10 to 11am UTC. We‘re working hard to serve you better
Search
Generic filters
Filter by Categories

What is Chain Reorganization?

In short, chain reorganization is basically when blocks in the old longest chain get deactivated for blocks in the new longest chain. If that doesn't make any sense, don't worry, we'll provide a more detailed answer to the "what is chain reorganization?" question later. But, we must also point out that there are other fundamentals we must dissect as well if we want to understand chain reorganization fully. These include understanding the basics of blockchain, blocks, nodes, etc. If that sounds interesting, read on!

To understand chain reorganization, you need to understand the basics of blockchain technology. This includes exploring the many components that power the blockchain. Also, we have to understand that not all blockchains are identical. For example, various blockchains utilize different consensus mechanisms, such as proof-of-work (PoW) and proof-of-stake (PoS). But consensus mechanisms will not be our focus herein. For now, know that a blockchain is a digital ledger of transactions. You can think of it as a distributed database maintained by a network of computers called “nodes”. Moreover, nodes, along with miners and transactions, will be the starting point before we answer the “what is chain reorganization?” question in this article.

If you’d like to learn more about the different consensus mechanisms, check out our article explaining the proof of trust consensus protocol. Also, find out if PoW’s electricity consumption threatens the global energy crisis!

Miners, Nodes, and Transactions

Let’s use the Bitcoin blockchain as an example. When a user makes a transaction, nodes have to validate it. After validation, the transaction remains “pending” until a miner (specialized node) picks it up. Individual Bitcoin miners and mining pools are worldwide, and they compete to confirm these pending transactions. Once approved, the transaction gets added to the blockchain; however, miners place batch pending transactions into blocks rather than confirming them one at a time.

Bitcoin Nodes Miners

The confirmed block gets propagated to all the nodes across the network to ensure it is valid. After this round of validation, the nodes add the new block to the previous blocks, thus creating a chain. Furthermore, nodes hold a copy of the entire blockchain.

Ready to dive into Bitcoin? Take the Blockchain & Bitcoin Fundamentals course at Moralis Academy. In addition, there’s an exodus of Bitcoin miners from China to North America and other locations. Discover the top five crypto-friendly countries in one of our recent blog articles!

The Blockchain as a Database

If you’re familiar with how databases work, you can think of a blockchain as a database that stores information in a digital format to complete the picture. However, one crucial difference between a blockchain and a typical database is how the blockchain structures the data. 

A database typically structures its data into tables, whereas a blockchain structures data into blocks that link together using cryptography. Blocks store transactions until they are full and then link to the next block added. Furthermore, new transactions go into the newly formed block after the previous one is full. Once this new block gets filled, it gets added to the blockchain. And so, the cycle continues. This action forms a data chain conveniently known as the “blockchain”.

Code is king, and the network incentivizes nodes to process transactions honestly. Once validated and linked, the blocks become a permanent part of the chain that no attacker can alter. Accordingly, blockchain technology offers a secure way for people to transact without a third-party intermediary such as a bank or government controlling and overseeing it.

Bitcoin Transactions

What is Chain Reorganization?

Remember our brief explanation of what chain reorganization entails from the outset? Let’s now dig a little deeper into what chain reorganization is. Also, since we’ve explored the above information, let’s look at the role chain reorganization plays in this process.

Chain reorganization typically happens on more prominent blockchains like Bitcoin or Ethereum. It occurs when separate nodes build a new block at the same time. These simultaneous blocks create a temporary fork and force a decision from other nodes looking to add recent transactions. Which block should they choose?

Simultaneous Blocks

Since chain reorganization typically happens when two blocks get mined simultaneously, disagreements will arise about which block was first. After all, due to block propagation speed across the network, some nodes will create one block first while others will make a different block first.

Nodes do their best to stay in sync. So, a node adding the next block has to choose which side of the fork is the correct chain. So how do they handle this dispute of simultaneous blocks? At present, the answer is the “longest chain rule”. It states that the longest chain is the valid one. Technically, the globally accepted chain has the most work done on it. However, the one with the most blocks is usually the same. So, for nodes to follow protocol, they will only attempt to extend the chain that’s already the most extended.

blockchain

You’ll need a crypto wallet to transact regardless of which blockchain you use, and MetaMask is the most popular. Check out our MetaMask tutorial to learn more.

Transactions in Deactivated Blocks

Once nodes choose a block, the other side is lost. So what happens to the blocks full of transactions on the wrong side of the chain? Since only transactions on the longest chain become part of the valid blockchain history, the other block(s) get deactivated. These become what’s called “orphan blocks”.

The next question is, what happens to the transactions in the orphan blocks? In a chain reorganization, transactions inside orphan blocks are no longer part of the blockchain’s transaction history. So, they have to get reassigned into new blocks. 

To sum up, chain reorganization results in deactivating blocks in a node’s old longest chain. At such a juncture, the blockchain deletes a block to make room for the new block with the longer chain. Furthermore, chain reorganization ensures that all node operators get an identical copy of the ledger. 

Orphan Block Chain Reorganization

Orphan Blocks and Transactions in Chain Reorganization

Two blocks mined simultaneously shouldn’t cause a huge problem. However, transactions on the orphan block will need to go back to the node’s mempool, where they propagate around the network, looking to get mined in a future block. 

That means the minority of transactions on the wrong side of the fork can suffer delays during blockchain reorganization. So, it may be worth it for users to wait for a transaction to transfer more than one block deep into the blockchain before assuming it’s final. There is a chance it will get reorganized, and the user will have to hope it gets “re-mined” on the longest chain.

But there are no guarantees. Since the transaction does not exist in the active chain, it’s like it never happened. Thus, if a user tries to spend crypto inside an orphan block, the nodes would reject the transaction. That’s because the user is trying to spend an asset that does not exist on the valid chain.

Advantages and Disadvantages of Chain Reorganization

This section brings us to some of the pros and cons of blockchain reorganization. The advantage of chain reorganization is that it facilitates successful blockchain operations. Without it, a unified ledger operating with each node would be impossible. Because of chain reorganization, copies of the ledger saved across the nodes on the network are identical, ensuring that all recorded transactions are valid. Thus, this mechanism is essential in keeping blockchain technology versatile in its application.

Furthermore, chain reorganization is a relatively straightforward process that works seamlessly. However, it does have disadvantages, and one of them is the potential for double-spending.

Some Disadvantages

Despite its potential, blockchain technology has its flaws. We’ve discussed a common deficiency, “block conflict,” when two blocks get published too close together. As we’ve seen, a fork can occur on the blockchain when this happens. 

Chain reorganization is the answer to this block conflict. However, some analysts contend that chain reorganization can cause users to have their transactions rejected. In theory, this is possible when a user’s transactions reside in the abandoned orphan block. However, it rarely happens. Typically, transactions recorded in the orphan block ultimately pass. 

Delays, 51% Attacks, and DeFi Vulnerability

Nonetheless, other disadvantages include the fact that chain reorganization degrades UX while increasing node costs, the likelihood of 51% attacks, and the vulnerability of DeFi transactions. Chain reorganizations, or “reorgs”, can also cause additional memory and disc costs because of the state updates necessary to transition to the new fork.

Also, because of the possibility of chain reorganization, users need to wait longer before they can confidently treat their transactions as confirmed. Therefore, firms such as crypto exchanges may wait longer before accepting a deposit. That’s not always ideal for traders rushing to open or close out their positions.

Since chain reorganization elevates DeFi transaction risks, its existence results in lower than expected trading returns. Reorgs also increase the risk of 51% attacks. That’s because, during a chain reorganization, attackers don’t have to overcome all the honest miners. Instead, they only have to defeat miners who aren’t “re-orged”. Therefore, the attacker’s quest becomes likely if a reorganization occurs frequently. Ultimately, the most notable disadvantage of reorgs is the possibility of a double-spend attack. 

The Chain Reorganization of Ethereum Beacon Chain

The Ethereum Merge, a.k.a. “Ethereum 2.0,” is a crucial upgrade to the current network marking its transition from the PoW to PoS consensus mechanism. Furthermore, the scheduled merge should happen in August of 2022 and will combine Ethereum Beacon Chain with the current Ethereum mainnet.

7 Block Chain Reorganization

Ethereum Beacon Chain launched in December 2020, introducing native staking to Ethereum. In addition, by staking assets to a network, validators become eligible to add blocks to the chain. On May 25, however, the chain suffered a seven-block reorganization – the longest reorganization in years. More importantly, it exposed Ethereum Beacon Chain to a high-level security risk. 

Ethereum is one of the most popular blockchains, but let’s not forget about Solana. Check out our “Rust & Solana” article to learn more about this Ethereum competitor and its programming language. Also, if you’re an aspiring Web3 developer, visit Moralis and find out how to get Solana NFT metadata.

Seven-Block Reorg

Let’s explore the “seven-block reorg” further. In short, the validators got out of sync after a client update. They became confused during the update process and did not update their software. Furthermore, “seven-block reorg” means that seven blocks worth of transactions got added to a fork before being discarded. The network eventually dropped the fork after deciding it was not the correct chain. But not before seven blocks worth of transactions were added to it. According to Etherscan, each block on the Ethereum chain contains 200 to 300 transactions. That means up to 2,100 transactions went to orphan blocks.

Double-Spend Attacks

So, we know that when two competing versions of a blockchain exist, blockchain reorganization occurs. However, before a reorg is complete, there is the risk that a user can spend the same assets twice. They call this event “double-spending”. If it occurs maliciously, it’s a “double-spend attack”.

Blockchain

Ethereum chain reorganization happens when updated clients submit the next block ahead of the remaining validators. Further, this occurrence can confuse validators. In the case of Ethereum’s Beacon Chain reorg, the up-to-date nodes were about twelve seconds quicker than validators that hadn’t updated their clients. So, the Beacon Chain reorganization appears to be a benign event rather than a vicious one. To understand Ethereum fully, start with the Ethereum Fundamentals course at Moralis Academy today!

Vitalik Weighs In

Ethereum co-founder, Vitalik Buterin, chimed in on Twitter, crediting the theory that miners running outdated software could have caused the Beacon Chain problem. He and other experts stated that one or two block reorganizations happen regularly because of network latency. However, anything over five blocks is suspicious since longer reorganizations primarily happen by client bugs, network failures, or malicious attacks. After all, the longer a reorganization lasts, the more serious the security risk. Nonetheless, there’s also the possibility of plain bad luck.

Vitalik seems to think the slower node operators were the ones who hadn’t updated their software. It makes sense; after all, blockchain reorganization can occur when some node operators are quicker than others.

Vitalik Beacon Chain Reorganization

Chain Reorganization – Summary

Ethereum’s Beacon Chain reorganization is an interesting case in that it lasted for seven blocks. Since that’s much longer than usual, it raises the question of what could have happened if double-spend attackers were standing by? Also, how many blocks can a chain reorganization be?

In actuality, it can be any number of blocks. If a node receives a new chain that’s longer than its current active chain of blocks, it will do a chain reorg to adopt the new chain, regardless of how long it is.

Regarding the Ethereum Merge, a more pressing question has to be whether or not this recent reorganization problem exposed enough security risk to cause a delay? Only time will tell. However, one thing is certain, blockchain technology and Web3 are here to stay. Isn’t it time for you to benefit from this latest internet iteration? There are many reasons why to learn Web3 development. So head over to Moralis Academy and learn how to become a Web3 developer today!

IvanLiljeqvistCEO.jpg

Written by Ivan on Tech

June 9, 2022

Written by IvanOnTech
June 9, 2022
Ivan is an international speaker, educator, developer and data scientists. Ivan’s YouTube channel Ivan on Tech has become an international phenomenon, spreading blockchain knowledge all over the world and accumulating over 450,000 subscribers.

Subscribe to our Newsletter

Get the latest information about Moralis Academy in your email
Your subscription could not be saved. Please try again.
Your subscription has been successful.

By subscribing you agree to the Terms of Use and Privacy Policy

Search
Generic filters
Filter by Categories

Want to Unlock your Career in Blockchain?

Hey! We are the Moralis Academy.
We're here to help you build a career in Blockchain, Crypto, and Web3.

Are you ready?

About Moralis Academy

Moralis Academy is a world-leading Blockchain, Crypto, and Web 3.0 e-Learning provider from the team behind Moralis (the ultimate Web 3.0 development platform). Our instructors live and breathe everything Blockchain. Founded by Ivan ‘Ivan on Tech’ Liljeqvist and Filip Martinsson, the Academy has already empowered 35,000+ students around the world with the skills they need to succeed as Blockchain, Crypto, and Web 3.0 professionals.

Subscribe to our Newsletter

Get the latest information about Moralis Academy in your email



By subscribing you agree to the Terms of Use and Privacy Policy

Recent Articles

22_08_Top-Crypto-Payment-Gateways-2022
Crypto Payment Gateways

Top Crypto Payment Gateways 2022

As cryptocurrencies continually grow in popularity, businesses seek exposure to the asset class with minimal friction and risk. As a result, crypto payment gateways are becoming an increasingly favorable solution. Below, we discuss eight of the top crypto payment gateways as voted for by a selection of media outlets. To discover which of the top crypto payment gateways is best for your business, read on!

Read More
22_08_Understanding-Zero-Knowledge-Proof-Technology-1
zero-knowledge proof

Understanding Zero-Knowledge Proof Technology

Blockchain technology operates as a public, decentralized, and distributed ledger. The blockchain records and stores historical transaction data, allowing transaction processing without involving a trusted third party. However, since blockchains are transparent, malicious users may try to access private transaction data such as wallet addresses, account balances, and transaction amounts. Therefore, while the blockchain is becoming more widely accepted in various industries, the sector still needs to overcome challenges to acquire more corporate migration. That’s where zero-knowledge proof technology comes into play.

Read More
Top5-Companies-Accept-Crypto
Companies Accepting Cryptocurrencies

Top 5 Major Companies Accepting Cryptocurrency Payments

There are now more companies accepting cryptocurrencies as payment than ever before. This comes as no surprise as the integration of blockchain into legacy payments systems gives customers more options. But which are the top companies accepting crypto in 2022? Find out herein as we explore five big-name firms that take crypto payments!

Read More

Log In

Sign in to your account and start learning!

Build Web3 Projects
Take part in weekly development projects & win NFTs