0
0
Blockchain / Solidityprogramming~10 mins

Rollups (Optimistic vs ZK) in Blockchain / Solidity - Visual Side-by-Side Comparison

Choose your learning style9 modes available
Concept Flow - Rollups (Optimistic vs ZK)
User sends transaction
Rollup collects transactions
Optimistic Rollup: Assumes valid
Publish batch on main chain
Challenge period starts
If fraud proof submitted
Revert batch
Correct batch
If no fraud, batch final
ZK Rollup: Generate proof
Publish batch + ZK proof on main chain
Main chain verifies proof instantly
Batch final immediately
User transactions are collected by rollups. Optimistic rollups assume batches are valid and wait for challenges, while ZK rollups generate cryptographic proofs that are verified instantly on the main chain.
Execution Sample
Blockchain / Solidity
function optimisticRollup(batch) {
  publishBatch(batch);
  waitChallengePeriod();
  if (fraudProofSubmitted()) {
    revertBatch();
  } else {
    finalizeBatch();
  }
}

function zkRollup(batch) {
  const proof = generateZKProof(batch);
  publishBatchWithProof(batch, proof);
  verifyProofOnChain(proof);
  finalizeBatch();
}
Shows simplified functions for optimistic and ZK rollups handling batches of transactions.
Execution Table
StepRollup TypeActionConditionResult
1OptimisticPublish batch on main chainAssumes validBatch accepted, challenge period starts
2OptimisticWait for challenge periodChallenge period ongoingNo immediate finalization
3OptimisticCheck for fraud proofFraud proof submitted?If yes, revert batch
4OptimisticFinalize batchNo fraud proofBatch finalized
5ZKGenerate ZK proofBatch readyProof created
6ZKPublish batch + proofProof generatedBatch and proof on main chain
7ZKVerify proof on chainProof valid?If yes, batch finalized immediately
8ZKFinalize batchProof verifiedBatch finalized instantly
💡 Optimistic rollup waits for challenge period; ZK rollup finalizes immediately after proof verification.
Variable Tracker
VariableStartAfter Step 1After Step 3After Step 4After Step 5After Step 7Final
batchStatuspendingpublishedreverted or publishedfinalized or revertedproofGeneratedproofVerifiedfinalized
challengePeriodnot startedstartedongoing or endedendedn/an/an/a
proofnonenonenonenonecreatedverifiedverified
Key Moments - 3 Insights
Why does the optimistic rollup wait before finalizing the batch?
Because it assumes batches are valid but allows a challenge period for fraud proofs, as shown in execution_table rows 2 and 3.
How does the ZK rollup finalize batches instantly?
It generates a cryptographic proof that the main chain verifies immediately, so no waiting is needed, as seen in execution_table rows 5 to 8.
What happens if a fraud proof is submitted in an optimistic rollup?
The batch is reverted and corrected, preventing invalid state changes, as shown in execution_table row 3.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step does the optimistic rollup finalize the batch if no fraud proof is submitted?
AStep 2
BStep 3
CStep 4
DStep 1
💡 Hint
Check the 'Result' column for optimistic rollup finalization in row 4.
According to the variable tracker, what is the status of 'proof' after step 5?
Acreated
Bverified
Cnone
Dpending
💡 Hint
Look at the 'proof' row under 'After Step 5' in variable_tracker.
If a fraud proof is submitted during the optimistic rollup challenge period, what happens to the batch?
AIt is finalized immediately
BIt is reverted
CIt waits longer
DIt generates a ZK proof
💡 Hint
See execution_table row 3 under 'Result' for optimistic rollup.
Concept Snapshot
Rollups bundle many transactions off-chain to reduce main chain load.
Optimistic rollups assume batches are valid and wait for a challenge period to detect fraud.
ZK rollups generate cryptographic proofs that verify batch validity instantly.
Optimistic rollups have delay but simpler proofs; ZK rollups finalize faster but need complex proofs.
Both improve scalability but use different trust and verification methods.
Full Transcript
Rollups are methods to bundle many blockchain transactions off the main chain to improve speed and reduce costs. Optimistic rollups publish batches assuming they are valid and wait for a challenge period where anyone can submit fraud proofs to revert invalid batches. If no fraud proof appears, the batch finalizes. ZK rollups generate a zero-knowledge proof for each batch that the main chain verifies instantly, allowing immediate finalization without waiting. Variables like batchStatus and proof change as the rollup processes batches. Optimistic rollups have a delay due to the challenge period, while ZK rollups finalize faster but require generating and verifying complex proofs.