Confirm Deposits Safely Through Blockchain Reorganizations
Last updated: November 29, 2026
Quick Overview
Blocks arrive one at a time with a hash, a parent hash and the deposit ids they contain; maintain the canonical chain, emit each deposit exactly once when its block has k confirmations on that chain, never emit deposits from orphaned blocks, and alert if a reorg reaches below an already confirmed block.
Bridge
November 29, 20260
0
0 solved
Blocks arrive one at a time with a hash, a parent hash and the deposit ids they contain; maintain the canonical chain, emit each deposit exactly once when its block has k confirmations on that chain, never emit deposits from orphaned blocks, and alert if a reorg reaches below an already confirmed block.
Before Bridge converts an incoming stablecoin deposit to fiat or forwards it from a liquidation address, it has to be sure the deposit will not disappear in a reorg. This onsite problem tests tree reasoning, incremental state, and whether you design for the failure case instead of assuming the happy path.
What the Interviewer Expects
- Store blocks as a tree keyed by hash with heights derived from parents
- Switch the tip only on a strictly longer chain and explain the tie rule
- Confirm block by block up to tip_height - k + 1 along the canonical path
- Never emit a deposit twice, even after reorgs and duplicate announcements
- Detect a reorg deeper than k and refuse to keep confirming automatically
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How do you handle blocks that arrive before their parents?
- Which k would you pick for Ethereum versus Solana versus a rollup, and why might finality checkpoints replace it?
- How do you prune old blocks without breaking deep-reorg detection?
- What would you do operationally after a deep-reorg alert on funds already paid out?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Given k, a block at height h is final when the canonical tip has height at least h + k - 1 (the block itself counts as one confirmation). The canonical chain is the longest; ties keep the first-seen t...
High-Level Design
Keep blocks[hash] = (parent, height, deposits), the tip, and a record of which hash we finalized at each height. When a new block extends the longest chain, walk from the tip back down to `confirmed...