A Byte of Blockchain: Week 59 - Discovering Layer 2 Solutions (Roll-ups)

·

4 min read

A Byte of Blockchain: Week 59 - Discovering Layer 2 Solutions (Roll-ups)

Table of contents

Image by PublicDomainPictures from Pixabay

Recap

Last week we introduced Layer 2 solutions to the Blockchain Trilemma. Layer 2 Solutions involve an additional layer over the main Blockchain. They reduce stress on the main Blockchain by moving transactions & related computations from the main Blockchain to this layer, or in other words off-chain.

We started with State Channels which utilize side channels for updating states & processing transactions off the primary Blockchain. The logic is to move transactions off-chain with relevant controls in place to ensure the authenticity of transactions & then only book the summary of all the transactions in the main chain. The below visual summarizes the end-to-end process in a State Channel.

Let us now move to the next Layer 2 solution - Roll-ups

Roll-ups

Before we explore Roll-ups in the context of Layer 2 solutions, let us first understand what roll-up means. One of the definitions of roll-up is "to become larger by successive accumulations".

It means we accumulate something together till it becomes larger. The items accumulated are normally of the same type. For example - strings

Image by Ulrike Mai from Pixabay

A string is rolled up till it reaches a certain size. Then it is used for stitching. So, In any context, we need to aggregate or accumulate something and then do a specific action on that accumulated object.

In Layer 2 solutions, the object that is accumulated is transactions. Transactions are aggregated off-chain and then rolled up into a single proof. This single proof is then posted back to the main Blockchain. What does this mean?

Let us rewind to Week 46 where we discussed the components of a transaction. Visualizing a transaction in Ethereum as below:

In addition to the normal fields in a transaction, there is an additional data field that interacts with a smart contract to carry out a particular action based on the requirement. (For details, refer to Weeks 45 & 46).

So, the data field in a transaction can be used to interact with a smart contract to carry out a particular function. For example:

Imagine a smart contract with a balance of 500 ETH & the instruction is to transfer 250 ETH on a particular date to Y's address subject to X executing a transaction.

On that particular date, X executes the required transaction which updates the data field & is transmitted to the smart contract to identify whether X satisfied the condition.

With the condition satisfied & data field updated, the smart contract will transfer 250 ETH to Y's address, otherwise not.

Similarly, in roll-ups, there are also transactions & data. Only in this case, transactions are compressed & rolled up into one "batch" and that batch is turned into one single "data" which is then submitted to the main Blockchain.

The steps are :

  1. A smart contract related to the rolled-up transactions maintains a state root, which refers to the state of the transactions in the roll-up like balances, transaction details etc. This is the Merkle Root of all the transactions in the roll-up. (Refer visual below from week 24).

  2. A batch of transactions is published which contains the old state root (the state before the transactions are processed) & the new state root (the new state once the transactions will be processed).

  3. The smart contract checks the old state root of the batch matches the current state root of the transactions in the smart contract.

  4. If it does, the batch is processed & it updates the state root to the new state root.

Visualizing the above steps :

Before we go further, what are the controls in place for a batch to be processed in a rolled-up block? The issue here is anyone can submit a batch to be processed. What if a transaction is fraudulently included in a batch that illegally enriches the initiator of the batch?

Two solutions are being experimented with to ensure proper controls are in place when implementing Roll-ups. They are :

  1. Zero Knowledge Roll-ups &

  2. Optimistic Roll-ups

Let us dive deeper into roll-ups next week.