Rollups work by bundling transactions together into a single transaction, that can be processed off-chain. This means that there is less demand on the main chain for each individual transaction to be processed. This results in less expensive transactions, more transactions per second, and reduced confirmation times.
The result is then recorded on the main chain, and cannot be disputed. The main chain is the one that everyone trusts because it has the most economic value, and is agreed upon by all users.
There are mainly two types of rollups:
1. Optimistic Rollups
2. ZK Rollups
Let's understand them one by one :)
Optimistic rollup (OR) is an Ethereum layer 2 scaling solution that transfers the computation process of smart contracts to a separate blockchain and then sends only the inputs and outputs to the main Ethereum chain.
Optimistic Rollups work as follows:
1. A smart contract on Ethereum would trigger a call to a separate smart contract, called an aggregator, on another sidechain.
2. This aggregator receives transactions from users through a relayer. The relay service submits batches of transactions to the validators on this sidechain, who combine all transactions into a batch and execute them in one block .
3. After the execution is complete, they submit only transaction hashes back to the main Ethereum chain. Users can then verify if their transactions were included in this batch and challenge invalid ones.
Optimistic rollups uses fraud proofs
Optimistic rollup allows for instant scalability by executing thousands of transactions per second off-chain; it reduces gas fees for users by significantly lowering Ethereum network load and it supports any type of smart contract logic that’s compatible with Ethereum Virtual Machine.
One drawback to optimistic rollups is that they require all users in each batch of transactions to submit them at once and wait until they have been processed before they can move on with their next actions.
ZK Rollups are a type of rollup that uses advanced “Zero-Knowledge Proof” technology to address the privacy and scalability issues plaguing regular rollups. While most rollups work by sending data on-chain, ZK Rollups keep most operations off-chain, which makes them more private and cheaper.
In a blockchain using a ZK rollup, the original transaction is replaced with a new one. This new transaction will include information that allows it to prove that the original transaction was valid. It does this by having a trusted party generate zero-knowledge proofs for each input in an order hash tree (OHT).
This means that instead of having all transactions included in every block, only one transaction needs to be included per account per block. Each input will have its own OHT which can then be verified by anyone while still keeping their privacy intact because they don't need to see what each individual's balance or transactions are - just whether they add up correctly!
You can learn more about types of zk rollups here.
We've learned a lot about the two broad types of layer 2 scaling solutions: Optimistic and ZK. Now it's time to address the question on everyone's mind: which one is better? The clear answer here is that it depends on what your perspective is. If you're someone who wants to keep everything on-chain, then only an optimistic rollup will do. If you're someone who doesn't care where the computation happens as long as it's fast, then you'll probably prefer a ZK rollup.
In the next and last part we will understand more about plasma and validium.