Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove newbie boost #332

Closed
denravonska opened this issue May 27, 2017 · 17 comments
Closed

Remove newbie boost #332

denravonska opened this issue May 27, 2017 · 17 comments

Comments

@denravonska
Copy link
Member

We briefly talked about removing the boost which causes new wallets to stake blocks much faster. While the idea is good it often causes new players to think that everything is going smoothly (which in a way it is) but then get confused. Instead we should rely on the pools and #331.

@iFoggz
Copy link
Member

iFoggz commented May 27, 2017

I think it should be recommend to use pool until they have around 5-10K GRC if they want to stake regularly. People grow impatient waiting months for a stake at a risk of not being able to get it in time. Also this recommended number will change in the future as network grows.

@skcin
Copy link
Contributor

skcin commented May 30, 2017

I agree @denravonska. This is somehow related to the stake weight debate. I htink currently the a magnitude of 1 has the same effect on the probability to stake as 1 GRC. That means that the whole PoR process with a total magnitude of 115000 has the same effect as a balance of 115000 GRC.
So no wonder that a newbie with only a few coins and no huge amount of compute power has to wait very long to stake.
But even if we can improve on that, if it gets more competetive pools are the only way to start without some investment.

@tomasbrod
Copy link
Member

In my opinion any staking weight boost should be removed from CoinStake PoS mechanism. The stakeweight boost is multiplied by the amount of UTXOs you have which is wrong. And I don't see other way to fix it.
However we should work towards adding a staking new mechanism based on research-age. To give crunchers with low balance some chance. Something like staking with beacon keys weighted by research-age instead of coins. And only allow research-age block after 10 coin-stake blocks.

@skcin
Copy link
Contributor

skcin commented May 30, 2017

@tomasbrod I don't understand how the stake weight is multiplied by the number of UTXOs (unspent transaction outputs). As I understand it the wallet loops through the UTXOs and tries to stake with the amount in that UTXO plus the RSA_WEIGHT. If it fails, it goes to the next UTXO and tries to stake with that.
And I think that is what should happen, or am I wrong?

@tomasbrod
Copy link
Member

tomasbrod commented May 30, 2017

@skcin It loops for all UTXOs. For each UTXO RSA_WEIGHT bonus is added. FOR EACH. Your weight is sum of all UTXO weights. SUM(something)+constant =/= SUM(something+constant)

@denravonska
Copy link
Member Author

Where does this happen?

@tomasbrod
Copy link
Member

Somewhere deep in the wallet.cpp or kernel.cpp (SignBlock maybe).
In my pull request for improved staking it is CreateCoinStake and CalculateStakeWeightV3. My code is compatible as it creates blocks that are accepted.

@skcin
Copy link
Contributor

skcin commented May 31, 2017

@tomasbrod now I understand what you mean. But I am not convinced you can actually just sum up the weights wich would result in the multiplication by the number of UTXOs. You never stake with a sum like that. Let me explain.

As I see it the RSA_WEIGHT (int64_t RSA_WEIGHT = GetRSAWeightByBlock(boincblock);) is only added in CheckStakeKernelHashV3. As CheckStakeKernelHashV3 gets the number of coins used for staking from CreateCoinStake it is added just once to the amount of coins currently staking.

The RSA_WEIGHT in CreateCoinStake is different since it is calculated by int64_t RSA_WEIGHT = GetRSAWeightByCPID(GlobalCPUMiningCPID.cpid);.

So at any point in time only one UTXO (or a set of UTXOs, not sure right now, but I think it is not relevant in this case, since the RSA weight is only added at the end) is used for staking.

Lets assume the wallet tries to stake a block once every second. Then the probability to stake a block right now is a function PB(aUTXO,RSA_WEIGHT) with aUTXO being the amount of coins used for staking and RSA_WEIGHT your weight due to the magnitude you earned. The actual function is not important right now.

The probability to stake trying a certain amount of times t (in this case it is the same as the probability to stake in a certain amount of seconds) is:
p = 1-(1-PB)^t

Now lets assume you have all your coins in one UTXO and the probability to stake in this second is PB(aUTXO,RSA_WEIGHT)=0.00001. Then the Probability to stake in the next 7 days (604800 seconds) is:
p = 1-(1-PB)^t = 1-(1-0.00001)^604800=0.9976

But if you have your coins in two UTXOs your probability to stake in one second is PB(aUTXO_1,RSA_WEIGHT) and in another second it is PB(aUTXO_2,RSA_WEIGHT). Now lets further assume that the RSA_WEIGHT increased the probability by a constant of 0.000002 and you split the coins equaly over the two UTXOs. Then you would get:
PB(aUTXO_1,RSA_WEIGHT) = PB(aUTXO_2,RSA_WEIGHT) = (0.000008/2)+0.000002=0.000006
But now these two UTXOs take turns in trying to stake a block. So you get for the Probability to stake in the next 7 days (604800 seconds):
p = 1-(1-PB)^t = 1-(1-0.000006)^604800=0.9735

So splitting your coins in multiple UTXOs will not increase your probability to stake the next block, quite the oposite.

Sorry for the lengthy post. But I think it is an important topic, so if I am wrong please let me know.

@tomasbrod
Copy link
Member

I appreciate your long message, we need this kind of detailed research, but your assumption is invalid.

So at any point in time only one UTXO is used for staking.

StakeMiner runs with period of 0.5s, but that is not important. A mask is applied to staking time-stamp (4 least significant bits cleared) so all attempts to stake specific utxo in given 16 seconds have the same outcome. All non-reserve mature UTXOs are used for staking in one miner run. It is clear in function CWallet::CreateCoinStake here. And the weight bonus is added every time.

@iFoggz
Copy link
Member

iFoggz commented May 31, 2017

so if splitting coins into multiple UTXOs does not help you stake more? Ive had quite the opposite of that. had all in one and took 15 days to stake. now got them in 12 grc addresses and i stake anywhere from 1-6 times a day depending on network weight. or are we talking about something different? i would like to know as i been trying to figure this mystery out for awhile. I think I stake more often with multiple because I always have most of my coin weight on the network. usually 20K non stop.

@skcin
Copy link
Contributor

skcin commented May 31, 2017

All non-reserve mature UTXOs are used for staking in one miner run. It is clear in function CWallet::CreateCoinStake here. And the weight bonus is added every time.

Yes, but one after another. There is no Weight = (UTXO_1 + RSA_WEIGHT)+(UTXO_2 + RSA_WEIGHT)+...+(UTXO_n + RSA_WEIGHT) happening. If it is, can you point out where?

@skcin
Copy link
Contributor

skcin commented May 31, 2017

@Foggyx420 there are other reasons for splitting your coins. I was kind of looking at how fast can you stake a block. But once you staked, your coins need to mature again and are not available for staking or spending for a certain amount of time. So if you want to stake regularly or want to stake as many blocks as possible in a certain amount of time it might be better to split your coins.

I cannot tell you why it took so long when you had all the coins in one address.
But as you said it also depends on difficulty and your balance.

@tomasbrod
Copy link
Member

tomasbrod commented May 31, 2017

Created a simple demo program for you @skcin .
boost is RSA_WEIGHT there (mag+newbie)

@iFoggz
Copy link
Member

iFoggz commented May 31, 2017

@skcin yes this been a experiment since end of march. and my results have shown more separate coin blocks or utxo as u call them (thanks i now know official name :)) helps me stake more often and probably because i keep weight on network and kinda limit what coins needs to mature again after a given stake.

and yea i thought for sure one big sexy block would do but as soon as i split it up within a day or two i started staking regularly. but like i said I figure it was because I always have 20K roughly in utxo's staking.

This been a long process. now this probably answers my latest question as well. How does it decide which grc address will do the stake and which coins lol! some days it seems like a pattern other days it doesn't.

Again thanks guys for helping me solve my biggest mystery. :)

@skcin
Copy link
Contributor

skcin commented May 31, 2017

@tomasbrod nice example. I think I misunderstood what you meant by multiplying with the number of UTXOs.

So in your example program you are estimating the probability to stake a block under different circumstances. If run:
stakesim(2600,8,0)
stakesim(1000,8,200)
I get the same results, for balance and boost and for balance+(8*boost).

I assumed that the wallet tries to create a block equaly often, no matter how many UTXOs you have. In your example program you assume that the number of attempts depends on the number of UTXOs. Hence the factor equaling the number of UTXOs.

In reality this might be different. It could be less but it also could be more since you didn't take the second loop into account. The time and the PoR nonce is changed in that loop. Basically introducing a PoW element.

So this could explain @Foggyx420 experience of staking more often with multiple adresses.

I think the way the RSA_WEIGHT is implemented is not the issue, it might be how often the wallet is allowed to create a new hash.

@tomasbrod
Copy link
Member

@skcin "nSearchInterval" is always set to zero here from since when protocol V2 is active.

The time and the PoR nonce is changed in that loop. Basically introducing a PoW element.

This. You just discovered a fatal Flaw in the stake kernel. Gridcoin is unofficially now a Proof of Work consensus coin.

//12-6-2015 - Add PoW nonce to POR - Halford

Well done Rob Halford. Here a freely choosable value (nonce) is included into the stake kernel hash. One can just iterate over until a suitable hash is found. If one doesn't understand crypto, one should not change proven algorithms. It may have been done well intentionally considering the amount of obfuscation done with the nonce. Including RSA_WEIGHT into the kernel is a bad idea, can be used as a nonce too.

@tomasbrod
Copy link
Member

Newbie stake weight boost removed in #364. Newbie block reward remains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants