zkRollups
Each transaction on Ethereum consists of bytes, which are priced in gas. Ethereum constructs transactions in blocks which are capped by gas, thus each block can only house a certain amount of information (data). It follows that transaction costs are exponentially increasing with demand for blockspace - this has led to negative network effects. The solution to this problem is moving computation away from the L1 and onto L2 networks, known as rollups.
Rollups are separate blockchains that sit atop the L1. There are two types of rollups, zk-rollups and optimistic rollups and they perform the same functions – batching of transactions, performing computation off chain, and publishing the new state to the L1. The use of rollups takes computational load away from the L1 - the L1 functions more as a verification and settlement layer.
Importantly, the two types of rollup solutions differ in their approach to data validation, that is to say how they prove to the L1 that the computation performed is valid. Optimistic rollups post the new state to the L1 and it is optimistically assumed that the computation was done correctly. There is a dispute period that follows in which anyone can publish a fraud proof claiming a particular transaction is invalid. On the other hand, zk-rollups publish a zk-SNARK proof that the off-chain computation performed is valid and thus, the new state is correct.
The lifecycle of a rollup transaction is as follows:
- Deposit: Users deposit their assets into the zk-rollup smart contract on the L1.
- Aggregation: Sequencers receive and aggregate individual transactions from users, batching them together in a specific order.
- Proof Generation: Provers generate a ZKP that attests to the validity of the batch.
- Verification: Validators verify the ZKP submitted by the provers.
- On-Chain Commitment: Once verified, the proof and the new state root are committed to the L1 through the zk-rollup smart contract.
“In the medium to long term, zk-rollups will win out in all use cases as zk-SNARK technology improves” – Vitalik Buterin.
A zk-rollups architecture is made up of the following components:
- On-Chain contracts: The zk-rollup is controlled by smart contracts on Ethereum, this includes the main contract and the verifier contract. The main contract houses rollup blocks, tracks deposits, and monitors state updates. The verifier contract verifies the ZKPs.
- Off-Chain VM: Transaction execution and state storage happen on a separate VM, this VM serves as the execution environment and validity proofs verify the correctness of the state transitions in the off-chain VM.