Hot answers tagged

38

Basically, there is no such thing as a "correct" nonce, only a set of possible "correct" blocks which can use any nonce they wish to obtain an acceptable hash. So the nonce is just "some arbitrary number". But in order to understand how nonces work, you first have to understand the hashing process by which blocks are produced. Cryptographic hashes are a ...


28

The difficulty is already to the point where it requires over a quadrillion hashes to solve a block. 2^32 is only 4 billion. Fewer than one in a billion times will there be any nonce that makes the block valid. A miner simply has to try every possible nonce on a different block. He can vary the coinbase, the transaction set, and/or the block timestamp. Any ...


12

A 2X rate with a 50% chance of missing a winning nonce is no advantage at all. Incrementing the nonce is the easiest mechanism of choosing the next nonce to try, so you try the most nonces per second that way. That's all that matters. Perhaps you are under the mistaken impression that everyone is trying to mine the same block. That is not so. If you are a ...


10

This really helped me understand it: 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.


9

extraNonce gets put into the input of the generation transaction. getwork clients can't see transactions, so they can't update extraNonce. Some miners instead modify nTime slightly to give them more nonce space. extraNonce is used by bitcoind, but it's not part of the protocol. There is no extraNonce field in blocks or transactions.


9

Nonce is a 32 bit arbitrary random number that is typically used once. In Bitcoin's mining process, the goal is to find a hash below a target number which is calculated based on the difficulty. Proof of work in Bitcoin's mining takes an input consists of Merkle Root, timestamp, previous block hash and few other things plus a nonce which is completely random ...


8

I think that Tim S. may have the answer with his comment about endian-ness. Your observations about the nonce having its lowest byte zero (being a multiple of 256), are with respect to the little-endian byte order of the block itself. From the perspective of a big-endian machine, these are statements about the high byte of the nonce. So consider a miner ...


7

First of all, when 1 second has passed, the miner can just increment the timestamp in the header. This already gives us 4 Ghash/s rather than 4 GHash/block. When this is not enough, and the nonce range is exhausted before a second has passed, the miner builds a new proposed block with a hash to search through. Specifically, the very first transaction in the ...


7

This mining simulator is a good visual of what is being hashed. http://www.yogh.io/#mine:last People are correct you don't have to change the Nonce it's just the fastest way to get a different hash output. You could very well keep the nonce at 1 and change the timestamp, or the list of included transactions, which would change the merkelroot. What's ...


6

Ordering the bytes that make up a block so that you can hash them seems to be fairly complex, but if all you're looking for is an arbitrary string that hashes to something beginning with a few zeroes, you can search using a simple shell command: $ i=0; while true; do echo -n $i | sha256sum | grep -q '^000' && echo $i $(echo -n $i | sha256sum); ...


6

It's not unevenly distributed. The reason it appears that way in the graphs above is because the x-axis is plotted in logarithmic units. Here's what it looks like in linear units:


6

The miner can change the block header hash several different ways: Change the timestamp. This is the least intrusive, but works just fine. If you can do more than 4 Th/s, this starts to become a problem. Add transactions. Adding any new transaction changes the Merkle root, so this gives you entirely new nonce spaces. Change the coinbase transaction. This is ...


6

They were never "waiting" in the first place. A miner is incrementing nonces and computing hashes continuously. As soon as a new transaction a2 arrives, it is added to the Merkle tree, the block header is regenerated, and hashing continues with the new block header. It's misleading to call this a "restart", since that implies there was some progress that ...


6

The block hash has to be below a certain value and the block hash depends (among others) on the nonce and on the Merkle root. The Merkle root depends on the sequence of transactions. Note that it's a sequence, not a set, meaning the order is important. Different miners choose many different lists of transactions. For every list of transactions with the ...


5

Yes, it is possible to not find a valid block for all 2^32 possible nonces, and that is indeed the typical case. I believe only at the minimum difficulty level, sometimes still used as basis for finding shares in pooled mining, would you even average(!) one valid block out of all possible nonce values. There is a timestamp field you can update, and there is ...


5

When the nonce range is exhausted, miners change the extraNonce field of the generation transaction. This changes the Merkle root in the header and allows a new range of nonces to be attempted. Since the Merkle root is 256 bits, this can be repeated indefinitely.


5

You assume that there exists (exactly?) one block for each work unit. This is not true, there are many variables (timestamp, nonce, transactions in a block, extranonce inside the block's coinbase transaction, ...), and all of them influence the block's hash. Each hash has a chance (as of October 2013) of less than 1 in a billion billion (1.15*10^18 to be ...


5

The nonce is an arbitrary string of bits with no particular meaning. Typically they are converted into an unsigned integer for convenience. Every possible set of nonce bits has a corresponding integer in this representation. To get letter in a nonce, you'd have to present the bits in the nonce in some encoding scheme that had some way to encode letters. ...


5

Whether or not there is a solution depends on the contents of the block as well as the possible values of the nonce. The transaction block can be altered if necessary which essentially means you get another 32 bits of nonce values to try. There is an additional component of a transaction block called the "coinbase" that can be altered without altering the ...


5

There's no guarantee that you can solve a block just by adjusting the nonce. But there are other things you can change in a block that also change the hash. This question is pretty much an exact duplicate of your question.


5

Miners that aren't cooperating will never replicate work because they each want to get a different block as the next official block. If nothing else, the account the mining fee is paid to will be different. (And this ripples up to the header.) For miners that are cooperating, work units are assigned by the mining pool. The pool will typically embed a ...


5

As you noted, the logarithmic scale skews it right, because the number of nonces within log(10, nonce) > 9 is 3 times larger than log(10, nonce) < 9 The other factor that might skew the nonces on your chart is that a pattern in the nonces on the blockchain doesn't necessarily mean that it's caused by a problem in the mining algorithm. As a trivial ...


5

The hashing function used in Bitcoin is deterministic, that is hashing the same input, i.e., block header, will always result in the same output. This is necessary so that others can also check that a Proof-of-Work is valid. This means that in order to compute a new hash the input to the hash function needs to be altered. The easiest way to alter the input ...


5

There's a difference between what is called a "golden nonce" in the context of the source and a valid block header hash. To reduce payout variance, miners group into pools and share their income proportionally to their hashpower. To determine each miner's hashpower, pools use a share system: when you are mining and find a block header of high difficulty (...


4

Every miner is working on a slightly different block because each block pays out the block reward to a different address. There's almost no chance of the network hashing the same thing twice.


4

The clients make use of the Target to determine if a block hash is valid and will be accepted by the network. The Bitcoin wiki states the following: The target is a 256-bit number (extremely large) that all Bitcoin clients share. The SHA-256 hash of a block's header must be lower than or equal to the current target for the block to be accepted by the ...


4

It doesn't matter where you start. The block you're hashing is unique because it's the only one that includes the mining bounty (new coins and transaction fees) being payed to your address. A timestamp is also included, so every second, you could start the nonce over at 0 and increment.


4

This is essentially like asking: "When buying a lottery ticket is it better to have a zero or a random number in my lottery number?" The reality is that it actually doesn't matter because it's an entirely random process, just like winning the lottery.


4

Changing the timestamp is one way, but the more scalable method is to change the "extraNonce" field of the generation transaction, which changes the block header's Merkle root.


4

There were many good answers to this question. After reading through them, I'm going to take a stab at the answer as well. The coinbase field of the coinbase transaction (as it is called) is really just a scriptSig which doesn't have to pass any validation about its contents (except that it is less than 100 bytes, and the newer BIP34 requirements). Satoshi ...


Only top voted, non community-wiki answers of a minimum length are eligible