There has been some confusion before and after Gridcoin switched to stake kernel V8 regarding the total amount of coins staking and the probabilities to stake a block. I present some estimates you can calculate from the difficulty provided by the wallet. Keep in mind that these are estimates and staking is a probabilistic process. Therefore the time it takes you to stake a block might very well be different from the estimate.

So at first lets define some variables:

blockSpacing=90s , the time between two blocks

, the time between two blocks hash is the hash value calculated by the kernel (proofHash) not the hash value of the block header, with a value between 0 and 2^256 (thanks @tomasbrod for pointing that out)

is the hash value calculated by the kernel (proofHash) not the hash value of the block header, with a value between 0 and 2^256 (thanks @tomasbrod for pointing that out) target is a very large number that is altered to make it harder or easier to create a valid hash value, in order to keep the blockSpacing of 90 seconds

is a very large number that is altered to make it harder or easier to create a valid hash value, in order to keep the blockSpacing of 90 seconds maxTarget=2^224 is the maximum allowed target value

is the maximum allowed target value diff is the difficulty to find a valid hash, being defined as diff = maxTarget/target

is the difficulty to find a valid hash, being defined as timeMask=16s , the time you have to wait until it is possible to create a new hash value with your coins

, the time you have to wait until it is possible to create a new hash value with your coins COIN=100000000 is a constant used for internal calculations since the amount of coins is stored internaly multiplied by this factor

is a constant used for internal calculations since the amount of coins is stored internaly multiplied by this factor nCoins the amount of coins you stake with

the amount of coins you stake with wTarget=target*(nCoins*COIN/1250000) , the weighted target, the more coins you have the easier it is to create a valid hash

So in order to create a block every wallet tries to create a hash value that is smaller than wTarget. It gets easier to find a valid hash with the number of coins you use to stake. But every set of coins is only allowed to create a different hash every 16 seconds. Once you have found a valid hash you are allowed to create the next block. The target value is now altered depending on the time since the last block has been created. If the time is less than 90 seconds it has to become more difficult, if the time is more than 90 seconds it has to become easier.

Probability to stake a block

The probability to stake with one try is:

pb = wTarget/2^256

But since we can try every 16 seconds and the block spacing is 90 seconds we can try multiple times.

From the Bernoulli chain we get the probability to get at least one hit with n tries: p = 1-(1-pb)^n

Now we get the probability to stake a block pbB by replacing n with the number of tries we can do in 90 seconds:

pbB = 1-(1-pb)^(blockSpacing/timeMask)

No if we put in all the variables we get:

pbB = 1-(1-(maxTarget/diff)*(nCoins*COIN/1250000)/2^256)^(90/16) = 1-(1-ncoins/diff*0.0000000186264514923095703125)^(90/16)

You can also replace the 90 seconds value in the equation to get the probability to stake in an arbitrary amount of seconds. For example replace it with 86400 to get the probability to stake within the next day.

Time to stake a block

Since we can create a unique hash every 16 seconds the number of tries equals tries*16 seconds. We are dealing with the geometric distribution in this case. We assume that the probability of finding a block on any one trial to be greater than zero. Now we can view each attempt to create a hash to be independent form each other and it is repeated until the first success. That gives us the average time to stake a block:

t = timeMask/pb

Again putting in all the variables gives us:

t = 16/((maxTarget/diff)*(nCoins*COIN/1250000)/2^256) = 16/(nCoins/diff*0.0000000186264514923095703125) = 16*diff/(nCoins*0.0000000186264514923095703125) = diff/nCoins*858993459.2

So if you have a balance of 4000 GRC and the difficulty is 2 you would expect to stake after t = 2/4000*858993459.2 = 429496.7296 seconds = 4.97 days .

Amount of coins staking

Last but not least we can estimate the amount of coins currently staking in the gridcoin network. We can just take the equation from the previous section. But now we solve the equation for nCoins instead of t:

nCoins = (16*2^256*1250000*diff)/(t*maxTarget*COIN)

Now if we set t=90 we get the amount of coins needed to stake every 90 seconds at the current difficulty. If we put in all the variables we get:

nCoins = diff* 9544371.769

If we have a difficulty of 2, there are about 19 million coins currently used to secure the network.

These calculations were not possible before V8 because of the magnitude being involved in the stake mechanism. There has been no way to reliably estimate the amount of coins used for staking. I find it quite alarming that we have such a low stake participation. With only 5-8% of the 394 million total coin supply staking there is a great risk of attacks. We should not only worry about the time it takes new users/users with a low balance to stake a block. But also think about the security of the blockchain. Without a secure blockchain all your efforts to gather Gridcoins become worthless.

Please note that some of these calculations have to be performed for each UTXO(unspent transaction output) separately to be correct.

If you find any errors please let me know and I will fix them.