What is the limit of transactions Ethereum clients can keep in transaction pool?
Geth can keep 64 transactions per address according to this answer, but what is the max size of total transactions in txpool?
txpool
What is the limit of transactions Ethereum clients can keep in transaction pool?
Geth can keep 64 transactions per address according to this answer, but what is the max size of total transactions in txpool?
Best Answer
Summary
It is limited by your computer's memory.
From my basic testing in What happens when a transaction nonce is too high?, I crashed
geth
with 400 x 64 transactions with a data payload of 4,500 bytes when running in 4 Gb RAM.I am assuming that your question is asking what is the maximum number of transactions that can be stored in the transaction pool. If you are asking what is the maximum size of a single transaction, the answer is at Is there a limit for transaction size?.
Details
There is a pool for pending transactions and a queue for transactions that are not ready to be processed.
The data structure representing the transaction pool in geth can be seen at go-ethereum - tx_pool.go, lines 54 to 77:
From stackoverflow.com - Maximum number of elements in map, the maximum number of elements that can be stored in a Go map data structure is
2147483647
for 32-bit architecture and9223372036854775807
for 64-bit architecture.Pending Transaction Pool
Pending transactions are stored in
TxPool.pending
that is amap(transaction hash -> pointer to transaction)
. In go-ethereum - tx_pool.go, there is no limit check to the number of transaction when adding transactions to this data structure.The number of transactions in the pending transaction pool is effectively limited by memory.
Transaction Queue
Queued transactions are stored in
TxPool.queue
that is amap(from address -> map(transaction hash -> pointer to transaction))
. In go-ethereum - tx_pool.go, there is a check that the number of transactions from the sameFrom
address does not exceedmaxQueued = 64
.The number of transactions in the transaction queue is effectively limited by memory, with the limitation that there can only be a maximum of 64 transactions for transactions with the same
From
address.What is the difference between a pending transaction and a queued transaction?
Pending transactions are transactions that are ready to be processed and included in the block.
Queued transactions are transactions where the transaction nonce is not in sequence. The transaction nonce is an incrementing number for each transaction with the same
From
address.For example:
0xaaaa...aaaa
with nonce 0 has been included in the blockchain.0xaaaa...aaaa
with nonce 1 has been included in the blockchain.0xaaaa...aaaa
with nonces 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 as sent to an Ethereum node. These are placed in the transaction queue as the transaction from account0xaaaa...aaaa
with nonce 2 has not been seen by the Ethereum node.0xaaaa...aaaa
with nonce 2 is added to the transaction pool, the 10 transactions with nonces 3, 4, 5, 6, 7, 8, 9, 10, 11 and 12 will be moved from the queue to the pending transaction pool and all 11 transactions are ready to be processed and inserted into into the blockchain (provided there is enough gas).