**Qtum Staking Guide: When Block Reward?**

Jackson Belove

May 23

https://blog.qtum.org/@jb395officialA common question from people staking on Qtum is: “when do I get my block reward?” and “why is it taking so long?” This blog answers these questions with a gentle introduction to probability, studying actual blockchain results, and running some simulations.

TL;DR: Since Qtum block rewards are given in a random process, we used several approaches to answer the question “when block reward?” The wallet’s “Expected Time” is a probability term for the long-term average of a random process. Over many block rewards, 63% of the time a wallet will receive a block reward before the Expected Time, but the random process means that block rewards could come much sooner than the Expected Time, or much later.

The random spacing between block rewards will average out in the long run, but individual block rewards can have significant variation, and for longer spacings, this can be frustrating. On the long spacing side, users have reported spacings of 6 to 10 times the Expected Time, with one Reddit user reporting 13 times. Of course, no one complains when their block rewards come much sooner than the Expected Time, and this variation is all part of the random lottery process for block rewards.

To confirm your wallet is set up properly for staking, check these things:

- Wallet updated to the latest version
- Syncing to the latest block
- Unlocked for staking only
- Computer clock set correctly [Reference 1]

There is some math coming up below, but you can skip the math and just look at the charts and tables, which give the answers.

Probability 101You intuitively know how probability works for dice. Probability lets us make calculations about random events like rolling dice (or Qtum block rewards). We will start considering a die (a single dice) and define success as rolling a “1”. You expect to get a “1” every 6 rolls (“Expected Time” = 6), but also know you are not guaranteed to get a “1” every 6 rolls because this is a random process.

The probability of an event occurring is given on a scale of 0 (will never happen) to 1.0 (definitely going to happen). The probability of getting a “1” in a single roll of the die is 1/6 or 0.167.

We can use this same approach to calculate the probability of winning a Qtum block reward for the next block. To make the math easier, let’s consider a wallet with 20,000 QTUM, and a Network Weight of 20,000,000. The wallet software makes the probability of winning a block reward 20,000 / 20,000,000 = 0.001. What does this mean, compared to the die?

Here we see the probability of success for a single trial, getting a “1” in a single roll of the die, or a block reward on the next block, and the Expected Time to the successful result.

This “Expected Time” is the same answer given by the Qtum wallet for a given wallet weight and network weight, which the wallet calculates based on the difficulty of minting a new block. For our example, the expected time is 1,000 blocks or about 40 hours.

Reference 2 shows a calculation for the probability of getting a “1” within 6 rolls of the die (33.5%) and for getting a block reward by the Expected Time (63.2%).

**Blockchain Results**To test our understanding of block reward probability let’s look at some actual results on the Qtum blockchain (data sources and methodology given in Reference 3). We can compare the theoretical (calculated) probability with the experimental (observed) probability. An ideal candidate for this experiment would be a wallet that began staking soon after the launch of Mainnet and has had no additions or withdrawals. We won’t adjust for changes in network weight over time or the increase in wallet size due to block rewards and will assume the wallet stayed online the whole time. Also note the experimental wallet received fewer block rewards early on because they didn’t split their UTXOs into small amounts, like this.

To get enough block rewards to analyze we can look for a big wallet and find one that started with about 19,000 QTUM in mid-October 2017, and with block rewards have grown to the 20,500 range (in the mid-300’s on the rich list). To get a sense of how smaller or larger wallets would work, simply scale the results below up or down linearly. For example, a wallet staking 500 QTUM would see block reward spacings 40 times larger than our experimental wallet.

In 580+ days of staking this wallet won hundreds of block rewards. To see the variability in block reward spacing, here is a chart of 100 spacings of sequential block rewards for the wallet:

*Block Reward Spacing Sequence^*

How to read this chart? The horizontal axis is 100 sequential block rewards for our experimental wallet. The vertical access is spacings in hours. You can see some significant variation, for example, block 18 had a spacing of 7 hours and block 19 had a spacing of 333 hours (almost 14 days).

The average spacing for all the block rewards was 40 hours, the closest spacing between block rewards was 21 minutes, and the longest spacing was 13 days 21 hours.

For this wallet, the plot of sorted spacings between block rewards shows a linear section with a rising tail on the right side which leads to the long spacings:

How to read this chart: the vertical axis shows spacing in hours between block rewards and the horizontal axis shows the sorted sequence of the actual block reward spacings.

Why is there a long tail on the right side? This is due to the fundamental nature of determining “success” by selecting a small target range of the random numbers provided by the SHA256 hash algorithm. There is a real chance that the wallet can have a run of “bad luck” and not win a reward for many blocks. This long tail is similar to results rolling the die. For example, the Expected Time for rolling a “1” is 6 rolls, but 1% of the time, you won’t get a “1” for 25 rolls. That is the long tail from random numbers.

Network WeightBecause we have all the data in hand for this wallet, it is easy to calculate the long-term average Network Weight which looks like this:

Wallet Weight x (total blocks/block rewards for this wallet) = Network Weight

20,000 x 994 = 19.9 million

This would represent an average Network Weight from the mid-October 2017 starting date, and represents (without compounding) a 4.4% annual return.

**Simulation**

Manually analyzing blockchain data is tedious, so a Python script can be used to simulate block rewards and the spacing between them. The simulation uses the SHA256 hash algorithm as the random number generator (same as Qtum Proof of Stake consensus code) and can be run for many block rewards (GitHub link to simulator, data set, and charts). For a simulation similar to the experimental wallet above, we can use a wallet with 20,000 QTUM, a Network Weight of 20,000,000, and run for 2,000 block rewards which required approximately 2 million blocks (the equivalent of 9 years):

This simulation had an Expected Time of 1,000 blocks (40 hours). For a wallet this size, in 9 years there were 2 back-to-back block rewards and the longest spacing between block rewards was 12.4 days. The 5% quickest block rewards were less than 108 minutes and the 5% slowest block rewards were longer than 4.9 days. For probability geeks only, see reference 4.

**Brain Teaser**Rolling the die or trying for a Qtum block reward are called “Independent Trails” in probability, which means each roll of the die or Qtum block reward is a new probability event with an identical chance of success. The previous results have no influence on the results for independent trials. Contrast this, for example, with double-deck Blackjack, and if you can count cards this is not a game with independent trials.

With charts for the experimental wallet and simulated wallet, we can definitively say when the next block reward will come: it is going to be one of the dots on these charts,

**which is not a useful answer.***Brain scan courtesy National Institute of Mental Health, National Institutes of Health, Department of Health and Human Services*

Let’s look at “Expected Time” more, with a brain teaser. For our experimental and simulated wallets, the Expected Time is 1000 blocks (about 40 hours). After half the Expected Time has elapsed from the last block reward, what is the Expected Time to the next block reward?

Answer:

** The Expected Time is still 40 hours!**This has to be true because of independent trials. The Qtum SHA256 hash random number generator lives in the moment, has no history, and can only tell who wins the next block reward. “Independent Trials” means each new block reward, like each roll of the die, is independent of any previous results.

To get a more useful answer for “when block reward?” let’s look at some more probability and the Pareto Line chart.

**% Chance of Block Reward**What would be useful for “when block reward?” is something like a weather forecast that says there is a “50% chance of rain.” This doesn’t mean it is definitely going to rain, or definitely not rain, but you know that about half the time, you are going to get wet. How can we use probability to give a similar forecast for block rewards?

The answer is the Pareto Line, which gives the cumulative percentages of block reward wins, as referenced to the Expected Time. The chart below is based on the 9 years of simulated block rewards, but the experimental wallet and theoretical probably calculations give the same line:

*% Chance of a Block Reward for a given multiple of the Expected Time*

How to read this chart? The horizontal axis gives the multiple of Expected Time. The vertical axis gives the percent chance of a block reward. The red lines show that there is a 63% chance of receiving a block reward before the Expected Time. This means after your wallet receives 100 block rewards, about 63 of them will have arrived before the Expected Time.

Here is a handy table which gives the % chance of block rewards for various points along the Pareto Line.

Taking the bottom row, a wallet would see a block reward 95% of the time before 3 times the Expected Time (120 hours) and would not get a block reward 5% of the time over the same period.

References

**1, ** To see if your computer clock is set correctly the command “getnetworkinfo” should give a “timeoffset” value of 0 or a few positive seconds.

**2, ** We can’t use probability directly to calculate success over multiple trials. However, you can calculate the probability of failure over multiple trials which is the product (multiplication) of the individual failure probabilities.

The probability of not rolling a “1” with the die is:

1.0 minus (probability of “1”) which is 1.0-0.167. = 0.833

This makes sense because there are 5 ways out of 6 to roll a number other than “1”. Probability math says the probability of not getting a “1” for 6 rolls is 0.833 multiplied by itself 6 times:

0.833 x 0.833 x 0.833 x 0.833 x 0.833 x 0.833 = 0.335

This means for a large number of die rolls, we would not get a “1” in 6 rolls 33.5% of the time. Then to calculate the probability of getting a “1” within 6 rolls we can subtract 0.355 from 1.0:

Probability of getting a “1” within 6 rolls = 1.0–0.335 = 0.665

which means for a large number of rolls, we should get a “1” within in the first 6 rolls 66.5% of the time.

Using the same math for a wallet with 0.001 probability of winning a block reward gives the probability of not getting a block reward of 0.999. The probability of not getting a block reward in the 1000 blocks (Expected Time) is:

0.999 ** 1000 = 0.368

Here we multiply 0.999 by itself 1,000 times (0.999 is the base and 1,000 is the exponent).

The probability of getting a block reward by the Expected Time is then 1.0 minus the probability you don’t get a block reward:

1.0 - 0.368 = 0.632

Which means over many block rewards you will get the block reward within the Expected Time 63.2% of the time.

**3,** Data from the qtum.info API, using these URLs with screen scraping into Excel:

All the transactions for a given address:

https://qtum.info/api/address/<Qtum address>/utxo

Get transaction details including whether this transaction initiated a block reward:

https://qtum.info/api/tx/<transaction ID>

**4,** Some probability results for block reward spacings

Experimental Wallet

Average: 39.8 hours

Median: 23.6 hours

Variance (total population): 2289.9 hours squared

Standard Deviation (total population): 47.9 hours

**Simulated Wallet**Average: 39.9 hours

Median: 28.6 hours

Variance (total population): 1636 hours squared

Standard Deviation (total population): 40.5 hours

5. Learn about probability on Kahn Academy, Probability

6. More Jackson blogs

https://medium.com/@jb395official

Qtum Telegram Channel:

https://t.me/qtumofficial