This is the year that Ethereum will be tested to its limits, with renewed focus on technologies that will help it to scale.
even though Ethereum is still young, the ICO-driven hype is making it seem more advanced than it really is. The potential for Ethereum and web3 to create a decentralized internet that is safe and easy to use is still there, but it won’t be realized until some key infrastructure is put in place.
There are several projects working to improve the infrastructure of ethereum and expand its capabilities. These projects are commonly referred to as scaling solutions. They come in many different forms, and are often compatible or complimentary with each other.
I want to talk about off-chain or layer 2 solutions for scaling in this long post.
- First, we’ll discuss the scaling challenges of ethereum (and all public blockchains) in general.
- Second, we’ll cover the different approaches to solving the scaling challenge, distinguishing between “layer 1” and “layer 2” solutions.
- Third, we’ll delve into layer 2 solutions and explain how they work — specifically, we’ll talk about state channels, Plasma, and Truebit
This article is focuses on providing the reader with a comprehensive and clear understanding of how layer 2 solutions operate. We won’t be delving into code or specific implementations, but rather focus on understanding the economic mechanisms used to construct these systems, and the shared insights that all layer 2 technologies share.
1. The scaling challenges of public blockchains
When people talk about “scaling” Ethereum, they are referring to a set of challenges that need to be addressed in order to make it useful for a global user base of billions of people.
Transaction throughput is the most common scaling challenge that is discussed. Ethereum can currently process around 15 transactions per second, while in comparison Visa processes approximately 45,000 transactions per second. In the last year, some applications, like Cryptokitties, or the occasional ICO, have been popular enough to slow down the network and raise gas prices.
The main issue is that public blockchains like ethereum need every transaction to be processed by each and every node in the network. This means that every operation which takes place on the ethereum blockchain -such as a payment, the birth of a Cryptokitty or the deployment of a new ERC20 contract- must be carried out by each node in the network at the same time. This is part of what makes public blockchains so reliable, as nodes do not have to depend on anyone else to inform them about the current state of the blockchain- they can figure it out for themselves.
An individual node’s transaction processing ability caps ethereum’s potential transaction throughput.
We could get every node to do more work by doubling the block size, but this would come at the cost of decentralization by making it harder for less powerful computers to stay on the network. Mining would become more centralized among powerful node operators.
We need a way for blockchains to be more efficient so that individual nodes are not overwhelmed with work.
Conceptually, there are two ways we might go about solving this problem:
I. What if each node didn’t have to process every operation in parallel?
The first approach would be to reject the idea that every node has to process every operation. What if the network was divided into two sections that could operate semi-independently?
The transaction throughput of a blockchain can be doubled by having one section process one batch of transactions while another section processes another batch. If the blockchain is split into many sections, the transaction throughput can be increased by many times.
Different sections of the blockchain are called shards, which can process transactions independently. This is called sharding and is a Layer 1 scaling solution being pursued by Vitalik’s Ethereum Research group. If you want to learn more about sharding, there is an extensive FAQ and blog post that can help explain it.
II. What if we could squeeze more useful operations out of ethereum’s existing capacity?
The second option would involve not increasing the capacity of the ethereum blockchain, but rather finding ways to make better use of the capacity that already exists. This would mean that the blockchain would be able to handle the same amount of throughput, but in practice be able to do more things that are useful to people and applications, such as transactions, state updates in a game, or simple computations.
The aim of “off-chain” technologies like state channels, Plasma, and Truebit is to allow operations to be carried out “off chain” instead of on the ethereum blockchain, while still maintaining a high level of security and finality.
These solutions are built on top of the ethereum main-chain and don’t require changes to the base level protocol. They exist as smart contracts on ethereum that interact with off-chain software.
2. Layer 2 solutions are cryptoeconomic solutions
The following text discusses the underlying insight that makes layer 2 solutions possible.
A key strength of public blockchain technology is its use of cryptoeconomic consensus. By ensuring that economic incentives are aligned and securing them with software and cryptography, it is possible to create networks of computers that can reach agreement about the internal state of a system. This is the key insight of Satoshi Nakamoto’s whitepaper, which has been used in the design of many different public blockchains, including Bitcoin and Ethereum.
We can be sure that on-chain operations like payments or smart-contracts will happen as they are supposed to unless something drastic happens, like a 51% attack.
Layer 2 solutions are based on the idea that we can use a core group of certainties as a fixed point to which we can attach additional economic mechanisms. This second layer of economic mechanisms can then be used to extend the utility of public blockchains to interactions that take place off the blockchain, while still being able to refer back to the core group if necessary.
The layers that have been built on top of ethereum may not always offer the same level of security as on-chain operations. However, they can still be secure enough to be useful, especially when the slight decrease in finality allows for faster operations with lower costs.
Cryptoeconomics is a relatively new area of study that is constantly evolving. Satoshi’s whitepaper was just the beginning of what has been accomplished in this field. There is much still to be learned about how to apply cryptoeconomic principles, not just in the design of core protocols, but also in the design of secondary systems that build on the functionality of the underlying blockchain.
I. State channels
State channels are a way of conducting transactions and other state updates without using the blockchain. However, events that take place within a state channel are still highly secure and final. If anything goes wrong, we can still refer back to the on-chain transactions, which provide a high degree of certainty.
State channels are a more general form of payment channels that can be used not only for payments, but for any arbitrary “state update” on a blockchain, like changes inside a smart contract. State channels were first described in detail by Jeff Coleman in 2015.
An example of a state channel would be two people using a chat application to discuss a contract they are working on. In this case, the state channel exists between the two people using the chat application. All data related to the contract (including any changes that are made) is stored on the state channel. A state channel is a two-way communication channel between two people. In the context of a contract, all data related to the contract is stored on the state channel.
If Alice and Bob wanted to play a game of tic tac toe in which the winner would receive 1 ETH, they could do so in a naive way by creating a smart contract on Ethereum that would implement the rules of the game and keep track of each player’s moves. Every time a player wanted to make a move, they would send a transaction to the contract. When one player won, as determined by the rules, the contract would pay out 1 ETH to the winner.
Alice and Bob are using the Ethereum network to process their game, which is inefficient and slow. They have to pay gas costs every time a player makes a move, and they have to wait for blocks to be mined before making the next move.
Features and limitations
State channels are useful in many applications, where they are a strict improvement over doing operations on-chain. However, it’s important to keep in mind the particular tradeoffs that have been made when deciding whether an application is suitable for being channelized:
- State channels rely on availability. If Alice lost her internet connection during a challenge (maybe because Bob, desperate to claim the prize, sabotaged her home’s internet connection) she might not be able to respond before the challenge period ends. However, Alice can pay someone else to keep a copy of her state and maintain availability on her behalf.
- They’re particularly useful where participants are going to be exchanging many state updates over a long period of time. This is because there is an initial cost to creating a channel in deploying the Judge contract. But once it is deployed, the cost per state update inside that channel is extremely low.
- State channels are best used for applications with a defined set of participants. This is because the Judge contract must always know the entities (i.e. addresses) that are part of a given channel. We can add and remove people, but it requires a change to the contract each time.
- State channels have strong privacy properties, because everything is happening “inside” a channel between participants, rather than broadcast publicly and recorded on-chain. Only the opening and closing transactions must be public.
- State channels have instant finality, meaning that as soon as both parties sign a state update, it can be considered final. Both parties have a very high guarantee that, if necessary, they can “enforce” that state on-chain.
Our team at L4 is building Counterfactual- a framework that allows for generalized state channels on the Ethereum network. This will be a modular implementation that will let developers use state channels in their application without needing to be experts on the subject. We’ll be releasing a paper describing our technique in Q1 2018.
state channels projects like Raiden are focused on creating a web of payment channels using a similar process to the lightning network. This would allow users to open one channel with an entity that is connected to a larger network of channels. This would allow for free payments to anyone else who is also connected to the same network.
Other than Counterfactual and Raiden, there are many channel implementations that are specific to certain applications on Ethereum. For example, Funfair has created state channels (which they call “Fate channels”) for their decentralized gambling platform. Another example is Spankchain, which has built one-way payment channels for adult performers (they also used a state channel for their ICO). Lastly, Horizon Games is using state channels in their first Ethereum-based game.
II. Plasma
On August 11, 2017, Vitalik Buterin and Joseph Poon released a paper titled Plasma: Autonomous Smart Contracts. The paper introduced a novel technique that could enable Ethereum to reach many more transactions per second than currently possible.
Plasma is a technique for conducting off-chain transactions that relies on the underlying ethereum blockchain for security. Plasma is different from state channels in that it allows for the creation of “child” blockchains that are attached to the “main” ethereum blockchain. These child-chains can, in turn, spawn their own child-chains, who can spawn their own child-chains, and so on.
The result is that we can perform many complex operations on child-chains, with minimal interaction with the ethereum main-chain. A Plasma child-chain can move faster and charge lower transaction fees because operations on it do not need to be replicated across the entire ethereum blockchain.
Ethereum Alternatives
Ethereum’s high gas fees have led to alternative blockchains with lower fees becoming more popular. However, these alternative blockchains require compromises in order to provide advantages in scalability. The “blockchain trilemma”, a term coined by Vitalik Buterin, describes the tradeoffs that blockchains must make between scalability, security, and decentralization. In general, these alternative blockchains provide higher throughput by increasing the amount of state-update space in each block and/or generating blocks faster than Ethereum. By increasing the number of transactions that the blockchain can handle in a given time frame, these networks reduce the cost of transactions compared to Ethereum.
Although larger and faster blocks can be validated with more powerful and sophisticated hardware, this hardware is not readily available to the average consumer. For example, Solana validators require at least 128 gigabytes of RAM, which most consumers do not have access to. As a result, there are fewer people who are able to validate blocks, which limits decentralization of the network. Although it is more expensive to become an Ethereum validator today, this cost has been gradually increasing since 2017.This 275,000 to 1,350 ratio shows that Ethereum has a much longer history and requires less sunk costs to validate. Although it would be nice for both networks to make validation more available to users, decentralization of the nodes is a bigger priority. Since most users won’t choose to validate, it’s important that there are enough decentralised nodes to protect everyone’s transactions.
Some people think that the way that alternative L1s are set up goes against the decentralized nature of public blockchains. They worry that having fewer people in charge of the network makes it more likely that one bad actor could take over, or that the people in charge could work together to do something bad on purpose. In reality, many people are willing to give up some decentralization in order to avoid having to pay very high fees. However, this means that alternative L1s do not really improve upon Ethereum in terms of scaling, since they have less decentralization.
Monolithic vs Modular Blockchains
Ethereum can scale without sacrificing security or decentralization by using Layer 2 solutions. These solutions provide genuine scalability improvements by establishing three critical roles of a public blockchain: consensus, execution, and data availability. A blockchain must provide a highly secure consensus mechanism to ensure that every state change complies with the set of financial rules. It must also perform computation to execute transactions and change the state of the blockchain. Finally, a blockchain must provide data space in each block to record new state changes in a publicly accessible way.
While most blockchains today are designed as one comprehensive unit, a new concept known as a modular blockchain may provide a way to scale these systems without compromising decentralization or security. A modular blockchain would handle consensus on the main layer while delegating one or more of the other two critical roles to a separate layer. This could potentially address the blockchain trilemma, which is the challenge of achieving all three of these goals simultaneously.This approach can scale Ethereum while still being decentralized as long as the transactions made on the execution layer are finalized by the decentralized consensus layer.
Early Layer 2 Solutions
Plasma and state channels are two scaling solutions that have been around for a number of years but are not as popular as they once were. State channels work by locking part of the blockchain via a smart contract. Two or more users will enter into this contract and deposit funds to be used in the channel. These users can then “send” funds back and forth to each other via signed transactions that could be posted on Layer 1, but are not until the channel closes. These signed transactions act as a record of the net change between the users’ accounts. Once a user wants to exit the state channel, they can submit a signed transaction to the smart contract to be posted on Layer 1 which, if accepted, closes the channel.If one user tries to leave the channel while there are still more recent transactions that they have not posted, the other user can challenge them by posting the most recent transaction. This will prove that the first user’s submission wasn’t up to date. Then, the smart contract can act as a judge and post the most recent signed transaction. This protects the channel’s state. While this can be applied to smart contract logic, it’s relatively complex to actually implement state channels due to all the different cases that could happen.
Plasma works by creating non-custodial child chains that are tethered to Layer 1, which provides high throughput and significantly lower gas fees than Ethereum L1. Unlike rollups, general smart contract execution is not possible on plasma, and transaction data is not made available on chain. Furthermore, in order to withdraw to L1, users must wait 7-14 days to allow users to challenge potentially fraudulent transactions.
Leave a Reply