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?


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.

| improve this answer | |
  • so who sets the block gas limit and how does it get updated periodically so new blocks can be mined? – user1870400 Feb 21 '19 at 10:58
  • Each miner can adjust the block gas limit up or down by a certain percentage. In practice, the majority of miners reach an agreement to set it at given number, and it doesn't effectively deviate from there. Each new block has a fresh gas limit, ready to be used by new transactions. – Matthew Schmidt Mar 1 '19 at 0:11

Usually in a private test network periodically empty blocks are mined.Maximum Number of transactions in the block depends on the maximum block size. About maximum block size in ethereum just refer this link

Maximum block size

| improve this answer | |
  • Thanks but this doesn't really make sense (not to put a limit on the block size). I mean why mine for new blocks when they're essentially not needed. – Sebi Jun 7 '16 at 10:51
  • What if in the testenet I set the initial gas limit for the first (mining) account to be 32 0xff bytes? Isn't that the absolute maximum amount? – Sebi Jun 7 '16 at 10:53
  • mining the empty blocks in a test network just gives you number of ethers. – Subhod I Jun 7 '16 at 12:14
  • 2
    @Sebi you can't know a block will be empty until it ends, so you have to mine it anyway. – Nicolas Massart Jun 7 '16 at 15:49
  • I was asking what would happen if there were too many transactions before the block could be mined? A large number in a sense that more than a block can hold. – Sebi Jun 7 '16 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.