4

Consensus Logic with an example

  1. Person A generates a transaction to pass some ether to person B
  2. The transaction is submitted on the node
  3. Node then passes that unconfirmed transaction to the whole connected network
  4. The miners pickup the unconfirmed transaction
  5. They start trying to randomly generate the nonce to find the correct hash
  6. So one of the miners finds the correct nonce to generate the block
  7. Now this miner sends this block to peer who then further send to the next peers and gradually everyone receives the block
  8. Everyone verifies the work whether it is meeting the criteria
  9. Once satisfied they include that block in their ledger
  10. Miner gets rewarded
  11. B's balance gets updated
  12. Thus A's payment is now confirmed
  13. Just like A think multiple transactions of passing ether were invoked at the same time
  14. Lets say from C->D, E->F, G-H etc.

Questions:

  1. In Ethereum how does a miner determine how many transactions to be included in the block?
  2. Is it based on total count of transactions or total price or total size?
  3. Is there a concept of wait time also applied i.e. if there are less unconfirmed transactions the miners will wait for certain time and then group all the available transactions to generate a block?

2 Answers 2

3

Q1 and Q2: the number of transactions in a block is governed by the block gas limit - a computational limit representing the maximum amount of computations that a miner will undertake to execute the full set of transactions in any given block. Each transaction will be formed from a set of instructions and a gas price is associated with each instruction. Gas prices are published in the appendix G of the Ethereum yellow paper.

Q3: strictly speaking there is no direct wait time (measured in raw time). The difficulty of the proof of work computation is however set such that the time between block creations averages to a pre-defined interval which is known to maintain a stable system.

If there are no transactions in that interval then a block is still generated. This is still useful as new blocks will re-enforce earlier blocks.

Miners are also rewarded for the transactions included in a block they mine successfully, therefore they are incentivised to include as many transactions they can - within the block gas limit. This dis-incentvises miners from trimming the list of transactions they include in a block, though a miner could, strictly speaking do this. If all miners would adopt such a strategy then there would be a loss of efficiency (transaction backlog grows), but the integrity of the blockchain is not lost.

5
  • Thanks a lot for replying! What i understood is gas limit for a block is different to transaction gas limit. While including the transactions it sums up each gas limit individually and then verifies whether it is exceeding the block gas limit. If so then the last transaction is not included and the block finalized to get processed. So what is the block gas limit? Does that change if so on what basis?
    – Susmit
    Commented Apr 13, 2017 at 14:08
  • 1
    Indeed: there are separate gas limits for both transactions and blocks. For more details see: bitcoin.stackexchange.com/questions/39132/…
    – zanzu
    Commented Apr 13, 2017 at 14:13
  • Thanks for sharing this link! But didn't find the block specific gas limit in it
    – Susmit
    Commented Apr 13, 2017 at 15:24
  • 1
    It is in the 3rd paragraph of the top answer, with details in reference [3] in the same response.
    – zanzu
    Commented Apr 13, 2017 at 15:30
  • To test I generated 300 transactions in my private blockchain. Every time it created 3 blocks i.e. 1st one 119 2nd one 119 and last one 62 transactions. When I checked the block header for 119 transactions it is around Gas Limit 4,712,388 m/s Gas Used 4,635,407 m/s, second one Gas limit 4,714,578 m/s Gas Used 4,635,407 m/s. So does that mean that the gas limit for block header is some where 4,714,578?
    – Susmit
    Commented Apr 13, 2017 at 17:29
3
  1. The miner influences which transactions are included in the block. He is incentivized however to include as many txs with high gas prices as he can in order to receive maximum compensation

  2. Yes, every block has a gas limit, so if there are too many unconfirmed TXs, not all of them will be included in the block. Instead, transactions will be processed until the block gas limit is reached. This gas limit is around 4.000.000 at the time of writing. The protocol allows this limit to adjust dynamically (~0.09% per block) relative to network utilization. So Ethereum is built to gradually adjust to a higher utilization.

  3. To my knowledge, there is no such thing as a waiting time. If a miner can guess the required hash, the block is mined. If it wouldn't, there would never be a block with lower gas usage and thus no downward gas limit adjustment.

5
  • Thanks for your reply Simon! Can you please elaborate (~0.09% per block) point. does that mean gradually more transactions will be included in a single block i.e. gas limit of a block will be increased.
    – Susmit
    Commented Apr 13, 2017 at 14:10
  • Miners do influence the number of transactions in their block, and in fact they have complete control of that. A miner may include as many or few transactions as they like, so long as the total gas limit stays under the block gas limit. Additionally, the gas limit adjustment is influenced by the miner, who is allowed to adjust the limit up or down by a small percentage. Commented Apr 13, 2017 at 14:36
  • Tjaden can you please share some reference to this view
    – Susmit
    Commented Apr 13, 2017 at 15:26
  • Thanks for pointing that out @TjadenHess. Would you agree that usually, a miner does not make use of this power? He is incentivized to include as many txs as he can and take the ones with higher gas price to obtain maximum payout.
    – simonDos
    Commented Apr 18, 2017 at 9:20
  • @Susmit Afaik, yes, as long as the network utilization (number of pending transactions) exceeds the blocks gas limit, it will be adjusted upward by 1/1024 (0.09%) per block
    – simonDos
    Commented Apr 18, 2017 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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