21

I'm running a private Ethereum blockchain. When I set one of the nodes to mine, that node continuously creates blocks, even if there are no transactions inside of it. What is the purpose of this?

0

3 Answers 3

20

A benefit of a blockchain is that it is append-only with, in practice, immutable past blocks.

These past blocks are immutable because it is very difficult (via proof-of-work) to create a competing block that "rewrites history". Plus, you have to take into account the fact that subsequent blocks add their own difficulty. So to change a block in the past, and be accepted by other nodes, you need to change that past block and all those that came thereafter.

So to come back to your question, those empty blocks are constantly adding new layers of difficulty to ensure the practical immutability of past blocks.

The awarding of new Ethers is there to incentivise miners to protect past blocks.

3
  • This answer is as good as it could be, but you might explain the reason why it's happening more often now than it has in the past because of the recent Dos attacks. I'm not sure why that is. Perhaps you can add an explanation of why it's happening now more often then before. Oct 14, 2016 at 22:39
  • 1
    When miners receive a new valid block, they need to switch to mining on the next block. However, before they can start mining, they need to decide what to put in the next block. This takes a non-zero amount of time. Therefore, during the interim, miners either keep mining on the old block in the hope of securing an uncle reward, or they start mining immediately on an empty next block in the hope of securing a full reward. When the new non-empty block is ready to mine, they can start mining on it. But it may well have happened that the empty block was mined in the interim. Feb 19, 2020 at 8:26
  • 1
    I came here for the same issue. Rarely have I seen such a clear and precise explanation as this one. Not only limited to the "how", but also explained the "why". Bravo.
    – Magno C
    Aug 11 at 18:47
10

On a public chain, it makes perfect sense to keep creating blocks, because a miner will still get the 5 ETH block reward, with or without transactions inside. Thus, geth will continuously mine as long as it is told to do so. It doesn't know that the chain isn't public. It is possible to write a script to control geth's mining. See this question.

If you are looking for a private blockchain to test dapps, a simulator such such as testrpc will likely be more suitable than a genuine full node. testrpc only "mines" when there is a transaction, and this mining is simulated--no actual hashing occurs.

6

In the ethereum blockchain we creates blocks every N time (15 s) check https://etherscan.io/charts/blocktime

we do that for 2 purpose :

1-include transactions.

2-generate new Ethers.

If there is no transaction to include or the miner refuses to include them then he crates a new block without transactions, but containing the rewarded Ethers.

so a block could contains no transaction inside it, but keep in mind that a validated block need some confirmations (additional blocks after it) to be more reliable [12 confirmations for making "irreversible" changes to data].

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