# how do we have random nonces in a deterministic system

From `consensus/ethash/ethash.go`

``````// Mining related fields
rand     *rand.Rand    // Properly seeded random source for nonces
update   chan struct{} // Notification channel to update mining parameters
hashrate metrics.Meter // Meter tracking the average hashrate
``````

How can we have this random function in a deterministic system?

Is it that this comes from the miner's machine and that's what create entropy in the system, why the block generation process is stochastic?

I think the OP is asking how a random number can be used in a consensus-driven deterministic system. The question has a misconception about 'timing' in it.

The randomness comes in while all the nodes are searching for the winning block hash--this happens before the consensus step. After the block hash is found (randomly by a single miner), that miner broadcasts the block hash to each node.

The nodes then confirm the hash (which is a deterministic task), and if at least one more than half of the nodes agree (again deterministic) the block gets written to the chain.

In answer to what I think is your question: the random part (finding the block) happens before the deterministic part (coming to consensus).

• yeah, I see what you mean- I think I was also getting tripped up about- the absence of randomness from solidity and so on Jun 5, 2017 at 16:28
• if there was true randomness in Solidity, different nodes would come to different conclusions about the running of the software. I'm not certain, but I think for this reason randomness will never be part of Solidity. Someone else might know better though. Jun 5, 2017 at 16:37
• right, but then I was wondering about this randomness, but I see now that it just comes from an individual miner and it's necessary to provide the entropy of the network Jun 5, 2017 at 18:30

Is it that this comes from the miner's machine

Yes, in the case of the default mining functionality in Mist/Geth. If you create a mining tool, you can get your source of random numbers from wherever you want (could just be the digits of pi if you want).