Bird
Raised Fist0
Blockchain / Solidityprogramming~20 mins

Rollups (Optimistic vs ZK) in Blockchain / Solidity - Practice Questions

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Rollup Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of Optimistic Rollup Fraud Proof Simulation
Consider the following simplified Python code simulating an optimistic rollup fraud proof check. What is the output when the code runs?
Blockchain / Solidity
def optimistic_rollup_check(state, new_state):
    # Fraud proof triggers if new_state is less than state
    if new_state < state:
        return "Fraud detected"
    else:
        return "State accepted"

print(optimistic_rollup_check(100, 90))
AState accepted
BFraud detected
CTypeError
DSyntaxError
Attempts:
2 left
💡 Hint
Think about the condition that triggers fraud detection in optimistic rollups.
🧠 Conceptual
intermediate
1:30remaining
Difference in Verification Time Between Rollups
Which statement correctly describes the verification time difference between Optimistic Rollups and ZK Rollups?
AOptimistic Rollups use zero-knowledge proofs for instant verification
BOptimistic Rollups verify transactions instantly, ZK Rollups delay verification
CBoth rollups verify transactions instantly with no delay
DZK Rollups verify transactions instantly using proofs, Optimistic Rollups delay verification due to fraud proofs
Attempts:
2 left
💡 Hint
Recall how each rollup type handles transaction verification.
🔧 Debug
advanced
1:30remaining
Identify the Error in ZK Rollup Proof Generation Code
What error will the following Python code raise when simulating a ZK Rollup proof generation?
Blockchain / Solidity
def generate_zk_proof(data):
    # Simulate proof generation
    proof = data / 0
    return proof

print(generate_zk_proof(10))
AZeroDivisionError
BNo error, outputs 0
CValueError
DTypeError
Attempts:
2 left
💡 Hint
Look at the operation dividing by zero.
📝 Syntax
advanced
1:00remaining
Syntax Error in Optimistic Rollup Challenge Period Code
Which option contains the correct syntax to define a function that returns the challenge period length in days?
Blockchain / Solidity
def challenge_period():
    return 7
A
def challenge_period()
    return 7
B
def challenge_period():
return 7
C
def challenge_period():
    return 7
D
def challenge_period:
    return 7
Attempts:
2 left
💡 Hint
Check for colons and indentation in function definitions.
🚀 Application
expert
2:00remaining
Calculate Final State After Batch Processing in ZK Rollup
Given the following Python code simulating batch state updates in a ZK Rollup, what is the final state printed?
Blockchain / Solidity
def zk_rollup_batch(states):
    final_state = 0
    for s in states:
        final_state += s * 2
    return final_state

batch_states = [1, 3, 5]
print(zk_rollup_batch(batch_states))
A18
B9
C15
D30
Attempts:
2 left
💡 Hint
Multiply each state by 2 and add them all up.

Practice

(1/5)
1.

What is the main difference between Optimistic Rollups and ZK Rollups?

easy
A. Optimistic Rollups assume transactions are valid until challenged; ZK Rollups use proofs to verify immediately.
B. Optimistic Rollups use zero-knowledge proofs; ZK Rollups wait for challenges.
C. Both rollups require a waiting period before finalizing transactions.
D. ZK Rollups do not move any work off the main blockchain.

Solution

  1. Step 1: Understand Optimistic Rollups behavior

    Optimistic Rollups trust transactions are valid initially and allow a challenge period to dispute invalid ones.
  2. Step 2: Understand ZK Rollups behavior

    ZK Rollups generate cryptographic proofs that transactions are valid immediately, so no waiting period is needed.
  3. Final Answer:

    Optimistic Rollups assume transactions are valid until challenged; ZK Rollups use proofs to verify immediately. -> Option A
  4. Quick Check:

    Trust first vs proof first [OK]
Hint: Optimistic trusts first, ZK proves first instantly [OK]
Common Mistakes:
  • Confusing which rollup uses proofs immediately
  • Thinking both rollups have the same waiting period
  • Assuming ZK Rollups do not move work off-chain
2.

Which of the following is the correct syntax to describe a ZK Rollup in a blockchain smart contract comment?

// This rollup uses ______ to verify transactions instantly
easy
A. manual challenges
B. a waiting period
C. optimistic assumptions
D. zero-knowledge proofs

Solution

  1. Step 1: Identify ZK Rollup verification method

    ZK Rollups use zero-knowledge proofs to verify transactions instantly.
  2. Step 2: Match the correct phrase in the comment

    The comment should mention "zero-knowledge proofs" to describe ZK Rollups.
  3. Final Answer:

    zero-knowledge proofs -> Option D
  4. Quick Check:

    ZK Rollups = zero-knowledge proofs [OK]
Hint: ZK means zero-knowledge proofs, not waiting [OK]
Common Mistakes:
  • Choosing 'waiting period' which applies to Optimistic Rollups
  • Confusing optimistic assumptions with ZK proofs
  • Selecting manual challenges which are for Optimistic Rollups
3.

Consider this pseudocode for an Optimistic Rollup transaction verification:

function verifyTransaction(tx) {
  assume tx is valid
  wait 7 days for challenge
  if no challenge then finalize tx
  else revert tx
}

What will happen if a fraudulent transaction is submitted and no one challenges it?

medium
A. The system will generate a zero-knowledge proof to verify it.
B. The transaction will be rejected immediately.
C. The fraudulent transaction will be finalized after 7 days.
D. The transaction will be finalized instantly without waiting.

Solution

  1. Step 1: Analyze the verification logic

    The function assumes transactions are valid and waits 7 days for any challenge.
  2. Step 2: Consider no challenge scenario

    If no challenge occurs within 7 days, the transaction is finalized regardless of validity.
  3. Final Answer:

    The fraudulent transaction will be finalized after 7 days. -> Option C
  4. Quick Check:

    Optimistic waits then finalizes if no challenge [OK]
Hint: No challenge means finalize after wait in Optimistic Rollups [OK]
Common Mistakes:
  • Thinking fraudulent tx is rejected immediately
  • Assuming zero-knowledge proofs are used here
  • Believing finalization is instant without waiting
4.

Identify the bug in this ZK Rollup pseudocode snippet:

function verifyZKProof(proof) {
  if (proof.isValid) {
    finalizeTransaction()
  } else {
    wait 7 days for challenge
  }
}

What is the main issue?

medium
A. finalizeTransaction() should be called only after waiting.
B. ZK Rollups should not wait for challenges; proof validity is immediate.
C. The proof.isValid check is missing a negation operator.
D. The function should always wait 7 days regardless of proof validity.

Solution

  1. Step 1: Understand ZK Rollup verification

    ZK Rollups use immediate proof verification and do not require waiting periods.
  2. Step 2: Analyze the code logic

    The code incorrectly waits 7 days if proof is invalid, which contradicts ZK Rollup design.
  3. Final Answer:

    ZK Rollups should not wait for challenges; proof validity is immediate. -> Option B
  4. Quick Check:

    ZK Rollups = instant proof, no wait [OK]
Hint: ZK proofs mean no waiting, immediate finalize [OK]
Common Mistakes:
  • Thinking waiting is needed for ZK Rollups
  • Misreading proof validity condition
  • Assuming finalizeTransaction requires delay
5.

You want to design a rollup system that minimizes user waiting time but can handle complex computations off-chain. Which rollup type should you choose and why?

hard
A. ZK Rollup, because it provides immediate proof and faster finality.
B. Optimistic Rollup, because it finalizes instantly without proofs.
C. Optimistic Rollup, because it uses zero-knowledge proofs for speed.
D. ZK Rollup, because it waits for challenges before finalizing.

Solution

  1. Step 1: Identify rollup goals

    The goal is to minimize waiting time and handle complex off-chain computations.
  2. Step 2: Compare rollup features

    ZK Rollups provide immediate validity proofs, enabling faster finality without waiting periods, suitable for complex computations.
  3. Final Answer:

    ZK Rollup, because it provides immediate proof and faster finality. -> Option A
  4. Quick Check:

    Minimize wait + complex work = ZK Rollup [OK]
Hint: ZK Rollups = fast finality with proofs, best for complex tasks [OK]
Common Mistakes:
  • Choosing Optimistic Rollup for instant finality incorrectly
  • Confusing which rollup uses zero-knowledge proofs
  • Thinking ZK Rollups wait for challenges