A quick rule of thumb formula for calculating expected time to stake

in #gridcoin5 years ago (edited)

I have been involved in an extensive discussion on the Gridcoin Slack recently involving difficulty, network weight, and stake weight.

I developed a quite accurate rule of thumb formula for estimated time to stake that is easy to remember...

(Expected Time to Stake in days) = (10000/(Stakable Balance in GRC)) * Difficulty

So a balance of 10000 that is available for staking (meets the 16 hour cooldown requirement) at a difficulty of 1.0000 will result in an expected time to stake of approximately 1.0 day.

Let's apply this formula to minimum balance questions that we get all of the time.

Most people want to see a stake every week to feel comfortable everything is going right... solving the rule of thumb and using a difficulty of 1.0...

7 days = (10000/balance)*1.0 means balance = ~1400.

If the difficulty was 2.0, you would need twice that much.

Let's cover the case of low balance holders and the research reward cutoff problem. Research rewards expire at 180 days age. So you must stake within 180 days to avoid losing research rewards. Let's apply the formula to that...

180 = (10000/balance)*1.0 which means balance = ~56. In reality, because staking is random, you should put in a factor of about two to be safe... (Thanks @barton26!) So being below 100 GRC in balance is really risking losing research credit.

A relatively high balance holder of, say 100000 GRC would see this at a difficulty of 1.0...

Expected time to stake = (10000/100000) * 1.0 = 1/10 of a day, or 10 stakes a day. To actually achieve this though would require the wallet to have that balance split among ~10 or more UTXOs, because each UTXO staked is subject to a 16 hour cooldown period.

See @hotbit's excellent article on UTXOs. https://steemit.com/gridcoin/@hotbit/cbr-the-way-to-split-coins-draft. The splitting of balances into multiple UTXO's will be more important when we move to CBR.

For those of you wanting to understand where this formula came from, you can take a look at the small ddiff.cpp program I posted on the Gridcoin Slack which describes the relationship between nBits, Target, Difficulty, and staking probability and/or time to stake.

The actual value of the constant in the formula, instead of 10000, is the following...

(MaxHash/UnitDifficultyTarget) * (16/(80 * 3600 * 24)). The 16 comes from the 16 seconds per stake quantum imposed by the stake time mask. The 80 comes from the conversion of stakable GRC to CoinWeight. CoinWeight = 80 * Stakable GRC for V8 protocol. The 3600 and 24 convert secs to days in the formula.

MaxHash is 256^32-1, and the UnitDifficultyTarget is the target value for nBits of 1d00ffff. This is the same as (256^2-1) * 256^26 where the ^ is exponentiation.

Putting it all together we have

(Expected Time to Stake in days) = (1/Stakeable Balance in GRC) * Difficulty * ((256^32-1)/((256^2-1) * 256^26)) * (16/(80 * 3600 * 24))

So... the 10000 is actually 9942.20563194.

The more precise formula is therefore

(Expected Time to Stake in days) = (9942.20563194 / Stakeable Balance in GRC) * Difficulty

Please see the reddit cross-post for interesting commentary...



This post was upvoted by Steemgridcoin with the aim of promoting discussions surrounding Gridcoin and science.

This service is free. You can learn more on how to help here.

Have a nice day. :)

Thanks for this rule of thumb.

I must say, that for me it does not seem to fit.
My experience from my last several stakes, has been that it takes 2-4 times as much time as this formula says it should.

And that's with diff in general below 1, and with a staking wallet on 24/7.

I know there's a degree of randomness to staking, so I could have been unlucky. I probably was :)

But still its nice to see a simple straight forward formula, and I hope that it proves to be more precise for me in the future :)

Do you have a relatively large or small balance? If you have a large balance you will need to ensure you have it split up among several UTXOs to ensure you don’t get caught by the 16 hour cool down. The whole amount in the UTXO selected must be staked. That UTXO is not available for staking again for 16 hours.

I think in the grand scheme of things my balance should be considered small.

According to your formula i should stake ~ once every 7 days, but my last stake was 16 days ago, and before that 5 weeks went by between stakes.

Its probably just the luck of the draw.

A better explanation of UTXO's would be nice. My balance is split in about 100 small amounts from 1.2 to 60 GRC, adding up to my grand total. Would it be better for me to add them together into a few bigger amounts?

One of the redditors claims he started to stake with his small balance after consolidating the wallet, what you do just by sending whole balance to yourself.

Also, expected time to stake =/= certainty to stake within that time

OK, I think I'll try to consolidate my wallet into larger chunks of e.g. 500 GRC, and see if it makes any difference.

And I completely understand that expected time to stake is not equal to actual time to stake. There is a good deal of randomness to the staking process, nothing is guaranteed.

At difficulty 1 a 500 GRC UTXO has each a chance to stake at least once within 34 days of only ~82%, I would consider bigger UTXOs. 2000 gives you a 82% chance to stake at least once within 8.5 days, while expected time is ~5 days.

There should be very little difference whether you have 4 x 500 or 1 x 2000, (4x500 should allow for slightly more frequent stakes due to 16h cooldown time) but not everything is understood yet. While we have done several calculations, as far as I know nobody tested actual wallet behaviour.

My capacity of making bigger UTXO's is somewhat limited by the amount of GRC that I own :)

The real question is, is it better to have one 600 UTXO or 10 x 60 UTXO's?

I suspect the 1 x 600GRC UTXO will stake more often than the 10 X 60GRC UTXO's, but statistically this shouldn't be true?

I know you end up getting your interest and your DPOR's anyway (as long as you stake at least once every 6 months), but I want to have some degree of regularity to my staking, if at all possible.

The miner loops through all eligible UTXOs essentially every 16 sec (it is actually every 8, but there is a quantum of 16 sec applied to the transaction times, so it is effectively every 16) and tests for whether the candidate hash is less than the target * coinweight.

This is a series of Bernoulli trails with probability p for each trial where p = target * coinweight / maxhash.

If you have a small balance, such that you are going to stake only once every few days, it makes little sense to have more than a few UTXO’s for staking, because the expected TTS is beyond the 16 hour staking cooldown.

What happens if you have one UTXO originally and then take your coinweight (i.e. balance * 80) and chop it up into 10 UTXOs? Then for each miner loop you are going to run up to 10x as many bernoulli trails with 1/10 of the probability for each one compared to the original. And you have to remember, the probability for each one of these is pretty small...

For an expected TTS of 1 day (10000 GRC), that is 24*3600/16 quanta, or 5400 trips through the miner. So with one UTXO, the “coin toss”will have been thrown 5400 times, and with 10 the “coin toss” will have been done up to 54000 times over that day when the success (stake) happens.

Note that the probability of success after k trials of a coin p is geometricallly distributed.

Let’s put it together. For Bernoulli trials, the expected value of the number of throws is 1/p.

So for a one day expected TTS for one UTXO, this would be 24*3600/16 throws=5400. So p=1/5400. If you split your balance into 10 UTXO’s evenly sized, then p for each UTXO goes down by a factor of 10. So each p is now 1/54000. Now asking the question of what the expected number of throws is for that p? It is 54000! What? ten times as long? No. Remember that the miner every 16 seconds loops through ALL UTXOs very quickly and then goes back to sleep, so 54000 trails are done as 5400 groups of 10 spaced at 16 sec intervals. This gets us back to 1 day.

The bottom line is that from an EXPECTATION perspective, chopping up UTXO’s into finer ones results in the same expected time to stake, IGNORING the 16 hour cooldown effect.

To be 100% certain requires an infinite amount of time. The expected value is the mean of a distribution, after all..

Coin Marketplace

STEEM 0.22
TRX 0.06
JST 0.027
BTC 19212.44
ETH 1298.06
USDT 1.00
SBD 2.43