hypersign-protocol / whitepaper

2 stars 0 forks source link

Research on Zkrollups #8

Open Vishwas1 opened 2 years ago

AbhijitSinha1 commented 2 years ago

An Incomplete Guide to Rollups - By Vitalik Buterin

Introduction to zkRollup with Pros and Cons

Comparision of various layer 2 protocols on different parameters   Short intro to ZKRollup   DeFi explained: ZK Rollup

ZK Rollups Explained: Why they are the future of blockchain scalability & privacy

AbhijitSinha1 commented 2 years ago

Different ways to scale Ethereum main chain

Introduction

State channel, Plasma and Rollups are a way to scale up transactions on Ethereum blockcain. In this article we will build our understanding from ground up.

Problem

Currently Ethereum blockchain suffers from two big problems:

People are trying to come up with ways to solve these issues in differnt ways:

Solution

Convert to Proof of Stake

This approach requires changing the way the node validators come to concensus regarding the data on the blockchain.

The benefit of this solution is that while in proof of work algorithm, the concensus mechanism automatically tunes its difficulty level so that mining a block necessarily takes a fixed amount of time, proof of stake does not have that artificial time restiction. As long the validators have sufficiant amount of token staked in the network to go rouge, the mining process can be as quick as possible.

Increase the block size

This solution suggests increasing the block size so that more transaction data can be added to each block. This way number of transactions per block would increase and thereby increasing the throughput.

However, if the data in the block increases then it would be more difficult to validate all the transactions in the block. The increased computation power required to validate all the transactions in the block will mean only few validations will be capable of perfoming this. This would result in a more centralized network.

Change the way blockchain is used

Instead of putting all the transaction data in the blockchain, put them off chain in a "layer 2 protocol", and at regular intervals provide proof of the transactions to the main chain. For this, deploy a smart contract on the main chian. This smart contract has two functions:

State Channel

To increase the throughput of main chain the concept of state channel was developed. State channels help two parties who want to get into a long duration of rapid transactions. Say, a zero-sum-game between Alice and Bob where the outcome of each round needs to be saved to Blockchain. In this example, both Alice and Bob deposit some money (say $5 each, the pot now has $10) to the on-chain smart contract and then begin playing. At the end of each round, the outcome is signed by both parties and saved. The outcome message might contain the following information:

Whenever a party wants to exit the game, they submit the latest signed message to the on-chain smartcontract. The smartcontract verifies the signature and transfers the relavant amounts to each players account.

Say, at the end of round 10 Alice has won 6 times and Bob has won 4 times, while winning amount for each round was $0.5. So Alice should now get:

Correspondingly Bob should get the remaining $2 from the pot.

The final message submitted by Alice to the smartcontract might look something like this:

Once the smart contract has verified the signature it is ready to release the funds to both players. An important feature of State Channel now comes into play. The smart contract now goes into a time lock for a pre determined time. During this time, smart contract waits for Bob to submit a counter message.

Why: The smart contract doesn't know that there were only 10 rounds played between Alice and Bob. What if there were actually 15 rounds played between them and in the last 5 rounds, Bob managed to get all his money back and then some. The time lock is provided for Bob to submit another message which might look something like this:

Basically, the smart contract waits for Bob to produce another message (signed by both players) where the round number is higher than what Alice had submitted.

In this approach there are only 2 main chain transactions but the number of payments made between Alice and Bob is arbitrary. Also, the throughput depends on how fast the signed messages can be sent between them.

While this approach works great for payments between two parties, issues arise when one of the participants in the payment channel wants to send some funds to a third party not involved in the payment channel.

Another restrictions on channel is that there needs to be clear logical ownership rules for the assets under transaction. In case of payments it is clear who the token belongs to at each point during the transaction. However, for cases like uniswap, payment channel cannot be used since we don't have clear ownership of assets inn that case.

To do anything more complex than simple paymenet transfers, the participants require large captial.

Once the withdrawal is triggered there is a lock period during which all parties need to submit their signed message in order to figure out what is the final balance. This lock period slows down the overall throuput of the system.

Plasma

Plasma is similar to Payment channel in that the transactions are done off chain, however, unlike in payment channel where the records of each round is signed and sent across as messages, in Plasma the information of each round is submitted to a sub chain (Plasma chain).

Say Alice and Bob have accounts on main chain and want to get into a series of transactions, doing so on Plasma would be cost effective for them. For doing so, they lock their asset inn a Plasma smart contract and get equivalant amount of tokens in the Plasma chain.

In the Plasma chain they can now go for any number of transactions and enjoy lower gas fees and higher throughput. When they are done with all the transactions they can request for the tokens to be submitted to the Plasma chain and equivalent amount be depositted to their account on main chain.

This solves some of the problems that Channels have. Now any number of parties can be included in the transaction at any point. There doesn't need to be a clear logical owner for an asset.

However, Plasma still couldn't solve the issue of lock period. If Alice wants to withdraw from the Plasma chain, she still needs to waits for a lock period.

Rollup

Rollup is built on the ideas of Plasma and solves the lock period issue. It consists of the Main chain where a Rollup contract is deployed. This smart contract contains a state variable which stores the value of the merkel root hash of the latest batch.

A batch primarily contains 3 things

Since anyone from the rollup chain can submit the batch, to verify if the batch is correct, both Optimistic Rollup and ZK Rollup solve this problem in a slighly different way.

There are however some ways to select who can submit batches on the rollup chain.

Summary

There is a lot of interest in solving the Scalability and Gas price problem in Ethereum. People have come up with various approaches over time. Each solution tries to solve some unsolved problem from the previous solution and so the solutions has also kept evolving. We started with State Channel, evolved to Plasma and now we are at Rollup, where we have two different flavors, Optimistic Rollup and ZK Rollup.

Each concept in itself is slightly more complicated and more interesting from the previous one. It is an interesting area to keep an eye on since the final solution to the scalability might still be out there.