Bitcoin Forum
April 28, 2024, 02:36:09 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Stupid newbie question about the nonce  (Read 13459 times)
anewbie (OP)
Newbie
*
Offline Offline

Activity: 52
Merit: 0


View Profile
May 23, 2011, 03:24:05 AM
 #1

This is definitely a newbie question.  It has probably been answered before, but I can't find it with the searches I've done.

I have come to bitcoin with the slashdot post last week and have tried to educate myself before asking stupid questions.  I started bitcoin mining solo and after about a day and a half realized I should join a pool.

I'm using the poclbm client.

As I understand bitcoin mining (in a pool or solo), I am grabbing the hash of the previous block, possibly some transactions, my (or the pool's) address and randomly trying different nonce's to get a hash of all of that smaller than a specified value based on the current difficulty.

But here's where I am confused.  My miner (solo or pooled) using my Radeon 5770 card reports around 170 - 175 Mhashes/sec.

The nonce on block 125907 found as I began writing this was 150,035,635 (comma's added for readabilty).  If the Mhashes reported by my miner are checking blocks by playing with the nonce, that should have been found in a second.

As I've written this, block 125908 has been found with a nonce of 3,787,138,861.  At 170M/s that would have taken just under 22 seconds.

Obviously, I'm missing something.  Technically, I do realize that a block hash is the hash of a hash, but still, I do not understand what is being reported as hashes/second when trying to find a block.

Technical discussions over my head are welcome as are pointers to threads where this has already been asked.  But, in a nutshell, if the only thing that a miner program is playing with is the nonce, why is the nonce so small compared to the hashes/sec or the time to find a block?



1714314969
Hero Member
*
Offline Offline

Posts: 1714314969

View Profile Personal Message (Offline)

Ignore
1714314969
Reply with quote  #2

1714314969
Report to moderator
1714314969
Hero Member
*
Offline Offline

Posts: 1714314969

View Profile Personal Message (Offline)

Ignore
1714314969
Reply with quote  #2

1714314969
Report to moderator
The grue lurks in the darkest places of the earth. Its favorite diet is adventurers, but its insatiable appetite is tempered by its fear of light. No grue has ever been seen by the light of day, and few have survived its fearsome jaws to tell the tale.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714314969
Hero Member
*
Offline Offline

Posts: 1714314969

View Profile Personal Message (Offline)

Ignore
1714314969
Reply with quote  #2

1714314969
Report to moderator
1714314969
Hero Member
*
Offline Offline

Posts: 1714314969

View Profile Personal Message (Offline)

Ignore
1714314969
Reply with quote  #2

1714314969
Report to moderator
theymos
Administrator
Legendary
*
Offline Offline

Activity: 5180
Merit: 12900


View Profile
May 23, 2011, 03:33:53 AM
 #2

The nonce is reset from time to time. With pooled mining, you ask the pool for new work when this happens. With solo mining, you modify the coinbase transaction to get a new set of hashes to try.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1024



View Profile
May 23, 2011, 03:34:50 AM
 #3

There is another one in the Merkle root.

If a miner burns through every possible nonce in the block header without success (which is most of the time), it reports that to the node, which updates the Merkle nonce and hash (it might also reconsider which transactions to include and possibly a new timestamp), and starts over.

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
anewbie (OP)
Newbie
*
Offline Offline

Activity: 52
Merit: 0


View Profile
May 23, 2011, 03:43:55 AM
 #4

Then what is the upper limit on the nonce?  Is there one in the protocol?

On transactions, if I'm solo mining, are those being assigned to my miner, or is it picking them out of the pool of transactions on its own? 

theymos
Administrator
Legendary
*
Offline Offline

Activity: 5180
Merit: 12900


View Profile
May 23, 2011, 03:47:50 AM
 #5

The upper limit is 4294967295, but Bitcoin resets the nonce long before you reach that. The reset is based on time, I believe. Edit: Actually, it looks like the nonce does go right up to the limit before being reset. ExtraNonce is the one that is reset based on time.

On transactions, if I'm solo mining, are those being assigned to my miner, or is it picking them out of the pool of transactions on its own? 

Are you talking about transactions in blocks? Solo miners pick them according to their own rules.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
anewbie (OP)
Newbie
*
Offline Offline

Activity: 52
Merit: 0


View Profile
May 23, 2011, 03:52:30 AM
 #6

Thanks to both of you for the quick answers.  One final question and I'm done for the night.

Theymos talks about the node resetting the nonce. kjj talks about the node making changes in the merkle root and possibly the timestamp.  Are you both talking about the same thing?  Merkle root nonces?  I thought that a miner was playing with the nonce itself to get a block.  Is my inderstanding incorrect.

Thanks again, and I promise I'm done for the night.

I may come back with more newbie questions tomorrow, though.
Meni Rosenfeld
Donator
Legendary
*
Offline Offline

Activity: 2058
Merit: 1054



View Profile WWW
May 23, 2011, 04:26:32 AM
 #7

Thanks to both of you for the quick answers.  One final question and I'm done for the night.

Theymos talks about the node resetting the nonce. kjj talks about the node making changes in the merkle root and possibly the timestamp.  Are you both talking about the same thing?  Merkle root nonces?  I thought that a miner was playing with the nonce itself to get a block.  Is my inderstanding incorrect.

Thanks again, and I promise I'm done for the night.

I may come back with more newbie questions tomorrow, though.
The miner plays with the nonce to get a block, up to a point. Since nonce is a 32-bit integer which only allows for 4B values, eventually it will need to ask the server (whether locally or on a pool) for a new merkle root to work on (where things like the extra nonce have been changed).

1EofoZNBhWQ3kxfKnvWkhtMns4AivZArhr   |   Who am I?   |   bitcoin-otc WoT
Bitcoil - Exchange bitcoins for ILS (thread)   |   Israel Bitcoin community homepage (thread)
Analysis of Bitcoin Pooled Mining Reward Systems (thread, summary)  |   PureMining - Infinite-term, deterministic mining bond
theymos
Administrator
Legendary
*
Offline Offline

Activity: 5180
Merit: 12900


View Profile
May 23, 2011, 04:33:41 AM
 #8

A solo miner increments Nonce until it overflows. Then it increments extraNonce and resets Nonce. extraNonce is located in the coinbase transaction, so changing it alters the Merkle root. extraNonce is reset based on the time.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1024



View Profile
May 23, 2011, 04:51:56 AM
 #9

I think that a lot of the confusion comes from thinking that there is just the one true next block and everyone is trying to find the one.

That isn't how it works.  There are many blocks that could be the next one.  The difficult part is finding one out of the much huger number of blocks that aren't difficult enough.

Each node builds up a list of pending transactions, and they pick some or all of them to go into the new block.  Once they have their list of accepted transaction, they calculate the hash of a Merkle tree for that list.  One of these transactions is unique to that node too, because it is the generation transaction, and everyone gets to pick their own account for the reward.  So, even if everyone had the same rules for picking and ordering transactions, they would all be starting from different places anyway.

For many potential blocks, there is no value of the nonce that will give a hash less than the target.  When that happens, the node must alter something in the block header and try again.  The timestamp is a good candidate, since it usually takes some time to try all 2^32 nonces.  New transactions may have come in across the network that can be added to the tree too.

I could have sworn there was also a nonce in the Merkle tree calculations, but I can't find any references to it now.  Ahh, theymos found it while I was typing.  It is in the generation transaction, which changes the Merkle hash.

In a pool, the pool server will hand out unique headers to each worker/request, by using the extraNonce and rehashing the tree, to prevent duplication of work and get better odds of finding a valid block.

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
thedrs
Newbie
*
Offline Offline

Activity: 40
Merit: 0



View Profile
May 23, 2011, 09:26:38 PM
 #10

Thanks KJJ that was very helpful for understanding how it works.
Many of the newbie tutorials explain the system in a more simple manner which makes you assume there is 1 true next block that everyone is working on.

Now, after reading you post it is clear why everyone is actually working on a different one.

Now I have to go find some info on what a Merkle tree is .... Tongue

Geremia
Sr. Member
****
Offline Offline

Activity: 502
Merit: 251


View Profile WWW
March 10, 2015, 11:49:11 PM
 #11

Now I have to go find some info on what a Merkle tree is .... Tongue
https://en.bitcoin.it/wiki/Protocol_documentation#Merkle_Trees

BTC tip jar | my BTC wiki, BTC StackExchange | Tox ID: 65C3E8810738AD9D175234808FCB317A1103632903436203D45411AE97C03F54C34861AB6663
Join Kraken. | The best, free book on Bitcoin: Mastering Bitcoin
Nos cum prole pia benedicat Virgo Maria.
MineForeman.com
Legendary
*
Offline Offline

Activity: 896
Merit: 1000



View Profile WWW
March 11, 2015, 12:02:13 AM
 #12


That page did not exist in 2011 when the question was asked.

Bitcoin News http://mineforeman.com/ || MinePeon - Bitcoin mining on the Raspberry PI http://mineforeman.com/minepeon/ || MinePeon Wiki http://minepeon.com/ || MinePeon Forums http://minepeon.com/forums/
Possum577
Sr. Member
****
Offline Offline

Activity: 434
Merit: 250

Loose lips sink sigs!


View Profile WWW
March 11, 2015, 04:56:29 AM
 #13

Dude, if you can't find it in the searches it's NOT a newbie question.

Good luck to you, hope you find your answers.

Meni Rosenfeld
Donator
Legendary
*
Offline Offline

Activity: 2058
Merit: 1054



View Profile WWW
March 11, 2015, 09:56:11 AM
 #14

That page did not exist in 2011 when the question was asked.
Not only did the page exist since 2010, the Merkle tree section was added before the question was asked.

Anyway, looks like Geremia is trying to set some sort of record on gratuitous necrobumps...

1EofoZNBhWQ3kxfKnvWkhtMns4AivZArhr   |   Who am I?   |   bitcoin-otc WoT
Bitcoil - Exchange bitcoins for ILS (thread)   |   Israel Bitcoin community homepage (thread)
Analysis of Bitcoin Pooled Mining Reward Systems (thread, summary)  |   PureMining - Infinite-term, deterministic mining bond
Kipsy89
Sr. Member
****
Offline Offline

Activity: 280
Merit: 250


Relax!


View Profile
March 11, 2015, 10:22:54 AM
 #15

Dude, if you can't find it in the searches it's NOT a newbie question.

Good luck to you, hope you find your answers.

Well apart from the fact that this thread is almost 4 years old, the question isn't exactly stupid. He actually thought about how blocks are being found and what the nonce's role is and deducted correctly how many nonces a miner has to go through, or should be capable to go through per second.

Geremia
Sr. Member
****
Offline Offline

Activity: 502
Merit: 251


View Profile WWW
March 12, 2015, 08:35:39 AM
 #16

Actually, Andreas M. Antonopoulos's Mastering Bitcoin's section on the Merkle trees is a very good description.

BTC tip jar | my BTC wiki, BTC StackExchange | Tox ID: 65C3E8810738AD9D175234808FCB317A1103632903436203D45411AE97C03F54C34861AB6663
Join Kraken. | The best, free book on Bitcoin: Mastering Bitcoin
Nos cum prole pia benedicat Virgo Maria.
deekor
Newbie
*
Offline Offline

Activity: 21
Merit: 0


View Profile WWW
April 04, 2017, 08:48:14 PM
 #17

In a pool, the pool server will hand out unique headers to each worker/request, by using the extraNonce and rehashing the tree, to prevent duplication of work and get better odds of finding a valid block.

So is this what a `share` is? An attempt to solve a block with a unique header?
timisis
Member
**
Offline Offline

Activity: 178
Merit: 10


View Profile
June 30, 2017, 09:23:09 AM
 #18

To prove that there are very few limits to human stupidity, or necrophilia, I need to ask: what does "Found nonce" actually mean? How close am I to finding a block with such a message? And does it have anything to do with verifying "other" blocks?
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!