ZK Rollup
ZK Rollup¶
You should already have some understanding of Ethereum scaling solutions and Layer 2.
Zero-Knowledge Rollup (ZK Rollup) is a Layer 2 scaling solution that moves computation and state off-chain and uses zero-knowledge proofs to prove the validity of off-chain transactions on-chain.
ZK-rollups execute transactions off the main network but periodically submit off-chain transaction batches to an on-chain rollup contract. This transaction record is immutable, just like the Ethereum blockchain, and the off-chain transactions also form the ZK-rollup chain.
ZK-rollups primarily consist of on-chain contracts and an off-chain virtual machine (VM).
On-chain Contracts: The ZK-rollup protocol is controlled by smart contracts running on Ethereum. These include the main contract that stores rollup blocks, tracks deposits, and monitors state updates, and the verifier contract that verifies zero-knowledge proofs submitted by block producers. Therefore, Ethereum serves as the base layer or "Layer 1" for ZK-rollups.
Off-chain Virtual Machine (VM): Although the ZK-rollup protocol exists on Ethereum, transaction execution and state storage occur on a separate virtual machine independent of the EVM. This off-chain VM is the execution environment for transactions on the ZK-rollup and serves as the second layer or "Layer 2" of the ZK-rollup protocol. Validity proofs verified on the Ethereum main network guarantee the correctness of state transitions in the off-chain VM.
ZK Rollup Operating Mechanism¶
- Transaction Batch Processing
Collecting Transactions: The ZK-Rollup sequencer collects multiple transactions submitted by users and batches them together. The transactions in this batch are processed off-chain, including transfers, smart contract calls, and other operations.
Off-chain Processing: Off-chain, all transaction state changes are computed and recorded. These changes include account balance updates, smart contract state modifications, and more.
- Generating Zero-Knowledge Proofs
ZK-Rollups typically use ZK-SNARK or ZK-STARK technology to generate a proof that proves the validity and correctness of this batch of transactions.
-
Submitting Proofs to the Main Chain
-
Submitting Batches and Proofs: The ZK-Rollup submits zero-knowledge proofs for the batch of transactions to the Ethereum main chain. Each proof contains proofs of all state changes for transactions in that batch.
-
Updating State Root: The ZK-Rollup also submits a new state root, which is a hash of the global state after all transactions have been processed.
-
On-chain Verification
-
Verifying Zero-Knowledge Proofs: Smart contracts on the Ethereum main chain verify the submitted zero-knowledge proofs. If the proof is valid, it indicates that all off-chain transactions have been correctly executed and have not been tampered with.
- State Update: If the proof is valid, the main chain updates the state root, meaning the main chain acknowledges the results of these off-chain transactions.
ZK-Rollups, by combining off-chain computation and on-chain verification, provide an efficient and secure scaling solution for the Ethereum network, significantly improving transaction processing capability and user experience.