Ouroboros (Cardano) Consensus Interview Questions

Ouroboros consensus algorithm interview questions covering Cardano's Proof-of-Stake consensus mechanism.

Q1: How does Ouroboros (Cardano) consensus work?

Answer:

Ouroboros is Cardano's Proof-of-Stake consensus algorithm.

Sequence Diagram:

Overall Flow Diagram:

Individual Node Decision Diagram:

Ouroboros Phases:

1. Epoch Structure:

  • Epoch: 432,000 slots (5 days)
  • Slot: 1 second
  • Slot Leader: Selected based on stake

2. Slot Leader Selection:

  • Probability proportional to stake
  • Uses Verifiable Random Function (VRF)
  • Leaders known in advance (for security)

3. Block Creation:

  • Slot leader creates block
  • Includes transactions
  • Signs with private key

4. Chain Selection:

  • Longest chain rule
  • Fork resolution by stake weight

5. Epoch Transition:

  • Update stake distribution
  • Recalculate leader schedule

Key Properties:

  • Security: Cryptographically secure
  • Energy Efficient: No mining required
  • Decentralized: Stake-based selection
  • Formal Verification: Mathematically proven

Example:

 1-- Slot leader selection
 2selectSlotLeader :: Epoch -> Slot -> StakeDistribution -> Maybe StakePool
 3selectSlotLeader epoch slot stakeDist = do
 4    -- Calculate probability based on stake
 5    let totalStake = sumStake stakeDist
 6    let poolStake = getPoolStake pool stakeDist
 7    let probability = poolStake / totalStake
 8    
 9    -- VRF to determine if selected
10    let vrfOutput = computeVRF epoch slot poolPrivateKey
11    if vrfOutput < probability then
12        Just pool
13    else
14        Nothing
15
16-- Block creation
17createBlock :: SlotLeader -> [Transaction] -> Block
18createBlock leader txs = Block
19    { slot = currentSlot
20    , transactions = txs
21    , previousHash = getPreviousHash
22    , signature = signBlock leaderPrivateKey
23    }

Ouroboros Variants:

  • Ouroboros Classic: Basic PoS
  • Ouroboros Praos: Semi-synchronous, private leader selection
  • Ouroboros Genesis: No trusted setup
  • Ouroboros Chronos: Time synchronization

Use Cases:

  • Cardano blockchain
  • High-security PoS systems

Related Snippets