Simulating Proof of Stake Mining for Qtum

A simulation to quantify PoS returns

(edited and updated version, original published on QtumNexus Slack September 2, 2017. While this article is based on the Qtum Skynet test network using test coins, staking behavior and block reward mechanics are identical on Mainnet Ignition)

September 2, 2017, Skynet v1.2 — Qtum Core version v0.14.2.0–797c365-dirty (64-bit)

I am an independent researcher, not affiliated with the Qtum team, but I would like to acknowledge and have great appreciation for their advice and help along the way.

There has been some discussion about Proof of Stake (PoS) block rewards on the QtumNexus Slack this week, and I wanted to see how it works and simulate some results.

Thanks to cryptominder’s excellent article (https://steemit.com/qtum/@cryptominder/qtum-staking-tutorial-using-qtum-qt ) I was able to setup the Skynet miner. The wallet installation was quick and easy, waiting for coins to mature and waiting for the block rewards are the hard part.

The probability of receiving the block reward for any block period is given by “your weight” (the number of mature coins in your wallet — coins with at least 500 confirmations) divided by the “network weight” (a calculated estimate by the wallet of the total coins being staked on the network). At 675 blocks per day (targeted for every 128 seconds) the probability of receiving a block reward in one day is

To simulate the results for various weights, I wrote a Python script that uses a random number to simulate receiving PoS rewards, that can run over long periods of time. The script calculates the wait in days between block rewards.

The heart of this code is the line below which reduces my weight by the stake size, even for multiple overlapping stakes, which is the same behavior used by the wallet.

With this script, it was easy to try different combinations of “your weight” and “network weight”. Running the simulation for 10 years evened out some of the variation from the random numbers. The script calculates the number of blocks between rewards (the wait between block rewards), which is what you are going to experience running the staking wallet, and helps answer the question — how long until my next block reward?

The simulation results seem to agree with the wallet calculations, for example, with 51,000 test coins and a network weight of 86,700,000[1] the wallet shows the expected time to earn reward of 2 days (rounding up) and the simulator gives 1.64 days for the median.

I tabulated results for the median and 10% longest waits.

· Median: For all the block rewards received, the median wait (the midpoint of the sorted waits between blocks). Half of the blocks received will have wait times less than or equal to this median, so wait times could be the very next block (aren’t you lucky?) up to the median.

· 10% longest waits: For the 10% longest wait times, what is the wait between blocks going to be? You are going to experience these waits for 10% of your block rewards.

Now let’s plug some numbers into the simulator.

How to read this table for 10,000 QTUM staked: If the network weight is 10,000,000, and you are staking 10,000 coins, then for half of the block rewards you receive, the reward will occur within 0.95 day or less from your previous reward. For 10% of the time, there will be at least 2.64 days between block rewards. You will receive 967 QTUM in block rewards per year (this calculation includes a small amount for transaction fees). This represents a 9.67% annual return.

Qtum currently has a population of 100,000,000 coins and will have an inflation of about 1% per year from PoS mining. Mining results are inversely related to the network weight, here are the simulations for some other network weights.

For a network weight of 15,000,000, the simulation showed a 6.5% annual return.

For a network weight of 20,000,000, the simulation showed a 4.8% annual return.

Here are some initial observations from staking on Skynet using the desktop wallet.

· Coins mature after exactly 500 blocks in the wallet. The block time is currently averaging 2.39 minutes, so this means 20 hours.

· If you have 1,000 mature coins your staking weight will be 1,000. If you then send 750 coins to the wallet, exactly 500 blocks later your weight will change from 1,000 to 1,750.

· If you restart a wallet containing mature coins it will take a minute or two to reactivate the maturity. The wallet will restart with the outline lightning bolt with mouseover messages of “Not staking because the wallet is offline” or “Not staking”, but just wait for staking to resume.

The screenshot below shows the right side of my wallet for a block reward starting at 8/31/2017 17:06. An initial payment of 0.4 QTUM is followed 502 blocks later with 9 more payments of 0.4 QTUM for a total of 4.0 QTUM (the first of these additional 9 payments is shown below at 9/1/2017 13:22) My first block reward took 2 days (1638 blocks) after these test coins matured, the second came 1040 blocks later, and unless you are a whale, patience is a virtue for PoS mining.

Happy mining to all, anticipating the Mainnet launch on September 8.

JB395

[1] Skynet has some brutally high network weights, sometimes topping 100,000,000.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.