Layer 2 technology enables high-speed, low-latency and in some cases, private transactions, giving traders all the benefits that they are used to on a large crypto exchange such as Coinbase, but without giving up custody of their funds.
We’ve already published introductory guides to Layer 2 and its related technology, rollups. Now we’re going to take a more detailed look at the tech, analysing the main kinds of scaling solution and explaining the benefits of each.
How Layer 2 rollups work
Over the last couple of years, a category of technology known as ‘rollups’ has become synonymous with Layer 2.
A rollup is a kind of scaling solution whose security is guaranteed by the underlying Ethereum blockchain. This is an important distinction to make, as other types of scaling technology purport to be Layer 2, when in actual fact they do not have as strict security guarantees.
So rollups can prove transactions far more quickly than would be the case on Layer 1, while providing the same level of trust and reliability.
Ok, so what are the different types of rollup project?
Within the category of Layer 2 rollups, there are two main types – zero knowledge rollups (or ZK rollups) and Optimistic rollups (often called Optimism rollups, although Optimism is a brand name rather than the generic name for the technology). Each has its own benefits and drawbacks for different types of exchange use cases.
ZK rollups abstract all transactions away from the underlying blockchain using zero knowledge cryptography such as Snarks or Starks. Each transaction is submitted to a Merkle tree and then a zero knowledge proof is perioidcally generated and sent to a smart contract for verification.
This proof is submitted periodically to the Ethereum blockchain, meaning that thousands of individual transactions can be submitted in just one main ‘batch’ or proof. This enables thousands of transactions per second (tps) to be processed whilst at the same time ensuring the strictest of security guarantees.
In the case of Optimistic rollups, a network of verifiers is needed to ensure the validity of each transaction that happens on layer 2. Instead of a smart contract checking the validity of transactions, the network of validators can challenge the operator in what is known as a challenge period.
This challenge period may need to stretch for several days or weeks to ensure that enough validators are able to check enough of the network for ‘cheating’.
In the event that the operator of either the ZK rollup or the Optimistic rollup is found to have cheated the system, the state of all participants’ balances is rolled back to the last stable state. In the case of a ZK rollup, this would be the point at which the last batch/proof was submitted and would likely be a few hours previous.
In the case of Optimistic rollups, the period that the trader’s balance is rolled back could be much greater. Importantly, all participants can retrieve their funds back to the main Ethereum chain, but may have suffered some opportunity cost due to the lost time period where the operator was proven to have cheated.
ZK rollups vs Optimistic rollups: The pros and cons
Ok, so we’ve established that although zero knowledge and optimistic rollups work slightly differently, both have strong security guarantees and participants tokens & funds are safe. But what are the advantages and tradeoffs between each?
Put simply, ZK rollup projects are suited for high-performance specific use cases, where high transactions per second and fast finality is needed.
Optimistic rollups, on the other hand, take the edge in terms of composability and openness, as they are able to support an Ethereum Virtual Machine environment (or similar) much more easily via their Optimistic Virtual Environment, meaning that projects can copy and paste their existing smart contracts into the environment without having to make any complex code changes.
Here is a handy graphic to summarise the distinction between the two types.