Block Assembly

Lesson, slides, and applied problem sets.

View Slides

Lesson

Block Assembly & Mempool Policy

Why this module exists

Mining is not just hashing; it is also economic selection. The block you mine determines your fees and influences mempool dynamics.


1) Fee rate

The canonical heuristic is fee per byte:

feerate = fee / size

Higher feerate transactions get prioritized.


2) Dependencies

A transaction may spend outputs of another mempool transaction. Selection must ensure inputs are available at inclusion time.


3) Size limits

A block has a size budget. Adding a tx may exclude others. This is a knapsack-like problem; we use a greedy heuristic here.


4) Coinbase output

Coinbase mints subsidy + fees. It anchors the miner's reward.


What you will build

  1. Greedy mempool selection by fee rate
  2. Input-availability checks
  3. Coinbase reward calculation

Key takeaways

  • Block assembly is an optimization problem.
  • Dependencies require careful ordering.
  • Fee policy influences network behavior.

Module Items