pull down to refresh

This block is full of large consolidations paying 10.0 s/vb.

At the time of mining, there were dozens of blocks worth of near-identical transactions all paying that same fee rate.

So how did @mempool know that these exact transactions would be mined next, and in this order? 🧵

Mining pools (normally) want to maximize the fees earned by their blocks.

Almost every pool delegates this task to a Bitcoin Core node, which runs the "getBlockTemplate" algorithm to efficiently select the most profitable 1MvB of transactions from its mempool.

At a high level, getBlockTemplate is very simple.

It assigns each transaction a "score" equal to the fee rate of the transaction itself, or the effective rate of the transaction plus any unconfirmed ancestors, whichever is lower.

Then the mempool is sorted by score, and the algorithm greedily picks the highest-scoring packages within consensus limits until the block is full (or it runs out of options).

(it's a bit more complicated in practice, because selecting one transaction changes other scores).

So a transaction paying 10.02 s/vb has a higher score than one paying 10.01 s/vb, and miners pick accordingly.

Fun fact - these scores are actually subtly wrong because they use rates with vsizes rounded up to the nearest integer, while consensus vbytes are fractional units.

But what about transactions with exactly the same fee rates?

The Bitcoin Core mempool applies a simple tie-breaker: when two scores are identical, choose the transaction with the lowest hash.

txids are just transaction hashes written backwards in hexadecimal, so miners will pick a txid ending in '00' before one ending in 'ff', when the scores are the same.

see this effect by watching the last two digits of the txids, as we move towards the back of a projected block:

mempool.space runs a custom implementation of the exact same getBlockTemplate algorithm used by the mining pools, dozens of times per minute.

That lets us predict the content and structure of blocks before they happen with surprising accuracy.