How does mining work on the moving target (variables change every second)?

0

In bitcoin, miners hash the header twice with the SHA256 function. This header consists of the fields listed below:

  • version (v)
  • previousHashBlock (p)
  • merkleRoot (m)
  • time (t)
  • difficulty (d)
  • nonce (n)

Let's simplify and say that I am a pool miner with nonce range from 1-100. So if I do my share and find that on 9th minute the Nonce value of 91, solves the puzzle (proof of work). But by the time I send to network, merkleRoot and time has changed, so the nonce that I've found is not true anymore. We know that hash changes dramatically with slightest change of input, but in this formula, not one but TWO variable change constantly throughout my mining period (in this case 9 minute). Transaction occured and time changed. So how does this formula hold true thoughout the mining time?

SHA256(v + p + m + t + d + n(91)) => 0000000asd8f686asd6das

Where m and t changes constantly? Wouldn't 91 be irrelevant at the time of finding?

Prostak

Posted 2018-01-22T23:02:32.957

Reputation: 103

Answers

1

Realistic miners run through all 2^32 possible nonces in much less than a second.

If a transaction occurred after you started your nonce search, then your block won't include that transaction. There's no problem with that.

If the time changed after you mined your block, then your block won't have the exact right time. Again, no problem with that.

And if you think about it, there can't be any problem with that. How would anyone know when you mined the block or whether the transaction occurred before or after you mined the block? It's mining that allows bitcoin to agree on these things, so if you mined the block, you're the one who gets to choose.

David Schwartz

Posted 2018-01-22T23:02:32.957

Reputation: 46 931

where does 2^32 comes from? is it the max possible nonce? or is it agreed share of the pool mining? if it take only a second, what do I do the rest of 10 minutes?Prostak 2018-01-22T23:52:10.367

There are 2^32 possible nonces since the nonce is 32-bits. Perhaps you have the misconception that there's one magic block that every miner is trying to mine. A miner is trying to mine any valid block that pays him the reward. If he can't mine a particular block, he'll just trying again with a slightly different block. If he has lots of fast hardware, he may be trying to mine 100's of possible different blocks at once. On average, someone somewhere succeeds once every 10 minutes. That's how hard mining is.David Schwartz 2018-01-22T23:53:52.360

thanks for responding btw! you are right, I did have this misconception... but does it mean, that it might be impossible to find jackpot with certain criterias.... i mean, it just does not exist... so let's say i have m and t, and no matter of nonce i use, it is impossible to get a hash with certain 0? so that means, that you have to modify time or merkleRoot ?Prostak 2018-01-22T23:59:46.100

@Prostak Right. It's trivial to get a new merkleRoot by just slightly changing the transaction that pays you the mining reward. So that gets you a whole new block to try all 2^32 nonces on.David Schwartz 2018-01-23T00:09:55.030

When you say "100's of possible different blocks at once", what do you mean? what variants do they introduce to block? time? and change transaction list? or is there a way to modify smth else?Prostak 2018-01-23T00:23:40.937

Typically they change the transaction that pays them the block reward and transaction fees. Changing one byte in the transaction is sufficient to give them an entirely new block to try all 2^32 nonces on.David Schwartz 2018-01-23T00:33:57.790

0

As a miner, you choose your own merkleRoot and time.

This is the same reason why different miners are looking for different nonces - your merkleRoot contains your reward transaction, while the merkleRoot for a different miner contains their reward transaction.

Greg Hewgill

Posted 2018-01-22T23:02:32.957

Reputation: 3 321

what do you mean "you choose"? do you mean that you choose transactions to pick to the block? but in that case, you also don't choose, because you have to take transactions that occurred before... as I understand, the max transactions are 2400, so you have to take at least this maxProstak 2018-01-22T23:55:35.340

You don't have to take transactions that occurred before. You have your choice of valid transactions. And you can introduce your own transactions if you want. Mining is how we agree on which transactions occurred so if you mine a block, you get to choose for that block. So long as they're valid, of course.David Schwartz 2018-01-22T23:56:51.470

Yes, I mean that miners choose the transactions that they would like to include in a block. This how miners can drive transaction costs up, by choosing to only include transactions with high included transaction fees. If miners were somehow required to include the oldest transactions, then nobody would bother including any transaction fees.Greg Hewgill 2018-01-22T23:56:59.947

@DavidSchwartz correct me if I am wrong, but you have to pick transactions BEFORE you start picking the nonce? because merkleRoot changes the result? in other words, if you mined the successful nonce, you can't change transactions list after? so you have to pick the exact transactions before starting to mine?Prostak 2018-01-23T00:06:55.840

@GregHewgill same question pls ^^Prostak 2018-01-23T00:07:14.500

@Prostak You have to decide what block you want to mine before you try to mine it. Then you try to mine it by trying all 2^32 nonces. You almost always fail, so you just start the process over again with a different block. And any realistic mining operation is trying to mine hundreds of possible blocks at once. Once you find a nonce, you have mined that exact block. Changing it in any way breaks the hash and so makes it invalid.David Schwartz 2018-01-23T00:09:07.883

Yes, you choose the transactions you would like to include before you start mining. When you find a successful nonce, it is in your best interest to broadcast that immediately, because you want your block reward.Greg Hewgill 2018-01-23T00:09:23.640

thanks guys, i've learnt from you that nonce is relatively small number... i thought that all 10 minutes, all miners around the world trying iterating via hash possibilities.... i mean that nonce itself was a hash with 2^160 possibilites... so all 10 minutes, miners iterating their own way these 2^160 ... but it seams that miner iterating playing the guessing game with variables themselfs, not with just nonce... @GregHewgillProstak 2018-01-23T00:28:49.760