Get Tangem

What is sharding and how does it work?

Blog_Sharding.png

One of the greatest challenges facing database developers is scaling. As data volumes and numbers of operations involved grow, system performance must also be improved one way or another.

Sharding is a database scaling technology based on the idea of splitting databases up into separate segments, each of which can be housed on a separate server.

If we apply this technology to the blockchain, sharding represents the division of the network into separate sectors. Each sector, or shard, contains a unique set of smart contracts and account balances, and specific network nodes are assigned to each shard. These nodes are responsible for verifying transactions only in their assigned shard, rather than for all transactions on the blockchain.

What problems does sharding solve?

The more popular a project becomes, the more users it attracts. These users end up conducting more transactions, launching more DApps, and running more processes on the network. As a result, transaction speeds fall and commissions increase in size, impeding the project’s future expansion and development. Dividing the network into shards allows you to solve the problem by increasing the processing capacity of the blockchain.

When a group of nodes is responsible for a certain segment of the ledger, all the nodes in the network are relieved of the requirement to maintain the entire blockchain in order for every transaction to be completed. Operations are validated in parallel rather than linearly, thereby increasing the throughput of the network and eliminating the issue of scaling.

Additionally, nodes on blockchains that use sharding work more efficiently without increasing computing power as a result of the reduced load.

How it all works

Blockchains require the work of thousands of computers to function, and their computing power enables distributed ledgers to conduct transactions, execute smart contracts, deploy DApps and more. If the network operates on the basis of sequential execution, then each node must process every transaction. The verification of operations therefore takes a lot of time. Ethereum, for example, processes around 10 transactions per second.

If nodes are simply added to the blockchain, its performance won’t increase. All that will happen is the verification chain will become longer.

The principle of sharding lies in abandoning the linear execution model in favour of a parallel one, in which shards only carry out certain calculations and process a large number of transactions simultaneously. They are a kind of “blockchain within a blockchain”, transferring all of their information to the main chain, albeit in a compressed format.

The downsides of sharding

There are two key problems in sharding: communication between shards and security. 

  1. Communication. If you split the network into isolated sectors, each of them becomes a de facto separate blockchain. Users and decentralized applications in one shard will only be able to communicate with users and applications in another by using a specific communication protocol.
  2. Security. In a sharded network, it’s much easier to take full control of one shard than an entire unsharded network, as the hash rate required is much lower. For example, a 51% attack on the Bitcoin network would require billions of dollars in hardware and hundreds of millions of dollars a day in electricity. It’s expensive, unprofitable and unfeasible. Capturing a single shard, however, is far cheaper and easier.

Ethereum offers a solution to this problem that uses random sampling. Shard protocols are randomly assigned to different sections in order to confirm block authentication. This was made possible by the network’s switch to the proof-of-stake consensus method.

The networks already deploying sharding

The first network to introduce sharding was Zilliqa. It bills itself as a blockchain platform aiming to solve scalability issues with sharding. At the testnet stage, it was able to achieve 2,828 transactions per second.

The NEAR blockchain ecosystem calls itself a sharded PoS blockchain and claims that its sharding technology supports nodes that are small enough to run on low-performance devices.

Ethereum also plans to implement sharding technology. Other sharded networks include Cardano, QuarkChain and Plian.

Conclusion

In theory, sharding technology can finally solve the blockchain trilemma if it is able to resolve its flaws. If it does, it will become possible to scale blockchains without sacrificing decentralization or security.