Q&A-1Define the oracle boundary for an application.
Answer
The 90-second answer
The oracle boundary is the written contract between your contract and the outside world: the exact fact you accept, where it comes from, in what units, how fresh it must be, who may report it, and what your code does when the report is late, disputed, or missing. Inside the boundary is native chain state you can recompute; outside it is an assumption you are choosing to trust.
Assumptions I'd state before drawing it: which chain, which asset, and the maximum value at risk per block. Then one question per fact: what does it cost to verify this myself, and what is at risk if it is wrong? If verification is cheap (a token balance, a block hash), keep it inside. If it is expensive (the ETH/USD price on Binance at 12:00:00 UTC), you are buying a claim, and the boundary is the purchase order.
Mechanism: how a claim becomes chain state
Chainlink Data Feeds on Ethereum mainnet run off-chain reporting: a set of node operators each pull from a list of exchanges, the median is computed off-chain, and one transaction posts the aggregate. The consumer calls latestRoundData() and gets answer, updatedAt, answeredInRound. The trust assumption is "no single node can move the median", not "the price is true."
Pyth inverts the flow: publishers sign prices, Pythnet aggregates them, and the result reaches the chain as a Wormhole VAA that your transaction must pull and post. You pay gas per update, but the payload carries the publisher's confidence interval and publish_time.
Worked example
A lending market on Ethereum mainnet prices collateral with Chainlink ETH/USD. The feed's documented parameters are a 0.5% deviation threshold and a 1-hour heartbeat, so the boundary says: accept the answer only if block.timestamp - updatedAt <= 3600 + 300 (heartbeat plus a 5-minute buffer for the posting transaction) and answeredInRound >= roundId.
Trace at block timestamp 17,000,000:
updatedAt = 16,996,200→ age 3,800 s. 3,800 ≤ 3,900 → accept.- Next block,
updatedAtunchanged, timestamp 17,000,400 → age 4,200 s > 3,900 → revert the borrow; repay and liquidation still allowed.
That last line is the boundary doing its job: the protocol would rather halt new debt than price collateral off a stale number.
Trade-offs
- Push (Chainlink) vs pull (Pyth): push costs nothing per read but you inherit the heartbeat; pull gives fresher prices, but every consumer transaction pays to post the update, and a liquidator who forgets to post is liquidating against an old price.
- Spot vs TWAP: a Uniswap V3 TWAP over a 30-minute window costs an attacker roughly the arbitrage loss of holding a manipulated price for the whole window; a spot read costs one block of capital. For a lending market, TWAP is usually the right default; for a perp funding rate, spot with a confidence check is.
- Single source vs median: median costs latency and a larger trust set; a single source is defensible when the value at risk is below the cost of the second source.
Failure modes and detection
- Stale data:
updatedAtolder than heartbeat plus buffer. Detect with a per-feed age metric; alert at 80% of heartbeat. - Ambiguous truth: two exchanges disagree by more than the deviation threshold. Detect by comparing the feed against a second source off-chain and paging on a gap above your tolerance.
- Reporter collusion: the median moves without a matching move on any tracked exchange. Detect by monitoring the feed against an independent index.
- Chain mismatch: the same feed address on a testnet or L2 returns a different answer. Detect by pinning feed addresses per chain ID in config and asserting
block.chainidat deploy. - Availability treated as correctness: the feed returns a number, so the code proceeds. Detect by making the staleness and round checks revert, not warn.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.