What Is Sharding?
Sharding refers to splitting the entire Ethereum network into multiple portions called ‘shards’. Each shard would contain its own independent state, meaning a unique set of account balances and smart contracts.
Sharding is definitely the most complex Ethereum scaling solution. It’s also the one that is expected to be released last, giving developers the necessary time to both fully scope it out and test it in production environments.
Before getting into the technical details, it’s important to know the role that nodes play in the Ethereum network. Nodes are responsible for verifying the miners’ work and ensuring that consensus rules are followed. The best way to do this is to keep a full copy of the Ethereum ledger, that way it’s easy to verify a miner’s work. But the Ethereum blockchain is approaching 1TB of storage so it’s impractical for a regular person to run a node.
The Big Problem
This presents a big problem: if Ethereum nodes become too expensive to run, the network will be more susceptible to centralization. At the same time, requiring each transaction to be processed by every node will make it so Ethereum never scales. Sharding is a potential solution to this very problem.
Sharding is different from both state channels and plasma in that it’s not attempting to move transactions off of the blockchain. What it’s doing is attempting to break up the blockchain into multiple parts so nodes aren’t responsible for processing every transaction broadcasted on the Ethereum network. Sharding begs the question, does every node in the network need to process each transaction for a blockchain to be considered secure?
More importantly, Sharding is Ethereum’s most formidable option to solve the scalability trilemma. To date, no blockchain network can exhibit all three of the following traits without having to sacrifice one of them:
Within a shard, notaries are randomly picked to periodically vote on the validity of blocks, think miners in a regular blockchain. These votes are then reviewed by a committee on the main Ethereum chain and merged via what’s called a sharding manager contract. These shard blocks are referred to as collations and are chained together the same way blocks on a blockchain are.
In fact, each shard is tied to the main Ethereum chain in the form of merkle trees, creating a cryptographic connection between the two. We can prove certain things about the shard relative to when it was created. Each shard acts as its own standalone blockchain. The users on each shard have their own account balances away from the main Ethereum network and can only transact with other users on the shard.
An easy way to think of it is to imagine if Ethereum was split into thousands of islands. Each island can do its own thing, it can have its own features and everyone belonging to that island can enjoy it. If they want to contact other islands, they will have to use some sort of protocol. That’s what Sharding allows. It creates a way for each shard to store individual receipts of each transaction. Since they’re cryptographically secure, they can be brought back to the main chain at any time.
Challenges to Sharding
While Sharding sounds great in theory, there are a number of potential attack vectors. One specific attack is the single-shard takeover attack. In this scheme, an attacker takes over the majority of block producers in a shard to create a malicious shard that can submit invalid transactions. The Ethereum core developers point to random sampling as a solution, but this is still in active development.
Sharding is also much easier to implement on a proof-of-stake chain than it is on a proof-of-work chain. There are already active validators within proof-of-stake which can be randomly assigned to different shards. In proof-of-work, nothing can be done to completely stop a miner from contributing hash power to a particular shard. If they know the shard they’re validating, they could potentially try and orchestrate some collusion.