Why Cryptocurrency Mining is Just Like Roulette

Luck figures into crypto mining in an important way.

Mike Crawford

Mike Crawford
Consulting Software Engineer
mike@soggywizards.com

Wednesday March 14, 2018

Some mining pools call it "Luck", other pools call the inverse of Luck the "Effort".

Among many other things, to mine an entire block requires one's rig to find a correct value for an item in the block header called the "Nonce".

If you can find the Nonce before anybody else does, you are given the "Block Reward". For LiteCoin, the Block Reward is 25 LiteCoins.

At the current exchange rate 25 LTC is over $4,300.00.

Here's a complete explanation:

The LiteCoin header contains a "Difficulty" field. As time progresses, the Difficulty gets larger and larger as mining rigs get faster and faster.

The Difficulty is adjusted so as to maintain a constant time interval between each successive block. For LiteCoin that interval is two and a half minutes.

The Difficulty should perhaps be called the "Easiness". A large number in that field makes it easy to mine each new block. A smaller number makes it harder.

If you're really lucky, it won't take much time or effort to find a valid Nonce. If you're unlucky it will take a long time and a lot of effort.

The time and effort required to find a good Nonce are nothing more than blind luck.

Now the truly technical part:

The irreversible hash of the block header is required to be numerically less than the Difficulty value. The Nonce is in the block header, so altering the Nonce also alters the header hash.

There's really no way to figure out what the Nonce should be other than a very simple brute-force search. It's just as good to try a simple sequence - 0, 1, 2, 3, 4, 5... - as any other possible way of finding a good Nonce.

So one's mining rig sets the Nonce to 1 then computes the hash of the entire header.

If that hash is numerically larger than the Difficulty, the rig tries setting the Nonce to 2 then hashes the header again.

You can see that rigs that hash more quickly also find valid Nonces more quickly. The specifications provided by the eCommerce sites that sell mining rigs always state the "Hash Rate" - more commonly found as just one word: "Hashrate".

My Bitmain Antminer L3+ has a hashrate of 504 MH/s - 504,000,000 hashes per second.

Eventually someone stumbles upon a valid Nonce. They will immediately submit the entire block to the Blockchain Pools.

Sometimes two different miners find a good Nonce simultaneously. That results in a kind of race:

At first both of the two competing blocks are accepted by the Blockchain Pools. This is called a "Soft Fork".

Over time more blocks are submitted. Each block is "Back Linked" - that is, each block contains a reference to the previous block. In the case of both LiteCoin and BitCoin that reference is the header hash of the previous block.

So the blockchain will - temporarily - grow two different appendages, with new blocks being added to one arm or the other depending on the value of its Back Link Previous Header Hash value.

After some time, it will become clear which of the two arms has grown the longest - that is, which side of the fork contains the most blocks, When that happens, the shortest arm is removed, which the longest arm is retained.

At that point the Soft Fork has come to an end. It is only then that the Block Reward is given to to one of the two miners that submitted blocks simultaneously. For all that work, the loser gets nothing!

The losing sub-chain blocks will remain present in the Blockchain Pools for a little while. It's now referred to as an "orphan chain".

Eventually the software that manages the Blockchain Pools will dispose of the orphan chains so as to free up memory for more newly-mined blocks.

One Must Not Trifle With Wizards For It Makes Us Soggy And Hard To Light