Sharding technology has appeared long before blockchain and has been used in a number of systems from business database. Sharding is a method which horizontally partitions data within a database. The database is fragmented into smaller parts called “shards”, and then they are put together to form the original database.
With blockchains, their network is made out of nodes which are connected peer to peer, which is not governed by one entity. The nodes store all states of the network and handle transaction processing. While this system is more secure, it does face difficulties with scaling as the network increases in size at a rapid pace. This problem is because the consensus only increases linearly.
When the network experiences such strains, the transaction costs and times increase significantly.
Sharding has been considered to be a complex solution to the scaling problem. By grouping subsets of nodes into shards, the system is able to process transaction in parallel which increases the volume it can handle.
There are several blockchains for cryptocurrencies which have had sharding technology implemented in order to improve scalability and their transaction volume.
But blockchains using Proof of Work (POW) consensus algorithm cannot have sharding applied to them. Only blockchains that use Proof of Stake (PoS) consensus algorithm are able to use this technology. This is because this consensus algorithm features specific, designated nodes which handle only transaction validation.
How Does Sharding Work in Blockchains?
The best known blockchain to try to implement sharding is Ethereum. Their development team is working on introducing what is known as “state sharding”.
Sharding in Ethereum will be implemented in two phases, after the network will have switched to Proof of Stake protocol.
- Phase one is a data layer consisting of the consensus regarding the shard’s data.
- Phase two is the state layer.
The network is broken down into specific shards which have assigned a specific group of transactions determined by certain accounts and smart contracts.
Each transaction group is comprised of a header and a body.
The Header represents the shard ID of the transaction group which assigns validators through random sampling. Here is where the State Root can be found (state of the merkle root of the shard before and after transactions added).
The Body contains all of the transactions from the transaction group’s specific shard.
Transactions which belong to shard and can only take place between accounts of that particular shard. As transactions are verified, the entire network is updated. For the transaction group to be marked as valid, the pre-state root of the transaction group has to be the same as the global state’s shard root.
What is a Merkle Root?
Ethereum blocks contain in addition to a state root, a transaction group root as well. The transaction group root represents the merkle root of all of the transaction groups from certain shards. A merkle root of all of the different shards is comprised of the updated and verified transaction groups.
A merkle tree is used here to ensure the validity of the blockchain. A shard reaches consensus by applying a Proof of Stake algorithm to nodes selected at random which are applied to a shard for a specific consensus round.
A PoW sharded network requires a lot of hash power in order to be overturned, meaning that no malicious takeover can occur by the exclusive use of computational power.
The communication protocol is vital to the sharding architecture functioning correctly in the system. You can think of the communication protocol as the universal language that is consistent among the states as part of the larger United States. However, designing this protocol is highly challenging and needs to be performed so that it is only used when necessary. It becomes necessary when a specific node requires information that is not stored within its own shard and needs to find the shard with the requisite information. This communication is known as cross-shard communication.
This type of communication requires the appliance of a concept known as transaction receipts. The receipt of a transaction is kept in a merkle root which is not part of the state root, but can be easily accessed to be verified.
The shard which receives a transaction from another shard can then use the merkle root to verify ensure the receipt and its spending state, thus preventing double-spending. In simpler terms, the receipts are kept in an immutable shared memory which can be accessed by other shards to verify the transaction. This distributed storage of receipts enables shards to communicate with each other.
Disadvantages of Sharding
But sharding does not solve all the scaling and performance issues. One big disadvantage is that the communication between shards is quite difficult to achieve.
This is because when a user from one shard want to transact with another user from a different shard, this type of transaction would need another different protocol.
Sharding is one of the many solutions that have been proposed to solve the issue of scalability in blockchain networks. The results of sharding will not be visible at first to the end user or dapp developer, as it is a modification only at protocol level. But over time, sharding may improve network volume, lead to faster transaction times and lower transaction fees, which will overall make the platform function better on a larger scale.
Featured image: JOC.com
coindoo.com is author of this content, TheBitcoinNews.com is is not responsible for the content of external sites.
TheBitcoinNews.com is here for you 24/7 to keep you informed on everything crypto. Like what we do? Tip us some Satoshi with the exciting new Lightning Network Tippin.me tool!