[Ethereum] How many transactions are there in a block


If a block acts as a ledger of transactions, how many transactions can fit in a block?

I have to setup a private test net where only one machine is allowed to mine while (many) others are performing transactions on its blockchain (the miner also sets up the genesis block). What happens if the number of transactions exceeds the maximum allowed number of transactions in a block?

Best Answer

The following is a simplified explanation of what geth does.

There are two main places where transactions can be: in a block, or in the transaction pool (txpool).

When a node first hears about a transaction, it puts it in the txpool. These are essentially zero confirmation transactions. There's a number of ways to access this, most particularly the "pending" psuedoblock in web3.

When a node starts to mine, it will take the highest-paying transactions in the txpool, one-by-one, and execute them. When it runs out of the gasLimit or transactions in the pool, it commits to mining that specific block. (This appears in the console as something like "commit new work on block X with Y txs...") It then continues hashing that block until it finds a hash that is sufficiently rare enough for the block to be accepted by the network.

Every other transaction, whether it was received before it started work on the block but could not use it for some reason, or whether it received it afterwards, remains in the txpool until it is mined, or becomes permanently invalid for some other reason.

Related Topic