What Are Layer 2 Platforms? And How Do They Work?

What Are Layer 2 Platforms? And How Do They Work?

Layer 2 solutions; the future of scaling blockchain technology.

Ever since December 2017, the shortcomings of the Ethereum network have been acutely clear to users and developers. The launch of Crypto Kitties, a stunningly (if briefly) popular blockchain game, saw players rush to breed collectible digital cats. This had the effect of swamping the network with transactions, driving up gas fees and confirmation times. In fact, the Ethereum network was backed up for days.

This was just the first of many episodes of congestion for Ethereum. The network is a victim of its own success. It can handle around 15-30 transactions per second, depending on their complexity. More than that, and users have to start paying more to ensure their transactions are confirmed in a timely manner, or else waiting indefinitely. At the time of writing, the memecoin trading craze has pushed gas costs up to between 50 and 200 gwei for much of the last month, meaning that a simple token transfer can easily cost $10-20, and a swap on a DEX as much as $50-100.

Scaling Ethereum

Over the last five years, many different approaches have been deployed to increase the capacity of the Ethereum network. The ‘holy grail’ of scaling is a solution that enables higher throughput, while maintaining both security and decentralisation. However, this is a hard problem to solve – the so-called ‘scaling trilemma’ – and many blockchain platforms end up sacrificing one or other of these three properties. (For example, Bitcoin is secure and decentralised, but slow; Solana is fast, but relatively centralised.)

‘Layer 2’ is the name given to these scaling solutions, because they are built on top of the Layer 1 foundation of Ethereum mainnet. While ‘true’ Layer 2 solutions are secured by Ethereum mainnet itself, the lines between L2s and other scaling solutions are blurred. We’ll look at four of the most popular approaches: State Channels, Sidechains, Optimistic Rollups, and ZK Rollups.

State Channels

State channels enable users to transact off-chain, minimising interaction with mainnet by only using it to open and close channels. A channel is a simple protocol that allows two parties to make many transactions, posting only the final result to the blockchain. A multi-sig smart contract is used to make sure the collection of transactions is signed by the relevant parties, and cryptography is used to prove that the summary they post to mainnet really is the result of a set of valid transactions.

Ethereum Raiden uses state channels to help scale the network. However, state channels can be inflexible, and have certain potential vulnerabilities and limitations that makes them unsuitable for many applications.

Sidechains

Sidechains are another popular scaling solution that enable a wide range of applications and high throughput. Sidechains rely on a dedicated set of validating nodes, separate to the nodes that secure mainnet. These nodes process transactions, bundle them, and pass them to mainnet. Plasma chains or ‘child chains’ use this approach to run what are effectively smaller copies of Ethereum mainnet, and are anchored to mainnet but use their own networks and consensus mechanisms for validating blocks of transactions.

TimeX is a Plasma-based cryptocurrency exchange which uses a combination of both centralised and decentralised technologies to provide a hybrid platform that offers the best of both worlds, combining speed, security, privacy, and convenience. Gnosis Chain, formerly known as xDai, is another sidechain project, and is maintained by a set of trusted validators, enabling high transaction throughput and low fees.

One of the best-known sidechain solutions is Polygon, previously known as the Matic network. Polygon started out as a proof-of-stake chain, but has been building towards becoming a “true” Layer 2 platform that derives its security primarily from Ethereum mainnet, using Optimistic and ZK rollups (see further below). Polygon became a very popular scaling solution in 2021, attracting a large number of dApps and companies, who were attracted by the prospect of a thriving blockchain ecosystem but low fees. LaborX, Chrono.tech’s freelancer marketplace, supports numerous tokens hosted on Polygon, as well as Ethereum mainnet and Binance Smart Chain, making it economical to take on smaller jobs without having pay swallowed up by high gas fees.

Similarly, TimeX has implemented support for Ronin, the sidechain for the Axie Infinity ecosystem. This allows native transfers of the SLP token between the game and the exchange, without the costs and delays entailed by sending funds via mainnet.

Another major technology, which dominates the current scaling narrative, is rollups. These combine, or roll up, batches of transactions, and submit them to mainnet together – thereby reducing the load on the network, as well as enabling dramatically lower fees for users. Posting the ‘rolls’ of transactions to Ethereum L1 provides finality: that is, the transactions cannot be altered.

Rollups broadly come in two forms: Optimistic, and ZK rollups.

Optimistic Rollups

The first form of rollups to be implemented as an Ethereum scaling solution is Optimistic rollups. They are called ‘optimistic’ because they optimistically assume that transactions are valid, unless proved otherwise.

This allows a large number of transactions to be processed together, bundled (or rolled up), and submitted together to mainnet. However, this is where the drawbacks of optimistic rollups become apparent. Transactions within the Layer 2 rollups solution can be fast, but when withdrawals are made to Ethereum L1, there is a delay to provide a window within which fraud proofs can be submitted. While optimistic rollups are easier to implement than some other solutions, this lengthy withdrawal process means they are less user-friendly. (Alternatively, separate bridges can be used to move funds between the rollup and mainnet, but these make trade-offs involving speed, centralisation and security too.)

Two of the leading optimistic rollups-based L2 platforms are Optimism and Arbitrum. Optimism allows hundreds of transactions to be secured by a single mainnet transaction, meaning they can share gas costs between them, whilst still being paid in ETH. Optimism secures over $1.75 billion in value.

Arbitrum (powered by the native ARB token) also uses optimistic rollups, but takes a different approach to Optimism in certain key areas. While Optimism uses single-round, on-chain fraud proofs, Arbitrum uses multi-round, off-chain fraud proofs, which are cheaper and more efficient, but can take longer. Arbitrum has gained greater traction than Optimism, with around $5.7 billion in TVL: two thirds of total value locked across all L2s, and three times more than Optimism.

The other major difference is that Arbitrum has its own Arbitrum Virtual Machine (AVM), which supports all EVM programming languages (including Solidity, Vyper, Flint, and others). Optimism, which uses the Ethereum Virtual Machine, supports only Solidity. However, these differences will be irrelevant to most end users.

ZK-Rollups

The second major category of rollups are ZK rollups. They are based on zero-knowledge proofs: a form of cryptography that enables you to prove you know something, without leaking any sensitive information about what it is you know. (Imagine someone finds your phone in a bar. You hide the screen from them and enter the unlock code, then show them the unlocked phone – proving it’s yours without revealing the pin. That’s a kind of simple zero-knowledge proof.)

ZK rollups use these cryptographic proofs to ensure that the bundles of transactions being posted to mainnet are truly valid. Unlike optimistic rollups, there’s no need to check them and leave a lengthy window for fraud proofs to be submitted. In theory, then, ZK rollups enable the creation of L2 solutions with greater security, efficiency, and privacy than optimistic rollups – allowing high transaction volumes with low latency, while still securing everything with L1.

Unfortunately, things aren’t quite as simple as that, because ZK rollups are markedly more complex to work with than optimistic rollups, so building comprehensive solutions with them is a considerable engineering challenge. It’s harder, and more expensive, to implement a fully-functional ZK rollup-based L2 that can do everything that Optimism or Arbitrum can do.

While ZK rollups are an extremely promising technology and there’s a lot of buzz around them, it’s only recently that the first full EVM ZK L2s have been launched in beta. Up to this point, partial solutions have been released. For example, Loopring offers an AMM and token transactions, but not wider EVM functionality.

Meanwhile, StarkWare has built two platforms, the permissionless StarkNet and permissioned StarkEx, both based on a type of ZK rollup called STARKs. dYdX, a decentralized exchange dApp, and Immutable X, a scaling solution geared towards NFTs and games, use StarkEx.

Polygon has committed to broadening its platform with ZK rollups, and Scroll and zkSync are also working on full zkEVM L2s. These will be versatile enough to run any Ethereum smart contract. SKALE, a hybrid L1/L2 project that is secured by Ethereum mainnet but uses a separate set of validator nodes to increase throughput and privacy, is also incorporating ZK technology.

The Long-Term Role Of L2 Solutions

L2 solutions were once discussed as a stopgap, while developers worked on scaling Ethereum mainnet. However, in practice they will always be needed, even when Ethereum’s full roadmap is complete.

Ethereum Upgrades (previously known as Ethereum 2.0) is the name given to the set of enhancements progressively being rolled out on the network. The Merge, which saw Ethereum switch from proof-of-work to proof-of-stake last September, was the first major stage in this process. Ultimately, the goal is to implement something called Danksharding, which will significantly increase mainnet’s capacity. (This replaces the initial plan for sharding, which would have split the blockchain into many subchains, processing transactions in parallel.)

In the short term, Proto-Danksharding will make it cheaper for rollups to add data to blocks, using ‘data blobs’ that contain data that is only required for a short time, and can be deleted after 1-3 months rather than stored on-chain forever.

Further down the line, full Danksharding will increase the number of blobs attached to blocks. As the Ethereum Foundation website explains, ‘Danksharding will bring massive amounts of space on Ethereum for rollups to dump their compressed transaction data. This means Ethereum will be able to support hundreds of individual rollups with ease and make millions of transactions per second a reality.’

While Danksharding is still several years away, Proto-Danksharding will be a reality relatively soon, giving existing rollup-based solutions – and Ethereum as a whole – a huge capacity boost.

All of this means that Ethereum will very much rely on rollups in the future, something reflected in Vitalik Buterin’s 2020 post titled A rollup-centric ethereum roadmap (even if plenty has changed over the last three years).

Scaling Solution Summary:

  • State channels allow large volumes of transactions to occur off-chain. While they keep interaction with L1 to a minimum, they are ultimately secured by L1. However, they are inflexible and not suited to more complex applications.
  • Sidechains enable a high degree of throughput, but are maintained by their own networks of validators, which need to be trusted; they are as secure as that network allows.
  • Rollups bundle large numbers of transactions together and post proofs to L1, meaning that they derive their security from Ethereum mainnet. They come in two main forms:
    • Optimistic rollups are relatively easy to implement, but require lengthy withdrawal periods to give time for fraud proof to be submitted.
    • ZK rollups offer the possibility of faster and more efficient L2 solutions, without the same withdrawal delays as optimistic rollups, but are harder to work with, meaning full ZK-EVM solutions are still in development and testing phases.
  • Danksharding is the ultimate aim for Ethereum’s scaling roadmap. This will dramatically enhance the network’s capacity by making it cheaper for rollups to post data to the blockchain – allowing Ethereum to process millions of transactions per second.

Chrono.tech has always been at the forefront of adopting scaling solutions, already leveraging these in its HR products. TimeX uses a Plasma chain, LaborX supports Polygon for digital work agreements and payments, and the TIME token is available on three different networks, including Polygon.