Pages:
Author

Topic: When a block is solved, is everyone else's work wasted? (Read 996 times)

member
Activity: 61
Merit: 10
Excellent information, thank you.
legendary
Activity: 2324
Merit: 1125
Wow what a bunch of long answers.

TLDR; "Work is not incremental"
legendary
Activity: 3472
Merit: 4801
Does the order the transactions appear also affect the resulting hash? That would be another dimension in which blocks can differ.

Yes.
hero member
Activity: 756
Merit: 500
It's all fun and games until somebody loses an eye
Does the order the transactions appear also affect the resulting hash? That would be another dimension in which blocks can differ.
newbie
Activity: 19
Merit: 0
Everyone's working on a different block because everyone has a different coinbase (the first transaction that says where to send your 25 BTC reward + transaction fees).  Plus my understanding is every miner creates their own blocks anyway, meaning they choose however many (or however few) transactions they want to stick in there - as well as which ones to put in.
full member
Activity: 221
Merit: 100
Lastly you seem to think that all blocks must need a solution in order for the next valid (solved) block to be found.  That isn't true.  MOST blocks have no solution eventually miners will (collectively) by random chance find a block which does have a solution.

This clarifies things a great deal for me. I was operating under the assumption that all miners were attempting to solve the same block.
donator
Activity: 1218
Merit: 1079
Gerald Davis
I'm trying hard to follow you here. Your first statement insinuates that it is possible to build a block that has no solution whatsoever which I think is patently false. In the next statement you conflate a finite pool in which there is a correct answer with being so large as to be infinitely sized. If that is the case then it would possible and even likely that any given block could result in an infinite amount of time being required to solve it. Strangely enough, the network tends to solve blocks at roughly 10 minutes each with no happenstances where the network stalls out because it is going to take infinite years to solve this one. I will concede the point that hash collisions can be found in a sufficiently sized pool.

The solution isn't infinitely hard the set of possible blocks is so large as to be practically infinite.  When solving a block even if one only modifies nonce, merkleroot hash, and timestamp the set of potential blocks is 2^320 this is even larger than the number of potential hashes (2^256) and is a number so large that for all practical purposes (related to mining) can be considered infinite).

I think you might be confused in thinking there is only one possible solution.  There is a LOT (once again pretty much infinite) possible solutions which could be the next valid block. 

Lastly you seem to think that all blocks must need a solution in order for the next valid (solved) block to be found.  That isn't true.  MOST blocks have no solution eventually miners will (collectively) by random chance find a block which does have a solution.   A particular block is created and then an incrementing nonce is added to the rest of the blockheader.  All nonce values are tried and if none of them produce a solution (hash below target based on difficulty) then that block will never have a solution.  Miners simply discard that block and attempt a new block (either by changing the coinbase tx or the timestamp).

Every 4 billion attempted hashes you have to change "something" all solutions for the current block (call it block candidate if you like) have been tried.  You can't attempt more solutions without changing the block in some manner.  Changing the timestamp or merklehash is not materially different than changing the prior block hash (because someone else found a block).  There is no progress.  You either solve a block or you don't.  Each attempt is a random chance like a lottery ticket. 


When difficulty is X that means on average miners (globally and collectively) attempted to find solutions for X blocks and failed before finding one which meets the difficulty target.

legendary
Activity: 3472
Merit: 4801
The set of possible solutions 2^256 and globally in the time period of a block being solved a negligible percentage have been completed.  However there is no 1:1 mapping between inputs and hashes in a hashing function.  An infinite number of inputs can produce the same hash. 

Routinely within one block "window" the two elements of the blockheader that are changed are the timestamp, the merkleroot hash, and the nonce.  That provides 2^320 potential solutions.   Any potential progress is so negligible that for all practical purposes it can be considered zero and thus each attempt is independent. 

https://en.bitcoin.it/wiki/Block_hashing_algorithm

Each hash has a 1 in (difficulty)*(2^32) chance of solving a block.   At current difficulty that means each hash has an independent chance of 1 in  52,198,505,828,311,400 chance of winning the block jackpot.   Each hash/ticket is checked and discarded. If it doesn't solve the block much like a losing lottery ticket there is no progress (in any usable sense).  You are just as far from wining the jackpot on the next ticket.

Thanks!  You just saved me a bunch of typing.

 Grin
donator
Activity: 1218
Merit: 1079
Gerald Davis
I don't entirely agree with this. In the dice analogy it would be more accurate to say that once a "1" is rolled the person who rolled the "1" will no longer roll another "1" because "1" has been proven to not be the solution to the problem at hand. That is, he would reduce the number of faces on the dice before rolling again. I agree that each attempt has equal chance of being the right solution in that the chance of rolling a "1" was just as good as rolling a "6" and that on the successive roll the chance of rolling a "5" will be just as good as rolling a "6" but chance of rolling another "1" has now been made zero and the available pool of possible answers has been reduced. Since the pool of possible answers is finite and thus every attempt proven incorrect will not be reattemtped  the next attempt does run a statistically higher chance of being the correct answer than the previous attempt.

I think you are mistaken.  There is no guarantee that a any solution will work for any given block.  While the pool of possible answers is finite, it is so large that it can essentially be considered infinite for the purposes of considering an increase in statistical probability.  If we consider the pool of potential hashes to be "finite" then we also have to consider that a resulting hash is not removed from the pool, since that same hash could be calculated again with a different set of data.

The next hash you calculate after incrementing the nonce is no more or less likely to result in a solution than then previous or the next hash.

This.

The set of possible solutions 2^256 and globally in the time period of a block being solved a negligible percentage have been completed.  However there is no 1:1 mapping between inputs and hashes in a hashing function.  An infinite number of inputs can produce the same hash. 

Routinely within one block "window" the two elements of the blockheader that are changed are the timestamp, the merkleroot hash, and the nonce.  That provides 2^320 potential solutions.   Any potential progress is so negligible that for all practical purposes it can be considered zero and thus each attempt is independent. 

https://en.bitcoin.it/wiki/Block_hashing_algorithm

Each hash has a 1 in (difficulty)*(2^32) chance of solving a block.   At current difficulty that means each hash has an independent chance of 1 in  52,198,505,828,311,400 chance of winning the block jackpot.   Each hash/ticket is checked and discarded. If it doesn't solve the block much like a losing lottery ticket there is no progress (in any usable sense).  You are just as far from wining the jackpot on the next ticket.

legendary
Activity: 3472
Merit: 4801
Note that the nonce is a 32 bit integer.  This means there are only 4.2 billion possibilities to try for a given block.  A miner with 4.2 gigahash/second can try every possibility in 1 second. (or is it 2 seconds because of the double hash? I can't remember).  Regardless, in a given 10 minute timeframe on average, new blocks are frequently generated.  Any pool (or solo miner) with access to significant hash power would be wise to pre-generate multiple potential blocks while the current one is being hashed.  They'd keep a queue of these pre-generated potential blocks ready so there is no delay between the exhaustion of nonces on one block and the beginning of hashing the next.
full member
Activity: 221
Merit: 100
I think you are mistaken.  There is no guarantee that a any solution will work for any given block.  While the pool of possible answers is finite, it is so large that it can essentially be considered infinite for the purposes of considering an increase in statistical probability.  If we consider the pool of potential hashes to be "finite" then we also have to consider that a resulting hash is not removed from the pool, since that same hash could be calculated again with a different set of data.

The next hash you calculate after incrementing the nonce is no more or less likely to result in a solution than then previous or the next hash.

I'm trying hard to follow you here. Your first statement insinuates that it is possible to build a block that has no solution whatsoever which I think is patently false. In the next statement you conflate a finite pool in which there is a correct answer with being so large as to be infinitely sized. If that is the case then it would possible and even likely that any given block could result in an infinite amount of time being required to solve it. Strangely enough, the network tends to solve blocks at roughly 10 minutes each with no happenstances where the network stalls out because it is going to take infinite years to solve this one. I will concede the point that hash collisions can be found in a sufficiently sized pool.
newbie
Activity: 19
Merit: 0
Thanks Danny.  Cryptography is one of those topics that sometimes seems simple on the surface, but the further you dig, the more complicated it can get. Nice to get some answers.
legendary
Activity: 3472
Merit: 4801
I don't entirely agree with this. In the dice analogy it would be more accurate to say that once a "1" is rolled the person who rolled the "1" will no longer roll another "1" because "1" has been proven to not be the solution to the problem at hand. That is, he would reduce the number of faces on the dice before rolling again. I agree that each attempt has equal chance of being the right solution in that the chance of rolling a "1" was just as good as rolling a "6" and that on the successive roll the chance of rolling a "5" will be just as good as rolling a "6" but chance of rolling another "1" has now been made zero and the available pool of possible answers has been reduced. Since the pool of possible answers is finite and thus every attempt proven incorrect will not be reattemtped  the next attempt does run a statistically higher chance of being the correct answer than the previous attempt.

This is exactly what I mean by wasted work when a block solution is found by someone else. This analogy seems better to me.  Anytime you have to chance something besides the nonce in your block, you're starting over.

Sure, but that has as good of a chance of helping you (by preventing you from wasting time on a block that wasn't solvable) as it does of hurting you (by keeping you from getting to the later solution that might have been in that block).  In the end it's a wash.
legendary
Activity: 3472
Merit: 4801
I don't entirely agree with this. In the dice analogy it would be more accurate to say that once a "1" is rolled the person who rolled the "1" will no longer roll another "1" because "1" has been proven to not be the solution to the problem at hand. That is, he would reduce the number of faces on the dice before rolling again. I agree that each attempt has equal chance of being the right solution in that the chance of rolling a "1" was just as good as rolling a "6" and that on the successive roll the chance of rolling a "5" will be just as good as rolling a "6" but chance of rolling another "1" has now been made zero and the available pool of possible answers has been reduced. Since the pool of possible answers is finite and thus every attempt proven incorrect will not be reattemtped  the next attempt does run a statistically higher chance of being the correct answer than the previous attempt.

I think you are mistaken.  There is no guarantee that a any solution will work for any given block.  While the pool of possible answers is finite, it is so large that it can essentially be considered infinite for the purposes of considering an increase in statistical probability.  If we consider the pool of potential hashes to be "finite" then we also have to consider that a resulting hash is not removed from the pool, since that same hash could be calculated again with a different set of data.

The next hash you calculate after incrementing the nonce is no more or less likely to result in a solution than then previous or the next hash.
newbie
Activity: 19
Merit: 0
I don't entirely agree with this. In the dice analogy it would be more accurate to say that once a "1" is rolled the person who rolled the "1" will no longer roll another "1" because "1" has been proven to not be the solution to the problem at hand. That is, he would reduce the number of faces on the dice before rolling again. I agree that each attempt has equal chance of being the right solution in that the chance of rolling a "1" was just as good as rolling a "6" and that on the successive roll the chance of rolling a "5" will be just as good as rolling a "6" but chance of rolling another "1" has now been made zero and the available pool of possible answers has been reduced. Since the pool of possible answers is finite and thus every attempt proven incorrect will not be reattemtped  the next attempt does run a statistically higher chance of being the correct answer than the previous attempt.

This is exactly what I mean by wasted work when a block solution is found by someone else. This analogy seems better to me.  Anytime you have to change something besides the nonce in your block, you're starting over.
legendary
Activity: 3472
Merit: 4801
How does the change of nonce work? does it do in order, or completely random?

While in theory the order shouldn't matter, for simplicity sake I believe miners all do it in order.  It makes it much easier for the program to keep track of which nonces it has already tried.
full member
Activity: 221
Merit: 100
There is no "making progress" towards a solution.  Every attempt has as good of a chance of being the right solution as every other attempt.  Think of it like rolling dice.  If 2 people each roll a die until one of them rolls a 1, are all the previous rolls "wasted"?  Has anyone's chances of rolling a 1 gotten better (or worse) just because a 1 has (or hasn't) been rolled yet?

I don't entirely agree with this. In the dice analogy it would be more accurate to say that once a "1" is rolled the person who rolled the "1" will no longer roll another "1" because "1" has been proven to not be the solution to the problem at hand. That is, he would reduce the number of faces on the dice before rolling again. I agree that each attempt has equal chance of being the right solution in that the chance of rolling a "1" was just as good as rolling a "6" and that on the successive roll the chance of rolling a "5" will be just as good as rolling a "6" but chance of rolling another "1" has now been made zero and the available pool of possible answers has been reduced. Since the pool of possible answers is finite and thus every attempt proven incorrect will not be reattemtped  the next attempt does run a statistically higher chance of being the correct answer than the previous attempt.
legendary
Activity: 3472
Merit: 4801
Anybody have an answer to my last question on double hashing?

Hello
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 (first round on sha-256)
d7914fe546b684688bb95f4f888a92dfc680603a75f23eb823658031fff766d9 (2nd round of sha-256, from hashing the above value)

However the wiki page above says the 2nd round should yield this value:
9595c9df90075148eb06860365df33584b75bff782a510c6cd4883a419833d50

What am I doing wrong?

Usually when someone asks this question it is because they are hashing the result of the first hash as a string of characters rather than as a block of binary data.

(ex. 0A would be a hex representation of  00001010, but as a string it would be represented as 00110000 01000001)
member
Activity: 98
Merit: 10
Official Troll of bitcointalk,Certified by John K.
thanks rme Smiley
newbie
Activity: 5
Merit: 0
How does the change of nonce work? does it do in order, or completely random?
Pages:
Jump to: