Bitcoin

What Is the Bitcoin Mempool? [All Questions Answered]

If you’re following the crypto universe for a while, you will hear about the name ‘Mempool’, which is mentioned at a time when some  Bitcoin transactions are stuck.

So today, in this post, I’m going to explain exactly what Mempool is and how it plays an important role in the bitcoin blockchain.

Don’t worry, I’ll explain the concept simply by avoiding technical terms.

What Is Bitcoin Mempool?

Bitcoin Mempool. AKA Bitcoin Memorypool is a waiting room for the new Bitcoin transaction before getting confirmation for going to the blockchain.

In technical terms, Mempool is the intermediate temporary memory where all the in-motion transactions are stored.

Once transactions arrive at mempool, miners select them to verify for adding into the blockchain.

What Exactly Happens Inside Mempool?

When any transactions occur in the Bitcoin network that can’t be added to the Bitcoin blockchain automatically. the transaction has to pass certain steps and criteria for it to become a valid transaction.

Firstly a transaction goes to a full node (full node is a node that has a complete copy of Bitcoin blockchain), and nodes have to check if the transaction is valid or not by checking the transaction following certain criteria mentioned below.

1. Check syntactic correctness.

2. Make sure neither in or out lists are empty.

3. Size in bytes < MAX_BLOCK_SIZE.

4. Each output value, as well as the total, must be in legal money range.

5. Make sure none of the inputs have hash=0, n=-1 (coinbase transactions).

6. Check that nLockTime <= INT_MAX, size in bytes >= 100, and sig opcount <= 2.

7. Reject “nonstandard” transactions: scriptSig doing anything other than pushing numbers on the stack, or scriptPubkey not matching the two usual forms.

8. Reject if we already have matching tx in the pool, or in a block in the main branch.

9. For each input, if the referenced output exists in any other tx in the pool, reject this transaction.

10. For each input, look in the main branch and the transaction pool to find the referenced output transaction. If the output transaction is missing for any input, this will be an orphan transaction. Add to the orphan transactions, if a matching transaction is not in there already.

11. For each input, if the referenced output transaction is coinbase (i.e. only 1 input, with hash=0, n=-1), it must have at least COINBASE_MATURITY (100) confirmations; else reject this transaction.

12. For each input, if the referenced output does not exist (e.g. never existed or has already been spent), reject this transaction.

13. Using the referenced output transactions to get input values, check that each input value, as well as the sum, are in legal money range.

14. Reject if the sum of input values < sum of output values.

15. Reject if transaction fee (defined as sum of input values minus sum of output values) would be too low to get into an empty block.

16. Verify the scriptPubKey accepts for each input; reject if any are bad.

17. Add to transaction pool.

18. “Add to wallet if mine”.

19. Relay transaction to peers.

20. For each orphan transaction that uses this one as one of its inputs, run all these steps (including this one) recursively on that orphan.

When these criteria full-filled, nodes store the transaction for passing it to miners who find correct nonce value using hardware for adding it to Bitcoin blockchain, by doing so miners receive the reward.

Simple process, right… But where is the mempool…?

Now shedding light on the important point ‘Mempool’.

In this validation process, when a full node verifies the transaction, the transaction is put on the waiting list because the Bitcoin blockchain is big and transactions are occurring every second, but the infrastructure to handle all the transactions is lacking, so transactions have to wait within the node.

This node’s holding area for all the pending transactions is called ‘Mempool’.

What Happens When the Node’s Memory Gets Full?

Full nodes have a different RAM capacity to store unconfirmed transactions, some nodes rapidly fill up, or some nodes still have space to process transactions.

To balance this inequality, Bitcoin Core version 0.12.0 released, introducing ‘Mempool’.

Before this version, if a node mempool maxed out its RAM, the node would just crash and restart with an empty Mempool.

After the core version, if a node’s Mempool size gets too close to the RAM capacity, the node sets up a minimal fee threshold. Transactions with fees per kB lower than this threshold are immediately removed from the Mempool, and only new transactions with a fee per kB large enough are not allowed access to the Mempool.

Impact of New Block on Mempool.

If you see the mempool chart, it has many fluctuations because when a node receives a fresh mined block, it removes all the mempool transactions as well as the transactions that have conflicting inputs.

As a result of this cleaning process, you see the sharp dips and drops in the mempool size.

Importance of the Mempool.

The Mempool idea is a part of BIP 35(Bitcoin Improvement Protocol 35).

The main intention behind Mempool creation is to allow outside nodes to access the other nodes’ mempool because of the following several use cases.

  • SPV clients(also known as lite wallets) wishing to obtain zero-confirmation transactions sent or received.
  • Avoiding Miners opportunity to miss lucrative fee transactions or download the current “transaction waiting list” in order to start confirming transactions.
  • Remote network diagnostics to several attacks like DDoS.

Problems With Mempool.

Until now, you know how mempool helps Blockchain to process the transactions, but on the contrary, there are some problems with the mempool’s existence to the whole network.

Here I’m sharing some of those problems.

  • Getting accurate datas about the Mempool is difficult because there are thousands of nodes holding different sizes of mempools, so the raw data is sparse and sometimes inconsistent. This makes definitive mempool data difficult to capture.
  • In the decentralized Blockchain structure, nobody says what is happening inside the mempool. Typically when a node receives the transaction and broadcasts it out for confirmation if the transaction gets stuck or lost, no central authority can tell what’s going on or help to resolve the situation.
  • Mempool transactions can be overwritten with a replacement transaction; this is not like an on-chain transaction that is immutable.

Conclusion.

Mempool has its own merits and demerits on the blockchain, but the existence of mempool is more beneficial to the blockchain and the user.

Because of mempool, many transaction accelerators came forward to boost unconfirmed transactions, and we have a rough picture about the pending transaction size on the network, also avoiding many attacks on the network.

So what is your takeaway from the concept of  Mempool?

If you got some valuable insights from the post, then don’t forget to share them with your family and friends.

Do Share This Useful Info With Your Family and Friends.