Chapter 37: Exercises

Conceptual Exercises

Exercise 1: The Oracle Problem

Explain in your own words why smart contracts cannot access external data. Why is this fundamental to blockchain architecture rather than merely a technical limitation that could be engineered away?

Exercise 2: Oracle Trust Models

For each of the following prediction markets, recommend the most appropriate oracle type (centralized, DON, Schelling point, optimistic, or governance) and justify your choice: a) A sports betting market with thousands of markets per day. b) A single high-stakes market on the outcome of a presidential election ($50M+ in volume). c) A market on whether a specific scientific paper will be retracted. d) A market on the closing price of the S&P 500 on a specific date.

Exercise 3: Schelling Point Failure

Describe a scenario where the Schelling point mechanism fails --- that is, where the "obvious" answer is not the truth. What does this imply about the types of questions that Schelling point oracles can reliably resolve?

Exercise 4: Optimistic Oracle Trade-offs

Explain the relationship between the dispute window length and security in an optimistic oracle. What happens if the dispute window is: a) Too short (e.g., 1 minute)? b) Too long (e.g., 30 days)? c) How would you choose the optimal dispute window for a given market?

Exercise 5: Fork Mechanism Analysis

Augur's fork mechanism is often described as a "nuclear option." Explain why: a) The fork mechanism is necessary for Augur's security model. b) The fork mechanism is costly and disruptive. c) The existence of the fork mechanism (even if never used) contributes to the security of earlier dispute rounds.

Exercise 6: Oracle Comparison

Create a comparison matrix evaluating UMA, Chainlink, Kleros, and Augur on the following criteria: speed, cost, decentralization, security, flexibility (range of question types supported), and track record. Rate each on a 1-5 scale and provide brief justifications.

Exercise 7: Decentralization Trilemma

Explain the decentralization trilemma in your own words. Why can't a system simultaneously maximize scalability, security, and decentralization? Provide a concrete example from oracle design.

Exercise 8: Resolution Source Specification

For each of the following market questions, specify a precise resolution source and criteria that would minimize ambiguity: a) "Will Bitcoin reach $100,000 in 2025?" b) "Will there be a recession in the US in 2026?" c) "Will SpaceX's Starship complete an orbital flight in 2025?" d) "Will the global average temperature in 2025 exceed the 2024 record?"

Mathematical Exercises

Exercise 9: Bond Sizing

A prediction market has $V = \$500,000$ in total value locked. The gas cost of an assertion transaction is $g = \$5$. Design the bond amount $B$ such that: a) Spam assertions are uneconomical (i.e., the bond exceeds the gas cost by a factor of at least 10). b) The bond is at most 2% of the market value. c) The bond provides meaningful economic incentive for correct reporting. Write out the constraints and find a suitable range for $B$.

Exercise 10: P+epsilon Attack Cost

Consider a Schelling point oracle with $n = 100$ voters. Each voter's honest reward is $R = \$10$ and penalty for voting against the majority is $P = \$20$. An attacker wants to corrupt the oracle using a P+epsilon attack. a) What is the minimum unconditional bribe needed per voter? b) What is the total cost of bribing a majority? c) If the attacker uses a conditional P+epsilon attack with $\epsilon = \$0.01$ per voter, what is the maximum cost if the attack succeeds? Why might this be enough to change the Schelling point?

Exercise 11: Multi-Oracle Corruption Probability

Consider a multi-oracle system with $k = 7$ independent oracles, each with corruption probability $p = 0.05$. a) Calculate the probability that the median oracle (majority vote) is corrupted. b) How does this compare to the corruption probability of a single oracle? c) How many independent oracles would you need to reduce the corruption probability below 0.001% if each oracle has $p = 0.1$?

Exercise 12: Security Margin Calculation

Compute the security margin for each oracle type given: - Market value: $V = \$2,000,000$ - UMA: 8M UMA tokens actively voting, UMA price = $4, bond = $5,000 - Augur: 11M total REP, REP price = $8 - Kleros: 5 jurors per round, $200 bribe per juror, 3 expected appeal rounds - Centralized: operator compromise cost estimated at $100,000

Which oracle would you choose and why?

Exercise 13: Kleros Appeal Cost Escalation

In Kleros, the jury size at round $r$ is $J_r = 2r + 1$ (starting from $r = 0$). Each juror costs $c = \$50$ per round. a) Calculate the total cost of resolving a dispute through 5 rounds of appeals. b) If the initial dispute involves a market worth $\$10,000$, at what round does the cumulative appeal cost exceed the market value? c) Design a modified appeal structure where the cost escalation is steeper (reaches the market value in fewer rounds).

Exercise 14: Trilemma Quantification

Using the trilemma model from Section 37.8.5: a) Define specific metrics for Scalability ($\text{Sc}$), Security ($\text{Se}$), and Decentralization ($\text{De}$) for a centralized oracle and a fully decentralized governance oracle. b) Compute $\text{Sc} \cdot \text{Se} \cdot \text{De}$ for each. c) Is the claim that $\text{Sc} \cdot \text{Se} \cdot \text{De} \leq K$ consistent with your results?

Exercise 15: Dispute Probability and Expected Cost

An optimistic oracle has a bond of $B = \$2,000$, and when a dispute occurs, the DVM vote costs $\$10,000$ (total across all participants). If the probability of dispute is $p$: a) Write an expression for the expected total cost of resolution. b) Plot expected cost as a function of $p$ for $p \in [0, 1]$. c) If the market has $V = \$100,000$ and you want the expected cost to be below 1% of $V$, what is the maximum acceptable dispute probability?

Programming Exercises

Exercise 16: Oracle Simulator

Write a Python program that simulates a Schelling point oracle with $n$ voters. Each voter has a probability $q$ of being honest and $1 - q$ of being bribed. Simulate 10,000 rounds and compute: a) The frequency with which the oracle reports the correct outcome. b) The expected payoff for honest vs. dishonest voters. c) The minimum $q$ needed for the oracle to be reliable (correct >99% of the time).

Exercise 17: Bond Optimization

Write a Python program that finds the optimal bond size for a UMA-style optimistic oracle given: - A distribution of market values. - A spam rate as a function of bond size. - A legitimate proposer participation rate as a function of bond size. Optimize for the expected total value secured minus expected losses from spam.

Exercise 18: Dispute Escalation Simulation

Implement a simulation of Augur's multi-round dispute mechanism. Given: - A true outcome (A or B). - A distribution of REP holdings across honest and dishonest participants. - Staking behavior for each round. Simulate the dispute process and determine: a) How many rounds it takes to reach finality. b) The total REP staked by each side. c) Whether the correct outcome prevails.

Exercise 19: Multi-Oracle Aggregation

Implement a multi-oracle aggregation system in Python. Given $k$ oracles, each with a known accuracy rate: a) Implement majority vote, weighted majority vote, and Bayesian aggregation. b) Compare the accuracy of each aggregation method when oracles have different accuracy rates. c) Determine the optimal weights for weighted majority vote.

Exercise 20: Oracle Security Dashboard

Build a Python program that creates a security dashboard for an oracle system. The dashboard should: a) Take as input the oracle type, bond sizes, token prices, and market values. b) Compute the cost of attack for each attack vector. c) Display the security margin, risk rating, and recommendations. d) Identify the weakest link in the system.

Exercise 21: Resolution Ambiguity Detector

Write a Python program that analyzes market question text and flags potential ambiguity issues. Use simple heuristics such as: a) Missing time specifications. b) Undefined terms (e.g., "recession" without specifying which definition). c) Missing resolution source. d) Vague quantifiers ("significantly", "approximately").

Write a Python program that monitors Chainlink price feed updates and detects anomalies: a) Fetch historical rounds from a Chainlink aggregator. b) Detect sudden price jumps that exceed a threshold. c) Check for stale data (updates that are older than expected). d) Flag potential manipulation (rapid price changes followed by reversals).

Applied Exercises

Exercise 23: Oracle Design for a Sports Betting Platform

Design an oracle system for a sports betting platform that resolves hundreds of markets per day. Specify: a) The primary resolution mechanism. b) The dispute resolution mechanism. c) Bond sizes and dispute windows. d) How to handle postponed or cancelled games. e) The trade-offs you are making in the decentralization trilemma.

Exercise 24: Oracle Design for a Political Prediction Market

Design an oracle system for a political prediction market (elections, legislation, policy decisions). Address: a) How to handle delayed results (e.g., elections that take days to count). b) How to resolve ambiguous legislative outcomes (e.g., a bill that passes but is vetoed). c) How to handle markets on events that may never resolve (e.g., "Will X be indicted?"). d) Source specification for different types of political events.

Exercise 25: Attack Scenario Analysis

You control $\$500,000$ and want to profit by manipulating a prediction market oracle. For each oracle type (centralized, UMA, Kleros, Augur): a) Describe the attack strategy. b) Calculate the expected cost. c) Calculate the expected profit (assuming you hold the maximum possible position in the market). d) Determine whether the attack is profitable.

Exercise 26: Post-Mortem Analysis

Research a real-world oracle failure or dispute in a prediction market. Write a post-mortem that includes: a) What happened. b) The root cause. c) The impact (financial and reputational). d) What could have been done differently. e) Recommendations for preventing similar failures.

Exercise 27: Oracle Cost Comparison

For a prediction market platform expecting 1,000 markets per month with an average of 5% dispute rate: a) Estimate the monthly cost of using UMA's optimistic oracle. b) Estimate the monthly cost of using Kleros for all disputes. c) Estimate the monthly cost of a centralized oracle (including server and operational costs). d) Which is most cost-effective at different scales (100, 1,000, 10,000 markets/month)?

Exercise 28: Hybrid Oracle Design

Design a three-layer hybrid oracle system: a) Define Layer 1 (fast, cheap, handles most resolutions). b) Define Layer 2 (moderate cost, handles disputes). c) Define Layer 3 (expensive, handles the most contentious disputes). d) Define escalation criteria between layers. e) Model the expected cost and resolution time for the hybrid system given a dispute probability of 3% at Layer 1 and 20% at Layer 2.

Exercise 29: Oracle Governance Attack

A governance token (used for oracle voting) has a market cap of $\$50M$ with 30% of tokens actively voting. An attacker wants to manipulate a market worth $\$10M$. a) Can the attacker profitably acquire enough tokens to control the vote? b) How does slippage affect the attack cost? c) If the protocol implements a time-lock on voting power (tokens must be locked for 30 days before they can vote), how does this change the attack calculus? d) Design a defense mechanism that makes this attack unprofitable.

Exercise 30: Future Oracle Design

Design an oracle system that incorporates at least two of the following emerging technologies: a) AI-assisted resolution. b) Zero-knowledge proofs for data provenance. c) Reputation-weighted voting (soulbound tokens). d) Cross-chain oracle aggregation. Describe the system architecture, trust model, security analysis, and trade-offs. Implement a simplified prototype in Python.