The Gap After a New Block
2026-11-20
When a miner finds a block, everyone else on the network is suddenly working on something that is not going to make it. Their current job builds on a tip that just went stale, and if they find a block before they switch, it will most likely lose the race.
So how long does it actually take a node to switch? Where does that time go? And what are miners doing in the meantime?
I wanted real numbers for this, so I spent a couple of days measuring it on my own node, and then looked at a year of mainnet blocks to see what miners seem to be doing about it. Let me take you through it.
How does a node learn about a new block?
Most nodes today get new blocks through compact block relay, described in BIP 152. Instead of sending the full block (which could be well over a megabyte), a peer sends a cmpctblock message containing:
- the 80 byte block header,
- a 6 byte short id for every transaction in the block,
- a few "prefilled" transactions the peer expects we don't have. Bitcoin Core always prefills the coinbase, since nobody has that in their mempool.
The short ids are SipHash values keyed with the header and a nonce, so they are cheap to compute but cannot be precomputed by someone trying to cause collisions. When we receive the compact block, we go through our mempool (and a small pool of extra transactions Core keeps around, like recently replaced or orphaned ones) and match each short id to a transaction we already have.
If every transaction matches, we have the whole block without downloading it. If some are missing, we send a getblocktxn with the indexes of the missing transactions, and the peer replies with a blocktxn containing them. That costs us one more round trip to that peer.
There are also two modes a peer can be in:
- Low bandwidth: the peer announces the block (with a
headersorinvmessage), and we have to ask for the compact block with agetdata. That is a round trip before we even start. - High bandwidth: we asked the peer (with
sendcmpct) to push compact blocks to us straight away, even before it has fully validated the block. Core picks up to 3 peers for this, usually the ones that gave us new blocks first recently.
So in the best case, a high bandwidth peer pushes the compact block, our mempool has everything, and we can rebuild and validate the block with no extra round trips at all.
Where does the time go?
From the moment we see the header to the moment the block becomes our new tip, I split it into four stages:
header seen
| fetch (network)
cmpctblock in
| fill (local)
filled from mempool
| round trip (network)
reconstructed
| connect (local)
tip updated
- fetch: getting the compact block itself. This is roughly zero if a high bandwidth peer pushed it, otherwise it is a
getdataround trip. - fill: matching the short ids against the mempool.
- round trip: the
getblocktxn/blocktxnexchange, only if transactions were missing. - connect: validating the block (scripts, UTXO updates and so on) and updating the tip.
Fill and connect are local work. Fetch and the round trip depend on the network, mostly on the round trip time (RTT) to the peer, which is basically your ping, and a bit on bandwidth when the missing transactions are large.
This matters for mining because a miner getting block templates from this node cannot get a full template on the new block until the last stage is done. Whatever it finds before then is built on the old tip.
How did I measure it?
Bitcoin Core already logs most of what we need. I turned on two options on my mainnet node:
logtimemicros=1
debug=cmpctblock
The first gives microsecond timestamps in debug.log, the second logs each step of compact block handling. The line that does most of the work looks like this (a real one from my log, trimmed a bit):
[cmpctblock] Successfully reconstructed block 00000000000000000001da7c...
with 1 txn prefilled, 557 txn from mempool (incl at least 9 from extra pool)
and 2293 txn (1280704 bytes) requested
Then I wrote a Python script that walks the log, matches the "saw new header", "initializing", "initialized", "successfully reconstructed" and UpdateTip lines for each block, and works out the time spent in each stage. It also records whether the compact block came from a high bandwidth peer and how many transactions and bytes had to be requested.
A couple of things it leaves out on purpose:
- blocks within 30 minutes of a restart, since the coins cache is cold and validation is a lot slower than normal,
- "link stalls", where a network stage took far longer than its size explains (more than 5x what it should take on my link, or over 10 seconds outright). For example, 2 kB taking 10 seconds is my connection dropping, not compact block relay being slow, while 1.4 MB taking 2.6 seconds is just a big round trip.
I left it running over 129 blocks (976408 to 976536). The script and the raw data are in this gist if you want to run it on your own node.
I should be upfront about the setup. My node is a worst case. It runs on a 4G connection behind carrier grade NAT, so it can only make outbound connections, and its ping to peers was somewhere between 200 and 450 ms during this time.
So what did it look like?
After leaving out 12 link stalls and 4 blocks right after a restart, this is what was left (113 blocks):
stage median p90 max
fetch after header (network) 151 ms 556 ms 1.5 s
round trip (network) 276 ms 1.8 s 8.6 s (85 blocks)
fill from mempool (local) 8 ms 10 ms 13 ms
connect / validate (local) 63 ms 107 ms 395 ms
header -> tip total 512 ms 1.8 s 10.3 s
The first thing that stood out was how little of this is local. Filling from the mempool took under 15 ms every time, and validation was around 60 ms on a typical block. Together that is about 70 ms. Everything else, the other 400+ ms on a median block, is waiting on the network.
The second thing was how often a round trip was needed. 85 of the 113 blocks (75%) were missing at least one transaction and needed a getblocktxn. Blocks that did not need one took 259 ms median from header to tip, blocks that did took 556 ms.
Breaking down how many transactions those 85 blocks were missing:
missing txs blocks
1 - 5 46
6 - 100 11
101 - 1000 15
over 1000 13
So over half of the round trips were for a handful of transactions, sometimes just one. But there is also a long tail where the block had hundreds or thousands of transactions my mempool had never seen. The worst one, block 976475, needed 6556 transactions (607 kB) fetched after the header, and the round trip alone took 2.2 seconds.
High bandwidth mode did not save much here either. 17 blocks were pushed to me by a high bandwidth peer, which skips the fetch, but 14 of those still needed a round trip for missing transactions.
And then there are the 12 stalls I left out, which took anywhere from 2.8 to 50 seconds from header to tip. That is close to 1 in 10 blocks. On a link like mine, multi second gaps are not rare at all.
But isn't that just a bad connection?
Partly, yes, and I don't want to oversell it. To get a feel for what a better connected node would see, I modelled the same blocks as:
local time + round_trips x RTT + bytes x 8 / bandwidth
where round_trips counts the fetch (unless a high bandwidth peer pushed the block) and the getblocktxn exchange (if there was one), and bytes is the compact block plus the requested transactions. With 50 ms RTT and a fast link, that gives about 160 ms median and 500 ms at worst. It ignores TCP slow start, so for big transfers it is a lower bound, but it gives the right order of magnitude.
So on a good connection the gap is mostly a few hundred milliseconds. But two things make this more than just my connection.
The first is the round trips themselves. Missing transactions are not a property of my link, they mean my mempool did not match what the miner put in the block. And it is not just me. 0xB10C runs monitoring nodes that track this across the network, and reported that from mid July 2026 the share of blocks that could be rebuilt without a round trip was hovering between 1% and 5%. That lasted until the unsolicited transaction chains being pushed to nodes stopped on 2026-10-18. If the best connected nodes need a round trip on almost every block, then the gap is really RTT bound for everyone.
The second is who actually runs links like mine. Home miners, small pools, and miners building their own templates with Stratum v2 job declaration are far more likely to be on a slow or unreliable connection than a large pool with servers next to each other in a data centre.
A block comes about every 600 seconds, so a 1 to 3 second gap per block means roughly 0.2% to 0.5% of their hashrate is spent on a stale tip. That does not sound like much, but mining margins are thin, and it is a cost that falls mostly on the smaller miners.
What are miners doing about it today?
To see this from the outside, I looked at every block from 923849 to 976408, roughly a year. There were 97 empty blocks, meaning blocks with only the coinbase transaction in them. For each block, I compared its header timestamp with its parent's:
gap to parent empty blocks all blocks
0-10s 20% (19/97) 1.1%
0-30s 58% (56/97) 4.1%
0-60s 76% (74/97) 8.1%
Empty blocks are roughly 9 to 17 times more likely than other blocks to show up right after their parent. Why would that be?
One explanation is mining on headers, often called spy mining or SPV mining. The pool starts working on the next block as soon as it sees the new header, before it has downloaded or validated the block. Since it does not know yet which transactions the parent included, it cannot safely include any transactions of its own (they might already be in the parent, which would make the block invalid). So the only safe thing to mine is an empty block.
The other explanation is more boring. Even after a pool has validated the new block, building a fresh full template takes some time: the node has to remove the confirmed transactions from the mempool, the pool calls getblocktemplate, and the new job has to get out to the miners. Some pools send an empty job straight away and replace it once the full template is ready.
From the chain alone, you cannot tell these two apart. Header timestamps are also noisy since miners set them, and some blocks even have a timestamp earlier than their parent (I left those out of the table). But in both cases the behaviour is the same: miners prefer to start hashing right away on an empty block over waiting for a full one.
Mining on unvalidated headers also has a history. In July 2015, shortly after BIP 66 activated, a miner produced an invalid block, and some large pools that were mining on headers without validating built on top of it. The result was a 6 block invalid fork. It is a good reminder that this needs to be done carefully, with a way to back out when the block turns out to be bad.
So what could Bitcoin Core do?
This is what bitcoin/bitcoin#33756 is about. Bitcoin Core has a mining interface that clients like the Stratum v2 Template Provider talk to over IPC. One of its calls, waitNext(), blocks until there is a better template than the one the client has (a new tip, or fees going up past a threshold) and then returns it. Options for the wait go in a BlockWaitOptions struct.
The idea in the issue is to optionally have waitNext() return an empty template as soon as we have a valid header for a new block, before the block itself is downloaded and validated. Basically doing what pools already do, but inside Core, opt in, and with a clear way to back out.
A small first version could look like this:
- A new field in
BlockWaitOptions, off by default, so only miners who ask for it get this behaviour. - Only an empty template, and only for a header that directly extends our validated tip, so at most 1 block deep. Nothing during initial block download.
- Only if the block has not connected within a short delay after the header. On a well connected node the block usually connects in a couple of hundred milliseconds, so this would rarely kick in there.
- The next
waitNext()call returns the full template once the block connects, or a template on the old tip if the block turns out invalid or never arrives.
Some of the plumbing is already there. When a compact block comes in, its header goes through ProcessNewBlockHeaders before reconstruction even starts, and that calls NotifyHeaderTip, which fires the headerTip kernel notification whenever our best header changes. Right now that notification only goes to the GUI, so the template manager would need to listen for it (or for a new validation interface notification).
The empty template itself is simple. It needs the new header's hash as the previous block, the next height, the difficulty target that follows from that header, a timestamp that satisfies the median time past rule, and a coinbase paying just the block subsidy, since there are no fees. None of that needs the mempool, so it could be built from the block index alone, without going through BlockAssembler's transaction selection.
There is also an existing guard worth mentioning. The template manager has a CooldownIfHeadersAhead step: when createNewBlock() is called and we already know a header ahead of our tip, it waits briefly for the block before returning a template. It deliberately does not wait long, because a miner could announce a header and then hold back the block to stall everyone else. A provisional template would need a timeout for the same reason.
What are the trade-offs?
The obvious one is mining on top of something you have not validated. If the block turns out invalid, any work in that window was wasted, and in the worst case you find a block on top of an invalid one, like in 2015. A few things help here. An invalid header still needs a full block's worth of proof of work, so it is expensive to produce on purpose. The template is only 1 block deep and is dropped as soon as the block fails. And backing off after a couple of invalid headers in a row would make repeated attempts pointless.
The second one is fees. An empty block gives up all the fees a full block would have collected. But during the gap the alternative is not a full block on the new tip, because you cannot build one until you know the parent's transactions. The alternative is a full block on the old tip, which will most likely lose. So for the time it is actually used, an empty template is better than what the miner has.
The third is the overlap with work that makes compact block relay itself better. Prefilling compact blocks lets the sending peer include transactions it thinks we are missing, which should get rid of most of the small 1 to 5 transaction round trips I saw. I don't think these compete. Prefill shrinks the gap for most blocks, and an empty template covers what is left: the blocks with hundreds or thousands of missing transactions, and the link stalls, which prefill cannot fix.
I shared these numbers and the approach on the issue as well. I'd be curious to see the same measurements from a better connected node, so if you run the script, let me know what you get.
References
- BIP 152: Compact Block Relay
- bitcoin/bitcoin#33756: Header-only support for waitNext(), and my comment with this data
- bitcoin/bitcoin#35558: p2p: Prefill compact blocks
- Stats on compact block reconstructions, Delving Bitcoin, in particular posts 53 and 63 by 0xB10C
- July 2015 chain forks, bitcoin.org alert on the BIP 66 / SPV mining fork
- Bitcoin Core source: src/interfaces/mining.h (
waitNext()), src/node/block_template_manager.h (CooldownIfHeadersAhead) - Scripts and raw data used in this article