So, Bitcoin block consists of some static (magic number, version, previous hash...) and dynamic (timestamp, Merkle Root, transaction count and transactions) elements. What I don't understand is if we update active parts, wouldn't we start guessing nonce from the beginning every time and also calculating the new merkle root would be time-consuming for each transaction? I understand that since PoW is memoryless it doesn't effect much if it is updated every seconds or with every transaction but it may be slower to compute new hashes and root. I'm sorry if I'm wrong but, if miners freeze the block at certain time would they have an advantage. I searched a lot, but couldn't find an article or video of what really happens during mining in slo-mo.
-
It needn't be a fixed time interval. In principle, a miner could measure how much it costs them (in terms of lost mining time) to restart with a new block header, and then restart only if the new block's fees exceed the old block's by at least that amount. This amount could of course be different for different miners, depending on their hardware.– Nate EldredgeOct 20, 2019 at 20:06
2 Answers
Miners do optimize the block construction process internally.
Unfortunately they do not share this information with the community, so we don't know what methods they use, how they choose TX's and how they distribute work to pool participants.
Both mining machines and mining software the big miners use are secret. Modern ASIC machines' hardware are closed source and so is their firmware and operating system.
This is unfortunate considering that Satoshi gave us Bitcoin source code, which is absolutely revolutionary, for free.
The mining is done on ASICs that do nothing but mine. As each miner finishes a work unit, it is given another one that has already been computed and is ready to go. The computation of the work units and the selection of what to put in the block to be mined is done by a general purpose computer and does not compete for resources with mining.
So, in general, it makes no difference how much effort you go through to choose the block contents and work units assigned to miners so long as you can produce work units fast enough to keep all your miners busy all the time.
There is one exception -- when a new block is found. Here, you don't want to use any work units you've already computed because they will produce a later chain of equal length and so are unlikely to reward you. In this case, you do need to produce new work units for all your miners as quickly as you possibly can. Every second it takes you to do this reduce your mining revenue by about 0.8%.
This is, however, an unavoidable case. You must generate new work units and you can't blindly use the same transaction set because certainly at least some of those transactions are included in, or invalidated by, the new block. So you can't avoid doing the work here anyway.