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
Coding & Algorithms
Software Engineer
Bridge
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

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
blockchain reorgs
trees
confirmation depth
incremental algorithms
exactly-once emission
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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...


Submit Your Answer
Markdown supported

Related Questions