Optimistic Rollup 与 ZK Rollup
比较 Optimistic Rollup 和零知识 Rollup,探索它们的机制与权衡。
Optimistic Rollup 与 ZK Rollup 是 CoddyKit 上的免费 Blockchain Smart Contracts with Solidity 课时。 这是第 2 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Blockchain Smart Contracts with Solidity 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Blockchain Smart Contracts with Solidity 课程共包含 4 节课。
本课时的部分内容尚未翻译,以英文显示。
Welcome to Rollups Deep Dive
In the previous lesson, we explored Layer 2 solutions for scaling blockchains. Today, we'll dive deeper into the two most prominent types of rollups: Optimistic Rollups and Zero-Knowledge (ZK) Rollups.
These technologies are crucial for making decentralized applications faster and cheaper to use.
What are Optimistic Rollups?
Optimistic Rollups operate on the assumption that all transactions processed off-chain are valid. They 'optimistically' believe everything is correct, without immediate cryptographic proof.
- Transactions are bundled together off-chain.
- A summary (state root) is posted to the Layer 1 (L1) blockchain.
- This reduces L1 congestion and transaction costs significantly.
Fraud Proofs & Challenge Period
Since Optimistic Rollups don't verify transactions immediately, they rely on a challenge period. During this time (typically 7 days), anyone can submit a fraud proof if they detect an invalid transaction.
If fraud is proven, the invalid transaction is reverted, and the party responsible for the fraud is penalized.
Optimistic Withdrawal Delays
The challenge period creates a necessary delay for withdrawals. If you want to move assets from an Optimistic Rollup back to Layer 1, you must wait until the challenge period expires.
This ensures there's enough time for any potential fraud to be detected and proven, securing your funds.
Optimistic Rollups: Pros & Cons
Here's a quick look at the advantages and disadvantages:
- Pros: Generally simpler to implement, highly compatible with the Ethereum Virtual Machine (EVM), allowing easy migration of existing dApps.
- Cons: Long withdrawal delays (due to challenge period), requires active monitoring for fraud (though usually handled by network participants).
What are ZK-Rollups?
Zero-Knowledge (ZK) Rollups take a different approach. Instead of assuming validity, they use advanced cryptography to prove that transactions are valid before posting them to L1.
They generate a concise cryptographic proof (a 'validity proof') for a batch of off-chain transactions.
Validity Proofs in Action
When a ZK-Rollup processes transactions off-chain, it creates a special mathematical proof (like a ZK-SNARK or ZK-STARK). This proof confirms the correctness of all transactions in the batch without revealing any underlying data.
This proof is then submitted to L1, where it's instantly verified by a smart contract. If the proof is valid, the transactions are confirmed.
ZK-Rollups: Pros & Cons
Let's weigh the benefits and drawbacks of ZK-Rollups:
- Pros: Instant finality (no withdrawal delay), stronger security guarantees (mathematically proven validity), potential for privacy features.
- Cons: Extremely complex to build and maintain, high computational cost for generating proofs, historically less EVM-compatible (though ZK-EVMs are changing this).
Key Differences at a Glance
Here's a summary of the core distinctions between the two rollup types:
- Verification: Optimistic uses fraud proofs (after the fact); ZK uses validity proofs (before the fact).
- Withdrawals: Optimistic has a challenge period delay; ZK has immediate withdrawals.
- Security: Optimistic relies on economic incentives and active monitoring; ZK relies on cryptographic certainty.
Choosing the Right Rollup
Both Optimistic and ZK Rollups offer significant scaling benefits, but their trade-offs make them suitable for different use cases:
- Optimistic: Great for general-purpose dApps that benefit from EVM compatibility and can tolerate withdrawal delays.
- ZK-Rollups: Ideal for applications requiring instant finality, high security, and potentially privacy, often at a higher development cost.
Test Your Knowledge!
Based on what you've learned, which statements correctly describe a key characteristic of either Optimistic or ZK Rollups?
Recap: Rollups Compared
We've explored the core differences between Optimistic and ZK Rollups. Optimistic Rollups assume validity and use fraud proofs with a challenge period, leading to withdrawal delays. ZK-Rollups use cryptographic validity proofs for instant verification and faster withdrawals.
Both are vital for scaling Ethereum, offering different balances of security, speed, and complexity for various decentralized applications.
常见问题解答
「Optimistic Rollup 与 ZK Rollup」课时是免费的吗?
是的 — 「Optimistic Rollup 与 ZK Rollup」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Blockchain Smart Contracts with Solidity 课程的其余内容,请升级到 CoddyKit PRO。 Blockchain Smart Contracts with Solidity 课程共包含 4 节课。
「Optimistic Rollup 与 ZK Rollup」这节课中我会学到什么?
比较 Optimistic Rollup 和零知识 Rollup,探索它们的机制与权衡。 你通过在浏览器中直接运行的动手代码来练习 Blockchain Smart Contracts with Solidity,全天候 AI 导师会在你学习这节课的过程中回答你的问题。
学习 Blockchain Smart Contracts with Solidity 需要有经验吗?
无需任何先前经验。CoddyKit 上的 Blockchain Smart Contracts with Solidity 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 2 节课,共 4 节。
「Optimistic Rollup 与 ZK Rollup」课时需要多长时间?
大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。
我能在这节 Blockchain Smart Contracts with Solidity 课中编写并运行代码吗?
能。每节 Blockchain Smart Contracts with Solidity 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。
此课程中的所有课时
- L2 扩容方案简介
- Optimistic Rollup 与 ZK Rollup
- 跨链通信与桥接
- 数据可用性与 Validium