Bitcoin Forum
May 11, 2024, 03:28:14 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: what does a miner do?  (Read 3330 times)
bitless (OP)
Newbie
*
Offline Offline

Activity: 28
Merit: 0


View Profile
July 10, 2011, 04:56:57 PM
 #1

Hi,

as I understand it, the miner goes through up to 2^32 values of the nonce field (which the fourth word in the message), calculates sha(sha(message)), and submits the proof-of-work to the pool if the last word in the hashing result equals to 0. Good.

Now the questions.
1 What other fields can we change in the message when mining, other than the nonce?
2 Where is the extraNonce located?
3 Where is the time (and can we change it as we see fit while mining, or are we required to keep it in a certain range)?

I've been reading through the protocol specs on wiki, but couldn't really figure it out.... Thanks!

-B


1715441294
Hero Member
*
Offline Offline

Posts: 1715441294

View Profile Personal Message (Offline)

Ignore
1715441294
Reply with quote  #2

1715441294
Report to moderator
No Gods or Kings. Only Bitcoin
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715441294
Hero Member
*
Offline Offline

Posts: 1715441294

View Profile Personal Message (Offline)

Ignore
1715441294
Reply with quote  #2

1715441294
Report to moderator
1715441294
Hero Member
*
Offline Offline

Posts: 1715441294

View Profile Personal Message (Offline)

Ignore
1715441294
Reply with quote  #2

1715441294
Report to moderator
JoelKatz
Legendary
*
Offline Offline

Activity: 1596
Merit: 1012


Democracy is vulnerable to a 51% attack.


View Profile WWW
July 10, 2011, 05:06:15 PM
 #2

1 What other fields can we change in the message when mining, other than the nonce?
The timestamp, the coinbase transaction, the list of transacations included in the block.
Quote
2 Where is the extraNonce located?
My recollection is that the 'extraNonce' is the coinbase. See here where its put into the input of the coinbase transaction:

    pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nBits << CBigNum(nExtraNonce);
    pblock->hashMerkleRoot = pblock->BuildMerkleTree();

Quote
3 Where is the time (and can we change it as we see fit while mining, or are we required to keep it in a certain range)?
The time is in the header, but it must be kept in a sensible range.

I am an employee of Ripple. Follow me on Twitter @JoelKatz
1Joe1Katzci1rFcsr9HH7SLuHVnDy2aihZ BM-NBM3FRExVJSJJamV9ccgyWvQfratUHgN
hashmaker
Newbie
*
Offline Offline

Activity: 52
Merit: 0



View Profile
July 10, 2011, 05:14:45 PM
 #3

1 What other fields can we change in the message when mining, other than the nonce?
The timestamp, the coinbase transaction, the list of transacations included in the block.
Quote
2 Where is the extraNonce located?
My recollection is that the 'extraNonce' is the coinbase. See here where its put into the input of the coinbase transaction:

    pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nBits << CBigNum(nExtraNonce);
    pblock->hashMerkleRoot = pblock->BuildMerkleTree();

Quote
3 Where is the time (and can we change it as we see fit while mining, or are we required to keep it in a certain range)?
The time is in the header, but it must be kept in a sensible range.


Good answers. I was just gonna say work with 6 other dwarfs and capitalize on woman work.
bitless (OP)
Newbie
*
Offline Offline

Activity: 28
Merit: 0


View Profile
July 10, 2011, 05:16:27 PM
 #4

Thanks, Joel!

So, my understanding is that if we change any of these
1 then we have to rehash all previous parts of the message (i.e. the block), thus changing the first three words in the share on which a miner is working, and
2 this is what a pool does when all valid values of the nonce have been tried.

Correct? Is there anything other than w[3] (that all kernels are currently changing) that we can change on the client side without having to change w[0] through w[2]?

(Joel - I'll send you a whole 1 BTC when you answer this, even if the answer is a no Smiley thank you very much!)
JoelKatz
Legendary
*
Offline Offline

Activity: 1596
Merit: 1012


Democracy is vulnerable to a 51% attack.


View Profile WWW
July 11, 2011, 12:10:05 AM
 #5

Thanks, Joel!

So, my understanding is that if we change any of these
1 then we have to rehash all previous parts of the message (i.e. the block), thus changing the first three words in the share on which a miner is working, and
That's correct. Changing the timestamp or coinbase gives you a whole universe of new nonces to try.

Quote
2 this is what a pool does when all valid values of the nonce have been tried.
Most pools, to my knowledge, use the bitcoind client's logic to generate work units. With the fix from Luke Dash Jr., the logic looks like this:

void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce, int64& nPrevTime)
{ // Fix from Luke Dash Jr
    static uint256 hashPrevBlock;
    if (hashPrevBlock != pblock->hashPrevBlock)
    {
        nExtraNonce = 0;
        hashPrevBlock = pblock->hashPrevBlock;
    }
    ++nExtraNonce;   
    pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nBits << CBigNum(nExtraNonce);
    pblock->hashMerkleRoot = pblock->BuildMerkleTree();
}

So the extra nonce (coinbase) goes to zero with each new block found on the network. Then increments in each work unit given to a client.

Quote
Correct? Is there anything other than w[3] (that all kernels are currently changing) that we can change on the client side without having to change w[0] through w[2]?
I'm not 100% sure I understand what you're asking. Are you trying to be able to have miners generate their own new work units without having to go back to the pool? If so, it's a bit tricky because if they succeed in mining a block, you have to be able to assemble the correct block or you can't get paid.

If you're trying to have something other than the bitcoind program generate the work units (maybe you're trying to minimize the interactions between the pool manager and bitcoind) you're better off with the patches to speed it up. But in that case, you're best off replicating this same logic of increment the coinbase for each work unit, IMO.

You can't ever run out of things to try because by the time you ran through every combination of nonce and coinbase, the time would have changed. If you really want to, you can also change the payout address(es) in the coinbase transaction or drop/add a transaction.

Quote
(Joel - I'll send you a whole 1 BTC when you answer this, even if the answer is a no Smiley thank you very much!)
Thanks. I appreciate it. If I misunderstood your question, let me know.

I am an employee of Ripple. Follow me on Twitter @JoelKatz
1Joe1Katzci1rFcsr9HH7SLuHVnDy2aihZ BM-NBM3FRExVJSJJamV9ccgyWvQfratUHgN
bitless (OP)
Newbie
*
Offline Offline

Activity: 28
Merit: 0


View Profile
July 11, 2011, 06:28:44 AM
 #6

This was the best answer I've ever read on any of the forums.

1 BTC sent.

Thank you!
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!