I read RandomX design and specs from https://github.com/tevador/RandomX/tree/master/doc to understand the mining process. At step 14 of the algorithn description it ends up with a result hash: R = Hash256(RegisterFile). In modern CPUs it takes around 1.6ms to calculate a single hash result in fast mode, so hundreds of hashes are calculated per second.

My question here is: How a miner knows which hash result among all other been calculated is a winner to be rewarded? What is the condition for the result hash to be a winner?

It is not in that docs and I couldn't find it Googling.

1 Answer 1


What is the condition for a hash result to be considered the winner and be rewarded?

The result (a hash), is just a 256 bit number. Every time you change the data you are hashing, you'll get a new, different and unpredictable 256 bit number. If it's smaller than another number (which is a representation of difficulty), you've can submit the block data used to create that hash to the network, and hopefully earn Monero.

A simplified example:

Let's say the maximum possible difficulty is 32, your hash function returns numbers between 1 and 32, and the current network difficulty is 2. You need to find a number (the hash), that when multiplied by the network difficulty (2 in this case), doesn't exceed 32, so you're looking for a number that's 16 or less – you have a 50% chance of finding a winner on each attempt, so you should find a hash that meets the difficulty requirement pretty quickly.

But when the network difficulty rises to say 5, your range of possible winning numbers is smaller; you're now looking for a number that's 6 or less – each attempt you now only have ~18% chance of finding a "winner". So, as the network difficulty increases, the range of "winning" numbers get's smaller.

How a miner knows which hash result among all other been calculated is a winner to be rewarded?

A "winner" is not the quite the right term to use here. Rather, does the hash (of the block data), meet the network difficulty requirement, as explained above. The reason I say this is because multiple miners may find results that meet the current network difficulty requirement. How quickly you advertise your "winning" block data and how well it meets the difficulty (how small the hash is), will help determine if you ultimately earn the block reward. As blocks are advertised and propagated across the network, multiple chains can form. Consensus as to which chain of blocks forms the main chain is reached based on most work done in any given chain. "Most work" here meaning the cumulative difficulty of blocks in a given chain. So long as your block ends up on the chain with the most work done, you'll earn Monero.

If it's not obvious, the block data itself (and thus the transactions it contains also), have to be valid – you can't just submit any old random data that produces a hash which meets network difficulty.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.