Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: BoyFromDubai on December 21, 2022, 12:22:22 PM



Title: Do nodes share their mempool with each other?
Post by: BoyFromDubai on December 21, 2022, 12:22:22 PM
When a new node connects to the network, other nodes start to share new transactions with this new node they got. But do they share their mempool, when a node disconnects from the network for some time for example? I think that the mempool size is too large and it would be difficult to share their mempool state, but maybe I'm wrong...


Title: Re: Do nodes share their mempool with each other?
Post by: pooya87 on December 21, 2022, 12:37:52 PM
There is a "mempool" message defined in the P2P protocol that the nodes can send each other to receive a list of transaction hashes that is in the other node's mempool and then request to receive any of the transactions they don't have using a "getdata" message.


Title: Re: Do nodes share their mempool with each other?
Post by: PawGo on December 21, 2022, 12:38:59 PM
When a new node connects to the network, other nodes start to share new transactions with this new node they got. But do they share their mempool, when a node disconnects from the network for some time for example? I think that the mempool size is too large and it would be difficult to share their mempool state, but maybe I'm wrong...

Think about it that way - transaction could be unconfirmed (is stored in the mempool) or confirmed (kept in block chain). Each new transaction must be populated  and known to other nodes - otherwise miners would not be aware given transaction exists and will not be able to include it in their mined blocks.

Why do you think mempool is 'too large' to be synchronised?


Title: Re: Do nodes share their mempool with each other?
Post by: hZti on December 21, 2022, 04:11:00 PM
But do they share their mempool, when a node disconnects from the network for some time for example?

When the node goes offline it will not share any information, it will simply be updated as soon as it comes back online.


Quote
I think that the mempool size is too large and it would be difficult to share their mempool state, but maybe I'm wrong...

The mempool is quite small as it will only contain unconfirmed transactions (usually a few MB). If a transaction has a too small fee, it will be deleted from the mempool after some days, so the mempool will never be to big.

What you maybe mean is the blockchain, that is a few hundred GB of data. This will indeed take some days to synchronies if you start your node for the first time.


Title: Re: Do nodes share their mempool with each other?
Post by: witcher_sense on December 21, 2022, 04:56:04 PM
When a new node connects to the network, other nodes start to share new transactions with this new node they got. But do they share their mempool, when a node disconnects from the network for some time for example? I think that the mempool size is too large and it would be difficult to share their mempool state, but maybe I'm wrong...
A particular full node has its own subjective view regarding what to consider valid in the blockchain: it receives pieces of information from other nodes, verifies if everything is okay, and adds transactions to its local temporary storage of yet-to-be-confirmed financial transactions. Mempool is a completely optional feature: you, as an operator of your personal node, can decide whether to allocate memory for those unconfirmed transactions or not. The only drawback of you not having a mempool is that you can't tell other nodes about unconfirmed transactions, and you even can't see them until they get into the mined block. Some will say that without mempool, you will have an incomplete picture of the blockchain, and your node should no longer be considered "full" because you can't conduct full verification.


Title: Re: Do nodes share their mempool with each other?
Post by: BitDane on December 21, 2022, 09:28:58 PM
Nodes serves as gateway to the mempool[1] so there is a need for nodes to share their mempool with each other in order for other nodes (peers) to perform its own check for the validity of transactions.

Quote
If the transaction passes the node's checks, the transaction is added to the node's mempool. That node will also broadcast it to other nodes, called peers. Each of these peers will perform its own checks — adding valid transactions to its mempool and then broadcasting the transaction along to its peers.

Here is a good presentation by Babypips about how mempool is shared by nodes[2]

It was stated that every node on Bitcoin network share information about new transaction, since transaction is not directly added to the blockchain they are first collected and stored at mempool.  Then these nodes communicate with its peers to check the validity of transaction on after performing its own check and adds valid transaction to the mempool.  



[1] https://www.blocknative.com/blog/mempool-nodes
[2] https://www.babypips.com/crypto/learn/what-is-a-mempool#:~:text=Also%20known%20as%20%E2%80%9Cmempool%E2%80%9D%20for,to%20a%20newly%20created%20block.


Title: Re: Do nodes share their mempool with each other?
Post by: BlackHatCoiner on December 21, 2022, 09:52:20 PM
But do they share their mempool, when a node disconnects from the network for some time for example?
A node that disconnects from the network has to come back online, and reach the chain tip to start receiving unconfirmed transactions. Obviously they can't share the mempool with an offline computer.

Then these nodes communicate with its peers to check the validity of transaction on the mempool.
They communicate to exchange unconfirmed transactions. Not to check / question its validity. That happens locally, and is done by each node individually.


Title: Re: Do nodes share their mempool with each other?
Post by: BitDane on December 22, 2022, 07:57:55 AM
Then these nodes communicate with its peers to check the validity of transaction on the mempool.
They communicate to exchange unconfirmed transactions. Not to check / question its validity. That happens locally, and is done by each node individually.

Thank you for the correction and I stand corrected, yeah they communicate exchange information about unconfirmed transaction, no excuses I messed up there  ;D.
I messed up this line
Quote
Each Bitcoin node has its own mempool, where it stores the queue of transactions that it has checked and considers valid.

In addition we can also see the difference of mempool and blockchain function in this quotation.

Quote
The memory pool holds “fresh” or unconfirmed transactions (stored as individual transactions).
The blockchain holds “archived” or confirmed transactions  (packaged in “blocks”).



Title: Re: Do nodes share their mempool with each other?
Post by: maikrothaman on December 23, 2022, 02:55:51 AM
When a new node connects to the network, other nodes start to share new transactions with this new node they got. But do they share their mempool, when a node disconnects from the network for some time for example? I think that the mempool size is too large and it would be difficult to share their mempool state, but maybe I'm wrong...

I'm not a programmer. I believe it is possible to spam the mempool if nodes would keep the entire mempool. A single person can generate 1M transactions by burning 0.5 BTC. The mempool would be unable to store all of the valid transactions due to RAM usage. I suppose some nodes might keep some mempool transactions while keeping others on different nodes.


Title: Re: Do nodes share their mempool with each other?
Post by: pooya87 on December 23, 2022, 03:00:54 AM
I'm not a programmer. I believe it is possible to spam the mempool if nodes would keep the entire mempool. A single person can generate 1M transactions by burning 0.5 BTC. The mempool would be unable to store all of the valid transactions due to RAM usage. I suppose some nodes might keep some mempool transactions while keeping others on different nodes.
This type of spam like any other type of spam requires paying a lot of fee in total specially since it also increases the fee so for example if they start at 1 sat/vb they will increase it to 100 sat/vb while their older transactions with low fee would be dropped out of mempool.
With 0.5BTC you can only create about roughly 100k transactions not a million.


Title: Re: Do nodes share their mempool with each other?
Post by: NotATether on December 23, 2022, 04:08:57 AM
I'm not a programmer. I believe it is possible to spam the mempool if nodes would keep the entire mempool. A single person can generate 1M transactions by burning 0.5 BTC. The mempool would be unable to store all of the valid transactions due to RAM usage. I suppose some nodes might keep some mempool transactions while keeping others on different nodes.
This type of spam like any other type of spam requires paying a lot of fee in total specially since it also increases the fee so for example if they start at 1 sat/vb they will increase it to 100 sat/vb while their older transactions with low fee would be dropped out of mempool.
With 0.5BTC you can only create about roughly 100k transactions not a million.

Assuming average tx size is 200vb, then that would take up 20MB of a mempool.

You'd have to burn around 7.5BTC to fully exhaust everyone's mempool.

Anyway, the fact that it costs 5 digits to pull off a successful mempool spam attack for no material gain shows how strong Bitcoin (and the Bitcoin price in particular) has become.


Title: Re: Do nodes share their mempool with each other?
Post by: gunhell16 on December 23, 2022, 01:06:03 PM
When a new node connects to the network, other nodes start to share new transactions with this new node they got. But do they share their mempool, when a node disconnects from the network for some time for example? I think that the mempool size is too large and it would be difficult to share their mempool state, but maybe I'm wrong...

As far as I know mempool is like a waiting buffer or a waiting place for all the unconfirmed transaction before they are added to the
blockchain. While the Nodes is the computer that run the network software. Or in other terms it forms a network where
information can be shared or transacted.

Where the major function of Nodes are routing, storage, mining and wallet services. So if you know the difference beween Nodes and the mempool dude, You can able to find the right answer to your question anyway.








Title: Re: Do nodes share their mempool with each other?
Post by: BlackHatCoiner on December 23, 2022, 01:45:52 PM
You'd have to burn around 7.5BTC to fully exhaust everyone's mempool
And let's not forget that if some crazy multi-millionaire ever thought of executing this meaningless attack, nodes could just adjust the mempool size limit and make it ever more costly to do it again.

Anyway, the fact that it costs 5 digits to pull off a successful mempool spam attack for no material gain shows how strong Bitcoin (and the Bitcoin price in particular) has become.
It also shows that the block space is expensive. If block size was 10 MBs, spamming the UTXO set (or blockchain in general) would be about 10 times cheaper. See what happens with BSV, where they have 1 GB blocks, and some even store movies in.


Title: Re: Do nodes share their mempool with each other?
Post by: citb0in on December 23, 2022, 03:36:00 PM
When a new node connects to the network, other nodes start to share new transactions with this new node they got. But do they share their mempool, when a node disconnects from the network for some time for example? I think that the mempool size is too large and it would be difficult to share their mempool state, but maybe I'm wrong...

No, the mempool is locally on each node and is not shared. A node (or better said the node operator) can decide for itself which transactions to pull and include in the local mempool, it can be configured on the node which transactions should be considered for a new block creation and on which criteria (thresholds) based upon.