crypto.bi – ELI5 Cryptography, cryptocurrency and programming

ELI5: What is the Bitcoin “mempool”?

You may have heard the term “mempool” a lot recently, especially during the recent attacks on the Bitcoin network when the number of unconfirmed transactions rise a lot, fueling rumours of flippenings and collapses that never happen. There is a relation between unconfirmed transactions and the mempool, which we’ll look at next.

As you may have guessed, mempool is a portmanteau of memory pool. In this article we discuss where is this memory is located and why it is called a pool.

The Memory Pool

The memory it refers to is the total of all Bitcoin nodes’ ephemeral RAM and disk storage – that is, transactions that may even be on a node’s disk, but are not yet on the blockchain. Remember : in Bitcoin, the only permanent storage is the blockchain.

Bitcoin works as a P2P network of nodes, similar to BitTorrent.

To begin a coin transfer, one participant crafts a well formatted chunk of data called a transaction and they send it to the next guy they can reach on the network.  When the Bitcoin Core client starts up, it tries to locate peers nearby. As this list of peers is built, the node is then able to send and receive transactions from the network.

One node may have knowledge of pending transactions that other nodes don’t. There’s an intense exchange of messages between nodes in order to guarantee that the collective mempool is as consistent as possible. But the only truly consistent source of truth on the Bitcoin network is the blockchain.

Tx Propagation

There is a delay between the time this data is sent between peers and propagates on the network and the time when a mining pool or large scale solo miner will take that chunk of data and commit it to the permanent blockchain. During this period, the transaction is stored in the nodes’ memory (RAM or disk, doesn’t matter).

Since Bitcoin is a P2P network, all this memory and disk space adds up to terabytes of space, which is Bitcoin’s memory pool or, you guessed it, mempool.  Every Bitcoin transaction is first sent to the mempool, it is mined later when the pools decide to include this transaction on the next block.

What if the Mempool fills up?

One of the attacks attempted on the Bitcoin network was to try to “fill” the mempool with useless transactions. Since transactions have to be mined in order to clear the mempool, if you were able to overwhelm the mining power with enough bogus transactions, then you could, in theory, fill the mempool.

If the Bitcoin network runs out of space to temporarily store its transactions before they are mined, those transactions will be lost. It’s as if they were “forgotten” in a sea of transactions.

In this case a miner will never see the transaction and the funds never will have moved. But the client which sent the transaction assumes it went through, showing a lower (and incorrect) balance than the user really has. Although no money is lost, because the transaction is never committed to the blockchain when a transaction goes missing, it does cause a lot of headaches and user complaints. When this happens, social media usually gets flooded with complaints and FUD about the end of Bitcon and how it “doesn’t work”.

Can mempool transactions get lost?

Yes in theory, but very unlikely in practice.

Yes, because in theory if every node who knew of a transaction got suddenly turned off, for some reason, then that transaction would be lost. That includes the node that originally sent the transaction, otherwise it’ll keep trying to resend it to nearby peers.

This is a very unlikely event, though. Let’s think of a scenario where completely forgetting about a transaction would be feasible. One node sends out the transaction when it’s likely connected to 100 or so other nodes. Each of those nodes is also likely connected to tens or hundreds of other nodes.

So, the original sender would have to be turned off, and every one of its peers, and all their own peers, would also need to forget the transaction somehow before it reaches a miner that decides to include it on the next block. Only an event of catastrophic proportions could trigger such a sudden loss of connectivity and ephemeral data. Or the Bitcoin network would have to be so small, with such few users, that suddenly messages aren’t get relayed enough.

For all practical purposes, Bitcoin transactions go viral once they’re broadcast. Some transactions may take a long time to get mined during peak mempool usage times, especially if they carry a low fee, but they likely will get mined some time in the future.

Links

Mempool Space – mempool stats

BTC Mempool at Blockchain.com

Mempool at Binance Academy

Exit mobile version