Self Healing Blockchains
Tags: blockchain, webdev
Published: 2022-09-19 19:39:50

The world is eagerly waiting for a next-generation, high-performance, permission-less blockchain and this blockchain should be able to industrially scale all decentralized applications. So far, the world/crypto community has witnessed:

- P2P blockchain networks that use all the peers to validate transactions, do computation and storage. For example, Bitcoin, Ethereum … (Traditional Blockchains)
- P2P blockchain networks that shard transactions, computation, and storage. For example, Ethereum 2.0, Zilliqa … (Sharding Blockchains)

The sharding mechanism in blockchain gives hope for an unlimited and sustainable scalability of blockchains. But many people in the blockchain space strongly believe that the scalability of the blockchain networks or the sharding mechanism has reached a tipping point. Not true! How?
In this article, we will discuss the problems that plague sharding mechanisms in permission-less blockchain. And, how the self-healing mechanism is the only solution to this.

---

#In the blockchain world, why do we need sharding?
Currently, the internet is used in Payments, IoT, smart city, robotics, web search, streaming videos, e-commerce, autonomous vehicles, etc. Hence, the internet generates
- over billion transactions per second (Transaction)
- over sextillion calculations per second (Computation)
- over 2.5 quintillion bytes of data per second (Storage)

This work needs to be harmoniously split among all the peers in a P2P network. This splitting of work is called the Sharding Technology. Sharding can be applied to transaction, computation, and storage.

---

#Problems that plague Sharding Mechanism
A permission-less P2P network is unpredictable and to compensate for this unpredictability, various blockchain protocols fix the number of validations and the number of storage copies to a constant that is derived from a mathematical computation based on certain assumptions. This limits the scalability of blockchains since the system will either over-compensate and limit scale or under-compensate and risk security/integrity.

What if the P2P network can be predicted? Can the number of validation and number of storage peers be flexible depending on the chaoticity of the P2P network? That is to say, if the P2P network behaves ideally then only 1 validation and storage copy is needed and if the peers in the P2P network behave maliciously or deviate from the ideal nature, then the number of validation and storage copies will increase proportionally.

Problems faced by peers/shard in the P2P network:
- Internet connection problems, electricity cuts, data loss, many more …
- Joining and leaving the network all the time throughout the globe.
- Data availability and data consistency problems
- If a peer/shard goes offline, the data belonging to that shard is lost forever.
- Peers/shard can turn malicious anytime

> The culprit here is the unpredictability of the P2P network! This unpredictability of P2P network decreases the performance of validation, computation, and storage. 

---

#Self-Healing Blockchain

Due to the uncertainty in the P2P network, the self-healing mechanism is introduced!

**Case 1:** (Traditional Blockchains) where all the N nodes in the network validate/compute/store all the transactions in the network. (N)

**Case 2:** (Ideal P2P) Consider an ideal P2P blockchain network where all the peers in the network are available 24×7, with good internet, bandwidth, electricity supply, etc. and are good peers (not malicious). Then any transaction/computation/storage that arrives to the network can be validated/computed/stored by 1 peer. (1)

**Case 3:**(Sharded Blockchains) But the real P2P blockchain network is not so and hence a mathematical formula is derived based on the maximum possible deviation from the ideal P2P blockchain network and certain assumptions to set a fixed number like 22–600 peers to validate/compute/store depending on the blockchain protocol. (N/x)

**Case 4:** (Self-Healing Blockchains) Cases 1, 2 and 3 are extreme scenarios as shown in the graph! The number of transactions/computation/storage should depend on the amount of deviation from the ideal state (with adequate safety margin). (N/x(c)) where c stands for chaoticity of the network.

Chaoticity © of the network is a function of (internet bandwidth, electricity, data availability, data consistency, no of nodes joining or leaving). Any change in the function compared to the ideal state (whether positive or negative), the counter measures are deployed accordingly by the P2P network.

Hence the network automatically heals if there is any stress in the network.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p34b5xgvytkba7haqpvd.png)

---

#Analogy to self-healing blockchains

Let us take the example of Paris metro, where depending on the traffic of people, the metro trains change the timings, frequency, the number of compartments, and speed!
- Traditional: There will be a maximum number of metro trains, with maximum frequency, with maximum number of compartments and with maximum speed of the metro train all the time. (Lot of energy is wasted)
- Ideal: There will be a minimum number of metro trains, with minimum frequency, with minimum number of compartments and with minimum speed of the metro train all the time. (Takes a lot of time for people to commute)
- Sharded: The number of metro train, the frequency, number of compartments, speed of the metro train will be less than the maximum, but the numbers are fixed no matter the number of people who want to use the metro.
- Self-Healing: Depending on the no of people, peak hours from 7AM - 9AM and 4PM - 7PM, number of metros available, etc. … The number of metro trains, the frequency, number of compartments, speed of the metro train change accordingly and are flexible for a harmonious output.

---

#To Conclude
Self-healing blockchains are designed in such a way that they can survive for decades, if not centuries. The scalability achieved by these types of blockchains are close to centralized systems yet maintaining true decentralization. Since there is high scalability, any centralized application can be built on the self-healing blockchains.

Applying artificial intelligence to the time series (internet bandwidth, electricity, data availability, data consistency, data loss, number of nodes joining/leaving, etc.) could further improve the self-healing blockchains making them faster and able to predict an event before it happens and hence deploying countermeasures to handle any event before even happening!

There are multiple blockchain protocols leading the self-healing blockchain space, one of them is Archethic, a blockchain startup based in Paris, France with multiple patents registered on this.


#"Self-healing blockchains are the only way that can lead to a true decentralized world within a decade"

---

_**Author**: Akshay Reddy, Chief Product Officer at Uniris_