SPECIFICALLY BITCOIN POW

Before we get into the details of what PoW means, we will say that the following description is based on how PoW is designed for the bitcoin blockchain. PoW for other blockchains will be somewhat similar but not necessarily precisely the same. We will also try to stay focused only on the salient aspects of PoW. We will try not to include extraneous details about closely related mining topics.

JUST USELESS “MAKEWORK”

Now, let’s also clarify something surprising about this process. Strictly speaking, the actual work itself performed during the POW effort produces no genuine useful output. This may be an arguable point, but the fundamental purpose of the PoW work itself is to make it very costly to add blocks to the blockchain. The high cost is to discourage rouge miners from trying to inject fraudulent blocks into the blockchain. PoW is also a way to control the rate of new coin additions. It is, by design, a very wasteful and processor-intensive activity.

BUT A USEFUL RESULT

The indirect yet absolutely essential side-effect of PoW is that the miners successfully performing this work will be the ones to add new currency transactions to the blockchain. This helps to ensure that only valid transactions exist on the blockchain. All active miners on the planet are simultaneously competing to win the right to add the next block to the blockchain. They compete by furiously attempting to be the first miner to prove that they have found the solution to the current PoW for their block of transactions.

THIS IS HOW POW WORKS

You will often read that PoW is vaguely described as the process where miners try to solve a complicated mathematical problem. We will now explain what that difficult mathematical problem is, without getting too technical.

A CANDIDATE BLOCK TO PROVE

In the following text, we will use the term “Candidate Block”. The candidate block is a block of data containing a Header and a list of new currency transactions to be added to the blockchain. The candidate transactions are found in a world-wide global “pool” of transactions. Before the Candidate block can be added to the blockchain, PoW must be performed on it.

A candidate block contains the following fields that are pertinent to this PoW discussion:

The block header which contains the following data items

  • The nonce (which is really just a counter)
  • The long string representing all the data in the candidate header
  • The “Target” hash value (set globally by the bitcoin system)

And other block data that does not directly get used as part of PoW:

  • Recent Transaction list (many)
  • Merkle hashes (many)

THE INTENSIVE WORK IN POW

The “work” in Proof-of-Work is an intensive trial-and-error effort (you can call it guessing) by miners to search for a unique magic number called a nonce. A nonce is just an integer number that can range from 0 to 65535. During the search, the nonce will be incremented by one and then combined with data in the candidate block’s header. The result will then be fed into a mathematical formula (called a Hash). The output value of that Hash is compared to a Target value to determine success.

WORK UNTIL SUCCESS

The test keeps running, and the nonce will keep incrementing for each test until success is determined – or until some other miner finds a successful nonce first. A successful nonce means that the nonce value can be used to pass the test. When successful, the Candidate block can be added to the blockchain for final validation.

This work may sound somewhat trivial for a computer. But it is not due to the complex mathematical algorithm, the size of the numbers involved, and the number of times the test is typically run on one candidate block. It is actually (and intentionally) a very processor-intensive effort.

WHAT IS THE TEST?

In the test mentioned above, each iteration of the computed output value of the hashed blocked header (called the Test Hash) is compared to a predefined Target value (called the Target Hash). If the Test Hash output is less than or equal to the Target hash value then a valid nonce has been found, and the PoW is complete. The testing will be stopped before this success if some other miner finds a PoW solution for their own proposed candidate block first. Only one block can be minded and added to the blockchain every 10 minutes, so all miners are in a race with each other to pass the test.

HOW TO MEASURE SUCCESS

The Target hash value indicates the difficulty (i.e. work) of finding a successful nonce value that will pass the test. It is easier/faster to find successful nonces when the Target Hash is a large number. It is harder/slower to find a successful nonce for a small Target hash.

CONTROL THE RATE OF SOLUTIONS

Bitcoin blocks are designed to be added to the blockchain at a rate of roughly every 10 minutes, on average. It was long ago decided that blocks should not be added faster. But, as technology advances, allowing tests to be computed more quickly, blocks would start to be added faster and faster. So something must be adjusted to counteract this advance. That is why Bitcoin PoW has a built-in mechanism to ensure that the work gets more difficult (i.e., more processor-intensive) as the months and years go by.

The global value of the Target Hash is reevaluated and updated to throttle the rate of block additions. This reevaluation happens after every 2016 block additions to the blockchain. This occurs roughly every two weeks. If the previous 2016 blocks were not added at the desired average rate of one block every 10 minutes, then the Target hash will be adjusted. When the recent block additions were added too slowly, then the Target Hash is increased. When they were added too quickly then the Target hash value is reduced. Reducing the Target hash makes the test more difficult to pass, which will intentionally slow down block creation to get it back to the 10 minutes per block rate. Although sometimes the Target hash may be increased, this less common. More likely is that the Target Hash decreased thus making the test more challenging to pass. Since mining power will keep advancing into the future, the difficulty factor will need to keep getting harder.

SUMMARY OF POW

In summary, PoW is the intensive effort to find a nonce that can pass a mathematical Hash test. The test is to hash the block header data and compare it to the Target Hash value. When the test hash value is less than the Target hash, then the block is declared valid, and the block is added to the blockchain. Solving for this magic nonce takes a lot of processing power and time. That is what is referred to as the “work” in Proof of Work. The design of bitcoin uses a system that intentionally requires a lot of work from the miners so that the rate of block generation (and therefore, bitcoin creation) can be controlled.

FUN FACTS ABOUT POW

That is the most basic and focused way to describe PoW. Below are a few “fun” facts related to PoW.

MORE THAN ONE NONCE

For any given candidate block, there can, and probably will be more than one valid nonce. The total number of possibly valid nonces for each candidate block will depend on the Target hash size. The smaller the Target hash, the fewer possible nonces that can be valid for that block. The larger the Target, the more possible nonces that can be valid. But this fact is not really materially important since a miner is only looking for the first valid nonce that can be found. At that point, the testing will stop.

IMPOSSIBLE NONCE

If the Target hash is small enough, there can be times when there are no valid nonces for that candidate block. In this case the candidate block must be changed in some way so that the testing can start all over again. Changing can be done by rearranging and/or changing some of the data in the block. But it is more likely that some other miner will probably find a successful nonce before any other miner discovers that their candidate is impossible to solve. In which case, the winning miner will submit their candidate block to the blockchain, which will cause all other mining to stop. If this happens, then the miner with the unsolvable block will probably never discover that they might have created a block without a nonce solution.

EASY NONCE

It is POSSIBLE that the very first test will be successful with the very first nonce. This will mean that the PoW for this block was not much work at all, but this case is statistically exceedingly uncommon.

NONCE + 1

Typically the nonce is always incremented by 1, but it is not a rule. You don’t want to waste any computation power by testing the same nonce twice. An easy way to avoid this is to increment the nonce by 1 at the start of each test. That is the easiest way to ensure every unique nonce is tried and never duplicated.

OTHER USES FOR NONCE

Since nonce just means a “number used only once”, it was not invented for the PoW process. But most non-math majors nor old bitcoin hands would typically not know this name. A Nonce can be used in other ways, for other reasons, besides in the PoW algorithm. For instance, other blockchains use a Nonce for different purposes.

  • nonce
  • Target hash
  • hash
  • block / candidate block
  • Merkle Root and Tree
  • Mining
5 1 vote
Article Rating
Category: Mining
Did you find this FAQ helpful?
Thumbs Up Icon 9
Thumbs Down Icon 2

Leave a Reply

5 1 vote
Article Rating