0
0
Blockchain / Solidityprogramming~20 mins

Layer 2 solutions overview in Blockchain / Solidity - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Layer 2 Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the primary purpose of Layer 2 solutions?

Layer 2 solutions are designed to improve blockchain networks. What is their main goal?

ATo create new cryptocurrencies unrelated to the main chain
BTo increase transaction speed and reduce fees by processing transactions off the main chain
CTo replace the main blockchain with a new one
DTo increase the size of blocks on the main chain
Attempts:
2 left
💡 Hint

Think about how Layer 2 helps with congestion on the main blockchain.

Predict Output
intermediate
2:00remaining
Output of a simple state channel transaction update

Consider this pseudocode for a state channel updating balances off-chain:

channel_state = {'Alice': 5, 'Bob': 5}
channel_state['Alice'] -= 2
channel_state['Bob'] += 2
print(channel_state)

What is the output?

Blockchain / Solidity
channel_state = {'Alice': 5, 'Bob': 5}
channel_state['Alice'] -= 2
channel_state['Bob'] += 2
print(channel_state)
A{'Alice': 3, 'Bob': 7}
B{'Alice': 7, 'Bob': 3}
C{'Alice': 5, 'Bob': 5}
DTypeError: unsupported operand type(s)
Attempts:
2 left
💡 Hint

Subtract 2 from Alice's balance and add 2 to Bob's.

🔧 Debug
advanced
2:00remaining
Identify the error in this optimistic rollup code snippet

Review this simplified pseudocode for an optimistic rollup submission:

def submit_batch(batch):
    if len(batch) == 0:
        raise ValueError('Batch cannot be empty')
    process(batch)

What error will this code produce when run?

Blockchain / Solidity
def submit_batch(batch):
    if len(batch) == 0:
        raise ValueError('Batch cannot be empty')
    process(batch)
ANo error, runs successfully
BNameError because process is undefined
CSyntaxError due to missing colon after if statement
DValueError because batch is empty
Attempts:
2 left
💡 Hint

Check the syntax of the if statement.

Predict Output
advanced
2:00remaining
Result of Plasma exit challenge simulation

Given this pseudocode simulating a Plasma exit challenge:

exits = {'user1': 100}
challenge_amount = 50
exits['user1'] -= challenge_amount
print(exits['user1'])

What is printed?

Blockchain / Solidity
exits = {'user1': 100}
challenge_amount = 50
exits['user1'] -= challenge_amount
print(exits['user1'])
AKeyError
B150
C100
D50
Attempts:
2 left
💡 Hint

Subtract challenge_amount from the user's exit amount.

🧠 Conceptual
expert
2:00remaining
Which Layer 2 solution uses zero-knowledge proofs to validate transactions?

Among Layer 2 solutions, which one relies on zero-knowledge proofs to ensure transaction validity without revealing data?

AZK Rollups
BPlasma
CState Channels
DOptimistic Rollups
Attempts:
2 left
💡 Hint

Zero-knowledge proofs are a key feature of one Layer 2 type that compresses data and proofs.