Question about getblocktemplate

1

1

I'm having trouble understanding getblocktemplate.

From https://en.bitcoin.it/wiki/Getblocktemplate,

I see how to build the block header and then begin hashing by incrementing the nonce, the same as I would perform work on the result of a getwork call.

What I don't understand is the following

Since you're making all the blocks yourself, you really don't ever need to get another template... until it's invalid.

After I construct my merkle root and then my block header, and hash away by incrementing the nonce, then what? How do I "create" a block? Surely I will overflow the nonce quickly with an ASIC - so what else am I varying while hashing?

I feel like I am missing a very important step.

Thanks in advance!

dacox

Posted 2015-12-22T21:25:50.663

Reputation: 23

You should look at BIP 22/23Nick ODell 2015-12-22T23:34:19.810

Answers

2

Once a client has the template it can modify it to make the header different, giving you a new nonce range to search. In modern miners this happens thousands or tens of thousands of times a second.

  • The timestamp in the header can be updated if needed, this is known in old software as nRollTime. This method is generally not used anymore because you only get one new range per second.

  • The "extraNonce" can be updated, the random data in the coinbase transaction is altered and the merkle tree is re-hashed up to the root, which changes the header. This technique is used by Stratum miners as well.

  • Transactions can be added or removed from the tree.

GBT and Stratum are distinct from an old system called GetWork which simply gave out just a partially hashed header, every time the nonce range was exhausted the client would need to make a new request to the server they were mining from. This is what your quote is alluding to.

Anonymous

Posted 2015-12-22T21:25:50.663

Reputation: 10 054

Okay, so I should be updating the nonce and extra nonce, and possibly the timestamp if I don't feel like excluding any transactions then?dacox 2015-12-23T07:15:49.997

You must always update the timestamp or you will produce invalid blocks. Iterate the nonce until you reach 2^32, then change the extraNonce.Anonymous 2015-12-23T08:35:00.983

The timestamp should always just be kept in sync with my current time?dacox 2015-12-23T20:48:08.657

That's correct.Anonymous 2015-12-24T00:45:09.893