Blockchain
-
March 8, 2022

How to use Rollups with Ethereum 2.0

As blockchain developers may know, two big obstacles to using Ethereum are its price and speed. In addition to cost and latency issues, the NFT community isn't exactly thrilled to be paying 300 USD dollars per transaction when buying or swapping tokens.

There are currently a lot of alternatives, and platforms, to Ethereum that accept its Ethereum Virtual Machine (EVP) such as Avalanche, xDAI, RSK, as well as inclusive protocols like Polygon. There are also layer1 blockchains that can replace Ethereum such as Polkadot, and Solana.

Communication between smart contracts is not straightforward in all blockchains. As an alternative to Ethereum, using Rollups with Ethereum 2.0 is a nifty way to improve speed and lower transaction fees.

In this article, we will:

  • Explain Rollups
  • Breakdown Optimism Rollups
  • Breakdown Zero-Knowledge Rollups (Z-K Rollups)
  • Look at the technology behind Optimism Rollups
  • Look at the technology behind Zero-Knowledge Rollups
Come join us

Interested in working with blockchain technologies? We're hiring!

Rollups explained

Rollups is a collective term used to describe solutions that help scale transactions into Ethereum. A Rollup executes transactions outside of the main Ethereum chain i.e. layer 1, while also remaining secure in it by posting transaction data onto layer 1.

There are 3 properties associated with Rollups: 

  1. All transactions are processed in layer 1. 
  2. Transactions are executed out of the Mainnet (Ethereum production blockchain).  
  3. Smart contracts are executed using layer 1 data within layer 2.

Overall, there are two rollups types that exist within security models, Optimism Rollups and Zero-knowledge Rollups.

Optimism Rollups

Operating as a Layer 2 Optimistic Rollup network, Optimism was specifically designed to reduce the aforementioned cost and latency issues for Ethereum users, while also maintaining the robust security guarantees of the network.

Just like its name, commitments on the networks are optimistically accepted while also being validated for errors and security issues. If validators find a potential issue with a commitment, they submit fraud proofs, which work to keep the network and commitments secure.

These fraud proofs can reject a transaction if it appears suspicious. Then, PoF (Proof-of-Formulation) will execute the transaction to see if it is fraudulent. This method increases the number of transactions possible while also providing strong security. 

Optimism Rollup example

'Unipig' is a proof of concept application that was created by Uniswap. It was demonstrated at Devcon5 and can be tried and tested here for free.

Zero-knowledge Rollups (ZK-Rollups)

ZK-Rollups have been described as a “layer 2 construction that increases scalability through mass transfer processing rolled into a single transaction".

They were designed to decrease the amount of data used in transactions by combining on and off-chain processes that effectively reduce storage and computer resources typically needed to validate blocks.

ZK-Rollups provide a “Proof of validity” (POV) to the chain. A PoV is a way to increase the speed of transactions, which is the same method as Optimism Rollup, but the calculation makes out of the chain and is sent to the Mainnet (Ethereum) with PoV.

This method increases the number of transactions while secured in Layer 1.

ZK-Rollup example

A useful example of a live zero-knowledge rollup is zkSync, which is currently running on the Ethereum mainnet.

Technology behind Optimism Rollups

With Optimism, smart contracts can be separated into a number of key components.  

Chain: Smart contracts in layer 1 that contain the transactions order and the commitments with the state root in layer 2. 

Verification: Smart contracts in layer 1 make the process to get the result of one transaction. 

Bridge: Smart contracts that make it easier to message steps between layer 1 and layer 2. 

Implementation: A smart contract set that implements and is available in the genesis system. These contracts are similar to the pre-compiles of Ethereum, are written in solidity, and can be found in an address that starts in 0x42. 

The Optimism technology blocks production that is managed for the “sequencer”. It provides instant transaction confirmation, state updates, builds, and execution of blocks in layer 2, and sends transactions of users to layer 1. 

If there is a disadvantage to this, it's having to wait a week to complete a transaction as it needs to make a PoF, and if the transaction is rejected within the 7 days, it means that Optimism cannot process the transaction. If completed within 7 days, it is then good for processing.

Technology behind ZK-Rollups

With ZK Rollups, you make transactions out of the chain accompanied by a cryptography test. This test can come in SNARK format (succinct non-interactive argument of knowledge), or STARKs (scalable transparent argument of knowledge).

ZK-Rollups have better knowledge than PoV and are published in layer 1. The smart contract of ZK-Rollup keeps the state of the transactions in layer 2, and this just needs the PoV and not the transaction data.

And, with ZK-Rollup, validating a block is faster and lower because includes fewer data. In the image below, there is a greater difference in this data, regarding the size and time in these two Zero-Knowledge Rollups.

Proof size, prover time, and verification time
Source - Beanstalk

There are also some disadvantages with this Rollup, the first one is that some of these have no EVM support, and the second is that the PoV is intense of calculating because it tries to figure it out, or better yet, calculate the exact data that the transaction needs, and then customize it. For example, reducing  bytes32 to bytes4. 

We can see the difference between SNARKs and STARKs in the following table: 

Table highlighting the difference between SNARKs and STARKs
Source - Matter Labs

Something interesting about the two Rollups is that the protocol and framework Polygon (Matic) uses both by taking the better of each and applying with, and with other tools as well.

What to take away

In the battle for layer 2, there are many advanced solutions especially those EVM compatible, fighting to be the main solution for the blockchain community. They are doing this by providing faster and more cost-effective operations to execute in EVM.

With a perfect value available for both project types, it's likely best to not choose just one right now. In fact, the ecosystem can see more of these types, as well as the multi-chain functions between blockchains that accept EVM as layer 1 and layer 2 projects.

So, the blockchain developer community is the audience witnessing this technological tug of war and most likely more so for the best performing tech over price.

Are you a blockchain developer? Feel free to join the conversation in the comments below.