Independent discussion of crypto, wallets, cards and markets
Forum Home > Learning & Discussion > Concepts & Explainers > Merkle trees: how proofs fit inside blocks
Merkle trees: how proofs fit inside blocks133 replies · 4,736 views
Thread ToolsShow Printable Version · Subscribe to this Thread · Search Thread
Where to open an account: Open a Trustee account.

Merkle trees: how proofs fit inside blocks

The problem a block must solve

A block contains hundreds or thousands of transactions, and the network needs to answer two questions about them cheaply: did this block's contents change at all, and can a lightweight device verify that one specific transaction is inside without downloading everything? Storing or transmitting every transaction hash for every check would be wasteful, and a phone verifying a payment should not need the chain's full history. Merkle trees answer both questions with one structure: a hash tree that compresses an entire transaction set into a single 32-byte fingerprint and enables partial proofs of membership.

How the tree is built

  • Leaves are transaction hashes: every transaction in the block is hashed, and those hashes become the tree's bottom level. The block header stores only the top of the tree - the Merkle root - which is a single hash representing all leaves beneath it.
  • Pairs combine upward: adjacent hashes are concatenated and hashed again, producing the next level; the process repeats until one hash remains. If a level has an odd number of nodes, the last node is duplicated or carried up, depending on the chain's convention.
  • The root is the commitment: any change to any transaction changes its leaf hash, which changes every hash up the path to the root. The root is therefore a tamper-evident summary - one altered transaction makes the stored root impossible to reproduce.
  • Order matters: because pairing is positional, rearranging transactions changes the root. The tree commits not just to contents but to sequence, which is why transaction order inside a block is part of the block's identity.

How a proof fits inside verification

  • The proof path: to prove one transaction is in a block, you do not send the whole tree - you send the transaction's hash plus the sibling hashes along its path to the root, typically around twenty hashes for a block of thousands of transactions.
  • Recomputation check: the verifier recomputes the path - hashing the transaction with each sibling in turn - and compares the result to the block header's stored root. A match proves membership and position; a mismatch means the transaction is not in that block or the data is corrupted.
  • The cost asymmetry: the prover stores and sends logarithmic-size data; the verifier does logarithmic-size work. This is why light clients, payment channels, and cross-chain bridges can verify inclusion with phones-sized resources while trusting only the block header they already have.
  • What the proof does not include: the proof demonstrates membership, not validity - it proves the transaction is in the block, not that the transaction itself follows protocol rules. Full validation still requires checking the transaction; the Merkle proof answers the containment question only.

Where Merkle structures appear in practice

  • Block headers: every major chain stores the Merkle root of its transactions in the header, which is why headers are small and why header-only sync is possible.
  • State trees: the same structure generalizes to account state - state roots commit to every balance and storage value, and state proofs let applications verify account data without trusting a server's database.

Reading Merkle claims correctly

The takeaway

Merkle trees compress a block's entire transaction set into one root hash and enable logarithmic-size proofs of membership: leaves are transaction hashes, pairs combine upward, and any change anywhere alters the root. Verification sends a transaction plus its sibling path and recomputes to the stored root - containment proven with phones-sized work, which is what makes light clients, state proofs, and bridge evidence possible. The structure commits to contents and order, proves membership but not validity, and generalizes from transactions to state to cross-chain claims. The block's small header is the trick: one 32-byte fingerprint that lets the whole network - and any device with a copy of the header - audit thousands of transactions without ever holding them.

Thread Statistics133 replies · 4,736 views