Loading the latest prices…

Protocol & Mining

The mempool is not one pool

Every node keeps its own store of valid, unconfirmed transactions, and no two nodes hold exactly the same set. The mempool is a local data structure with local rules, which is why two explorers can report different backlogs at the same moment.

Protocol referenceSource: Bitcoin Developer Guide, P2P NetworkDescribes the reference implementation's mempool behaviour; other implementations differ in detail.

What a mempool holds

A mempool is a node's working set: the transactions it has received, validated against the consensus rules, and is holding in the hope that they will be included in a future block. It is not a ledger and it is not authoritative. Nothing in the protocol requires a node to keep one, and a node that discarded every unconfirmed transaction it received would still follow the chain correctly. The mempool exists because miners need candidates to build blocks from and because relaying transactions is how they reach miners in the first place.

A transaction enters a node's mempool when it arrives and passes the node's checks. Those checks include the consensus rules — the outputs being spent must exist and be unspent, the signatures must be valid, the outputs must not exceed the inputs — and the node's own relay policy, which sets a minimum fee rate and limits on size and script form. A transaction that fails a consensus rule is invalid and will never be accepted. A transaction that fails a policy check is merely unwelcome here, and may be perfectly acceptable to a node with different settings.

A transaction leaves the mempool in one of three ways. It is confirmed, in which case the node removes it and also removes any transactions that spent its outputs, because those are now confirmed too. It is evicted, because the mempool has reached its size limit and the node has decided this transaction is the least valuable entry to keep. Or it is replaced, when a conflicting transaction spending the same outputs arrives with a fee high enough to satisfy the node's replacement rule. Each of these is a local decision made by one node about its own store.

Fee-rate ordering and eviction

A mempool is ordered by fee rate, not by arrival time. The relevant figure is the fee a transaction pays divided by the weight it consumes, because a block has a fixed weight budget and a miner filling it wants the most fee per unit of that budget. A transaction that pays a large absolute fee but consumes a great deal of weight may rank below a smaller transaction paying less. This is why fee estimation is expressed per unit of weight, and why the block weight rule is the right frame for thinking about fees.

When a mempool reaches its configured size limit, the node evicts entries from the bottom of the fee-rate ordering until it is back under the limit. Eviction is not a rejection of the transaction's validity; the transaction remains valid and may still be confirmed if another node kept it and a miner includes it. But the node that evicted it will no longer relay it, and if enough nodes evict it the transaction may effectively disappear from the network's view until it is rebroadcast.

Replacement works in the opposite direction. A node that receives a transaction spending outputs already spent by an unconfirmed transaction in its mempool must decide which to keep. The rule the reference implementation applies is that the replacement must pay a fee that exceeds the original by a margin, and must compensate for any descendants of the original that are displaced. The effect is that a sender who underpriced a transaction can raise the fee by replacing it, provided the increase is large enough to be worth the node's attention. This is the mechanism behind fee bumping, and it is a policy rule rather than a consensus one.

Why it is node-local

There is no global mempool, and this is the fact most often lost in discussion of fee rates. Each node holds the transactions it has happened to receive, subject to its own policy, and the sets differ between nodes for entirely ordinary reasons. A node that was offline for an hour missed whatever arrived during that hour. A node with a higher minimum fee rate never accepted the cheap transactions in the first place. A node that evicted entries under pressure holds fewer than one with more memory. Two honest nodes can therefore disagree about what is pending without either being wrong.

This is why a fee estimate is a prediction rather than a reading. When a wallet asks a node what fee rate is likely to confirm a transaction soon, the node is answering from its own view of its own store, and that view is a sample rather than the whole. The estimate is useful because most nodes see most transactions most of the time, so the samples agree broadly. It is not exact, and it cannot be, because the thing being estimated does not exist as a single object.

The same reasoning explains why a transaction can appear stuck on one explorer and pending on another, and why a transaction that seems to have vanished may simply have been evicted from the nodes an observer happened to query. The node verification page sets out the checks a transaction passes before it is held at all, and the UTXO model page explains what a transaction spends when it is finally confirmed.

Sources

  • Bitcoin Developer Guide, P2P Network — transaction relay and the mempool as a node-local store.
  • Bitcoin Core, policy documentation — minimum fee rate, eviction and replacement rules.
  • Bitcoin Core, developer notes — the reference implementation's mempool implementation.