What are rollups?
Imagine a situation when we’re using the postal service and we're trying to send multiple packages to one sender. We can pack each package separately, stick a label on it and send it. However, this will be a solution where we pay multiple times to deliver something to one place. What if we use a larger box and send it at the price of a larger shipment already as one package? It will very likely be a cheaper solution. This is exactly how rollups work. On the solution next to L1 (layer 1), we recalculate all transactions, and finally, only the result of these transactions lands on the main network in one package.
Thanks to this solution we can save on commission fees because on the main network we pay only for one transaction and not for a larger number that was made outside L1. Technically, this solution consists of two functions on the network: deposit (locking the funds) and withdrawal (unlocking the funds), which we use on layer 2. Transactions and conversions can be done off-chain or on the side chain.
Optimistic rollups
This approach assumes that all data that appears on the network is correct. Verification is done by providing proof of fraud. This can happen at any time and can be reported by any user at any moment. A user caught trying to falsify data is penalized by the protocol and therefore every user, before using the network, must block his/her funds on the given protocol. When evidence of fraud is reported, the rollup enters dispute resolution trim. This is a function that checks if the report is correct and if there was an attempt to falsify data. The transaction is then simulated on the main network. The transaction stays if everything is ok, however, if there is no match and errors occur, then restoration is performed and the user who made the mistake is penalized.
Due to the way the network works and the selective checking of transactions (by users' requests) the blocked funds are unavailable for a long time during withdrawal. The same is true for deposits to the protocol. This is because the network needs time to provide potential evidence of fraud.
Examples of solutions:
- Arbitrum One - https://arbitrum.io/
- Optimism - https://www.optimism.io/
- Boba Network - https://boba.network/
Zero-knowledge rollups.
To fully understand the idea, we need to know what is zero-knowledge proof. A zero-knowledge proof is a cryptographic procedure in which one party can prove to the other that they have some information, without revealing it. Example: we have caves. Between points C and D there is a secret passage, which is opened with a secret password. Person Joe knows this password and wants to convince person Tom of it, without revealing the password. He, therefore, carries out the following experiment: Tom stands at point A, while Joe enters the cave, reaching one of the points C or D. Once Joe is in the cave, Tom moves to point B and instructs Joe to exit either through the left or right corridor. Since Joe knows the password that opens the secret passage, he has no trouble following Tom's instructions. The procedure is repeated several times.
In this type of rollup, we don't need the assumption that every transaction is correct. Whether a transaction is correct, we can prove it when dropping data into the main network. All calculations are done outside the main network and only the results are uploaded there. This is called validity proof.
Cryptocurrency mining works similarly. We review all transactions, and when everything is ok, we pack it into a package and upload it to the network.
The disadvantage of this solution is the compatibility problem of the Ethereum Virtual Machine (EVM). Performing all calculations, compared to the previous solution is not so easy. To fully understand the idea, I recommend reading the zero-knowledge proof (https://en.wikipedia.org/wiki/Zero-knowledge_proof)
Examples of solutions:
- dYdX - https://dydx.exchange/
- Loopring - https://loopring.org/
- zkSync - https://zksync.io/
- ZKSpace - https://zks.org/
Sources:
https://ethereum.org/en/developers/docs/scaling/optimistic-rollups/
https://ethereum.org/en/developers/docs/scaling/zk-rollups/
https://developer.offchainlabs.com/docs/inside_arbitrum
https://docs.zksync.io/userdocs/