Bitcoin Forum
December 04, 2016, 06:36:33 PM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Stupid newbie question about the nonce  (Read 7304 times)
anewbie
Jr. Member
*
Offline Offline

Activity: 31


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?




1480876593
Hero Member
*
Offline Offline

Posts: 1480876593

View Profile Personal Message (Offline)

Ignore
1480876593
Reply with quote  #2

1480876593
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480876593
Hero Member
*
Offline Offline

Posts: 1480876593

View Profile Personal Message (Offline)

Ignore
1480876593
Reply with quote  #2

1480876593
Report to moderator
1480876593
Hero Member
*
Offline Offline

Posts: 1480876593

View Profile Personal Message (Offline)

Ignore
1480876593
Reply with quote  #2

1480876593
Report to moderator
theymos
Administrator
Legendary
*
Offline Offline

Activity: 2492


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



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.

p2pcoin: a USB/CD/PXE p2pool miner - 1N8ZXx2cuMzqBYSK72X4DAy1UdDbZQNPLf - todo
I routinely ignore posters with paid advertising in their sigs.  You should too.
anewbie
Jr. Member
*
Offline Offline

Activity: 31


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: 2492


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
Jr. Member
*
Offline Offline

Activity: 31


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: 1890



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: 2492


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



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.

p2pcoin: a USB/CD/PXE p2pool miner - 1N8ZXx2cuMzqBYSK72X4DAy1UdDbZQNPLf - todo
I routinely ignore posters with paid advertising in their sigs.  You should too.
thedrs
Jr. Member
*
Offline Offline

Activity: 33



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: 445


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, Twister posts, & Keybase pages | Tox ID: 65C3E8810738AD9D175234808FCB317A1103632903436203D45411AE97C03F547D390A76B3CF
Join Coinbase. | The best, free book on Bitcoin: Mastering Bitcoin
Nos cum prole pia benedicat Virgo Maria.
MineForeman.com
Legendary
*
Offline Offline

Activity: 896



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

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: 1890



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


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: 445


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, Twister posts, & Keybase pages | Tox ID: 65C3E8810738AD9D175234808FCB317A1103632903436203D45411AE97C03F547D390A76B3CF
Join Coinbase. | The best, free book on Bitcoin: Mastering Bitcoin
Nos cum prole pia benedicat Virgo Maria.
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!