1

I'm a bit new to blockchain and I am trying to understand.

As I understand when a new transaction happens it's added to a mining pool and miners prioritize these transactions (for example by amount of fee) and select some transactions to add them to block (max 1MB).

But it's also possible for some block to be empty (without transactions).

So, if some blocks are empty, does this mean that new block creation starts at certain times? (Does it have some schedule like every 5 min or something like that?)

Or does something trigger miners to create a new block?

1
  • There hasn't been a 1MB block size limit for many years now. Since Segwit activated blocks have been bigger on average.
    – Jannes
    Mar 7, 2022 at 15:58

1 Answer 1

3

The flow of a transaction is like this:

  • Users create and submit transactions
  • Nodes gossip the transaction in the network, validating them, adding them to their mempools and forwarding them
  • Miners select transactions from their mempools to build block templates
  • A new block is found that includes the submitted transaction and the transaction is confirmed

Miners mine continuously—each of them is always trying to find a new block. A block is found when a block header hashes to something that is lower than the difficulty target. There is no way to know whether a block header candidate is a valid block until it is hashed. Since every miner is trying to pay themselves the mining reward, they all have unique block templates (as their transactions don't match, the Merkle root of the transactions differs). This means that every miner is searching previously unseen block candidates and finding a new block essentially comes down to an independent random event with a minuscule chance for every block template. Sometimes it only takes seconds for a new block to be found, and sometimes it takes more than an hour. The difficulty retargets automatically to keep the expected block interval to about 10 minutes.

Miners continuously update their block templates whenever they hear about new transactions. As you said, they pick the transactions with the highest feerates, to build the block template that will collect the most fees.
When miners hear about new blocks, they briefly use an empty block template that doesn't include any transactions. The miners do this to avoid including a transaction that the previous block already included which would make their new block be in conflict and invalid. As soon as the miners have processed the previous block, they build a new block template with transactions again and use that. So, we usually only see empty blocks if a new block is found seconds after a previous block, or if there are actually no transactions waiting to be confirmed.

4
  • Nice answer which changed my perspective :) But just a small question for clarification. U said, "miners do this to avoid including a transaction that the previous block already included which would make their new block be in conflict and invalid." But why there are instead of just stopping the creation process and look new transactions there are creating new empty blocks? (For earn award?)
    – Murad Sofi
    Mar 7, 2022 at 15:20
  • And U said "or if there are actually no transactions waiting to be confirmed". if there are see new transactions not exist why instead of stoping there are creating an empty block? So let's say if in some blockchain not any transaction exist mining process will continue?
    – Murad Sofi
    Mar 7, 2022 at 15:23
  • 1
    The reward for mining a block is composed of two parts: the transaction fees, and an amount of new bitcoins to be created. The miners can still collect the new coins even if they do not include any transactions. Since the transaction fees are only a small part of the block reward right now, mining empty blocks is still very profitable.
    – Murch
    Mar 7, 2022 at 15:33
  • 1
    The miners don't know if they only saw a transaction after it was included in the previous block, therefore it just being new to them is insufficient for putting it in their block template. They have to finish processing the previous block to know which transactions can be safely included.
    – Murch
    Mar 7, 2022 at 15:34

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.