1

I have a question about getting transactions from mempool to be added to block. Imagine the situation where we have 500 transactions in mempool, when we decide that is enough to start adding them to the block? Also what if we sre in the middle of mining (so we have Merkles tree root already) and the new transaction is added to the mempool? The process of our mining in my node is starting again?

3 Answers 3

1

You can start to work in a block at any moment, you can even mine an empty block. If any new transaction arrives you rebuild the merkle tree and continue.

2
  • So there is a possibilty to choose how many transactions is ok to start minning? Will the adding new transaction to potential block reset the minning (reset the nonce to zero)?
    – Konrad
    Jan 27, 2019 at 11:58
  • One don't need to reset the nounce. One can choose any nounce in any order.
    – Osias Jota
    Oct 2, 2019 at 18:46
1

While mining is done by specialized hardware, transaction choosing and merkle root calculating is done by the node software. While the specialized hardware is mining, a node may (and will) update its mempool continuously, and will calculate a new merkle root every few seconds. The mining hardware will check for header-template updates often, (and this instantaneous process is done without needing a restart), and will continue mining. The interval of header updates is chosen by the pool, and one of the aims is not to do it too often, or it'll waste the bandwidth

5
  • I'm not sure that I understand, I thougt that merkle tree is taken to the block, so updating list of transactions will somehow start minning again? (Reset the nonce to zero)
    – Konrad
    Jan 27, 2019 at 11:56
  • Yes, they can reset the nonce.
    – MCCCS
    Jan 27, 2019 at 12:32
  • So this will not complicate mining? I mean after reseting the nonce we are starting again so we are not as close to winning as we were before reseting the nonce (I guess)
    – Konrad
    Jan 27, 2019 at 13:20
  • 1
    No, reseting the nonce with a different block template is not repeating the same POW, as the header hash will be different with the same nonce. (Same nonce, but different merkle-root)
    – James C.
    Jan 27, 2019 at 15:15
  • Increase or decreasing a nounce don't make you any closer or far from finding a block. Otherwise you would just go straight to the highest nounce. Any order you try nounces is good.
    – Osias Jota
    Jan 28, 2019 at 0:45
1

Producing the optimal block-template to mine is a NP-hard problem.

The optimal block-template includes the highest sat/byte(or weight) transactions to maximise the miner reward. Assuming this computation and propagation of the perfect block-template took no time, it would make sense to update the block-template for each new transaction accepted to the memo-pool, as this new transaction could potentially increase the block reward. In this hypothetical scenario, the mining hardware is continuously working (hashing) and continuously updating the block header for a better block reward.

However, since producing the optimal block-template is NP-hard, it takes significant time/cost to compute the optimal block-template from the mempool at any point in time:

  • Knapsack problem - maximise total fee value in block
  • Maximum independent vertex set - ensure no two tx spend the same output.

Both problems scale exponentially and are expensive. This cost could have been invested in more hash-rate.

Therefore, there is a trade-off between block optimisation and mining utilization.

  • Continuously optimising for a better block-template represents a cost in itself, which could be invested in more mining hash rate.
  • There exists a financial optimum, where suboptimal blocks-templates are mined, whilst mining equipment is fully utilised.
  • (One extreme could be mining empty blocks, maximising the number of hashes performed, whilst spending zero resources in block optimisation.)
  • In practice, simplified heuristics are used to update new block-templates cost-effectively as mining is being performed.

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.