Bitcoin Forum
May 01, 2024, 10:51:09 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Where does it start?  (Read 746 times)
pacojones (OP)
Full Member
***
Offline Offline

Activity: 126
Merit: 100



View Profile
November 11, 2013, 06:38:16 PM
 #1

I'm not even sure how to ask this question so here goes:

The bitcoin mining network is hashing away and pool X finds a block - question:  once a miner sees that a block is solved, how does it know where to start mining the next block?

Example:
- block found
- network notified
- Miner 1 > starts to brute force the next block by trying 1111, 1112, 1113, 1114
- Miner 2 > starts to brute force the new block by trying HuhHuh
- Miner 3 > starts to brute force the new block by trying HuhHuh
- Miner 4 > starts to brute force the new block by trying HuhHuh
- Miner 5 > starts to brute force the new block by trying HuhHuh

What's to keep all 5 miners from starting at the same starting position and therefore (basically) finding the 'solution' at the same time?  Is there some sort of randomization calculator built into the software so the miners all start at a different point??  I mean if I have 5 miners going myself and they are all trying to solve the same problem and they are all starting at the same start position they would all be doing the same work!

I hope this makes sense - sorry for the crude example!

1714603869
Hero Member
*
Offline Offline

Posts: 1714603869

View Profile Personal Message (Offline)

Ignore
1714603869
Reply with quote  #2

1714603869
Report to moderator
1714603869
Hero Member
*
Offline Offline

Posts: 1714603869

View Profile Personal Message (Offline)

Ignore
1714603869
Reply with quote  #2

1714603869
Report to moderator
"There should not be any signed int. If you've found a signed int somewhere, please tell me (within the next 25 years please) and I'll change it to unsigned int." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714603869
Hero Member
*
Offline Offline

Posts: 1714603869

View Profile Personal Message (Offline)

Ignore
1714603869
Reply with quote  #2

1714603869
Report to moderator
ineedit
Sr. Member
****
Offline Offline

Activity: 252
Merit: 250


View Profile
November 11, 2013, 06:45:14 PM
 #2

I'm not even sure how to ask this question so here goes:

The bitcoin mining network is hashing away and pool X finds a block - question:  once a miner sees that a block is solved, how does it know where to start mining the next block?

Example:
- block found
- network notified
- Miner 1 > starts to brute force the next block by trying 1111, 1112, 1113, 1114
- Miner 2 > starts to brute force the new block by trying HuhHuh
- Miner 3 > starts to brute force the new block by trying HuhHuh
- Miner 4 > starts to brute force the new block by trying HuhHuh
- Miner 5 > starts to brute force the new block by trying HuhHuh

What's to keep all 5 miners from starting at the same starting position and therefore (basically) finding the 'solution' at the same time?  Is there some sort of randomization calculator built into the software so the miners all start at a different point??  I mean if I have 5 miners going myself and they are all trying to solve the same problem and they are all starting at the same start position they would all be doing the same work!

I hope this makes sense - sorry for the crude example!


You might want to start here http://codinginmysleep.com/bitcoin-mining-in-plain-english/

If I have been help then please show your thanks         BTC: 127PRogAVZiV3fEmpJERh9KemK3a3Ffh6G         LTC: LXghFL8mZffpTFkm2nRTesuDrV5DJQP3Js
os2sam
Legendary
*
Offline Offline

Activity: 3578
Merit: 1090


Think for yourself


View Profile
November 11, 2013, 07:16:26 PM
 #3

And here, or hear Smiley

https://media.grc.com/sn/sn-287-lq.mp3

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
November 11, 2013, 07:34:39 PM
 #4

Your example is too crude to provide anything to correct.

First of all if you are mining for a pool you really aren't a "miner" you are a SHA-2 hashpower provider (independent contractor), your pool makes sure there is no duplicate work.  For the purpose of this explanation, only entities which construct the block headers are "miners" (pool operators, solo miners, and some unique situations like p2pool).

No miner is working on the same "work".  You aren't just hashing a single number.  That would be beyond pointless it wouldn't provide any security.  What does the number 123456 hashed mean?  Absolutely nothing.  How would it prevent modifying the blockchain?  It wouldn't.  

You are hashing a blockheader which consists of 6 values only one of which is "the number" which is called a nonce.  The nonce is simply a way to add entropy so you can make multiple tries without changing anything else in the blockheader.

So what is in the blockheader?

Code:
Field	        Purpose	                                                    Updated when
Version        Block version number                                    You upgrade the software and it specifies a new version
hashPrevBlock 256-bit hash of the previous block header            A new block comes in
hashMerkleRoot 256-bit hash based on all of the transactions in the block  A transaction is accepted
Time        Current timestamp as seconds since 1970-01-01T00:00 UTC    Every few seconds
Bits        Current target in compact format                    The difficulty is adjusted
Nonce        32-bit number (starts at 0)                            A hash is tried (increments)
https://en.bitcoin.it/wiki/Block_hashing_algorithm

If ANY of these values are different the hash will be different.  Miners routinely attempt the same nonce.  Your own individual miners will attempt the same nonce millions of times.  The nonce is only 32 bit, there are only 4 billion possibilities.  A KNC Jupiter for example will exhaust the nonce range in less than 1/100th of a second.  Even a low end GPU will try all possible nonces (for a given blockheader) in a few seconds.

The "hashMerkleRoot" is a unique hash which represents all the transactions in the block.   If you add, remove, or change ONE transaction in the block you will end up with a different Merkle Root hash.  One of those transactions is the "coinbase" where miners receive their reward.  Even two miners (solo miners, pools, p2pool users) which have the exact same set of other transactions will still have a unique coinbase txs and thus have different Merkle Root hashes.

Different Merkle Root Hash = Different Block Header = Different Hash.

No two miners on the planet are ever working on the same work (with the exception of a bug in a pool server issuing duplicate work to its workers).
pacojones (OP)
Full Member
***
Offline Offline

Activity: 126
Merit: 100



View Profile
November 12, 2013, 12:18:47 AM
 #5

If ANY of these values are different the hash will be different.  Miners routinely attempt the same nonce.  Your own individual miners will attempt the same nonce millions of times.  The nonce is only 32 bit, there are only 4 billion possibilities.  A KNC Jupiter for example will exhaust the nonce range in less than 1/100th of a second.  Even a low end GPU will try all possible nonces (for a given blockheader) in a few seconds.

The "hashMerkleRoot" is a unique hash which represents all the transactions in the block.   If you add, remove, or change ONE transaction in the block you will end up with a different Merkle Root hash.  One of those transactions is the "coinbase" where miners receive their reward.  Even two miners (solo miners, pools, p2pool users) which have the exact same set of other transactions will still have a unique coinbase txs and thus have different Merkle Root hashes.

Different Merkle Root Hash = Different Block Header = Different Hash.


https://en.bitcoin.it/wiki/Block_hashing_algorithm
Given just those fields, people would frequently generate the exact same sequence of hashes as each other and the fastest CPU would almost always win. However, it is (nearly) impossible for two people to have the same Merkle root because the first transaction in your block is a generation "sent" to one of your unique Bitcoin addresses. Since your block is different from everyone else's blocks, you are (nearly) guaranteed to produce different hashes. Every hash you calculate has the same chance of winning as every other hash calculated by the network.

This is starting to make sense - thank you

DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
November 12, 2013, 12:53:37 AM
 #6

Yes.  Given the size of the hash space (2^256) we can drop the "nearly" from the impossible & guaranteed.  The block headers will be unique.  The probability of two unique block headers producing the same has are 1 in 2^256 which for all practical intents in purposes is 0.

There is one additional "field" which is more useful to pools.  The coinbase input field has no use in Bitcoin so it can hold any arbitrary psuedo random value.  This is used by pools as an "extra nonce" field so they can give two wokers different blockheaders despite having the same tx set.  Changing the extra nonce in the coinbase tx will change the tx hash which will change the merkle tree root hash.  This way by incrementing the extra-nonce field a pool can quickly assign unique (but very similar) work to thousands of workers if necessary.
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!