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

Stake distribution logic error(sdk 0.27.1) #3018

Closed
4 tasks
nodebreaker0-0 opened this issue Dec 6, 2018 · 14 comments
Closed
4 tasks

Stake distribution logic error(sdk 0.27.1) #3018

nodebreaker0-0 opened this issue Dec 6, 2018 · 14 comments

Comments

@nodebreaker0-0
Copy link

Summary of Bug

No rewards are being added to pool

Steps to Reproduce

Nothing is being added to CurrentPoolRewards, and CurrentCommissionRewards when the inflation rate has been set to 10000% in genesis.json for Game of Stakes. But when set to 100,000%, it works fine.

  1. [Change the inflation rate to 10000% in genesis.json]
  2. [Start the chain and check the reward pools (CurrentPoolRewards, CurrentCommissionRewards)]
  3. [If inflation in genesis.json is changed back to 100000%, and see if the rewards are being added to the pools correctly]

If no rewards are being distributed to the pools at 10000 inflation, we cannot continue on with Game of Stakes as no stakes are being added to players, and on mainnet it becomes impossible to distribute rewards to validators and their delegators, causing critical loss in what could have been potential income.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@nodebreaker0-0 nodebreaker0-0 changed the title No rewards are being added to pool(sdk 0.27.1) Stake distribution logic error(sdk 0.27.1) Dec 6, 2018
@cwgoes
Copy link
Contributor

cwgoes commented Dec 6, 2018

I can't replicate any discrete problem here. If the block rewards (added to the global pool) were zero, that would be a problem, but that doesn't seem to happen with 10,000% inflation and total supply of a million (see testcase here).

Have you withdrawn rewards for your validator? If you haven't yet, current pool rewards will be zero as it's calculated on-demand. If you are withdrawing rewards, make sure you don't do so too frequently or the amounts might be rounded down to zero.

If you can provide a testcase or set of detailed instructions to replicate this issue we can debug further.

@Hyung-bharvest
Copy link
Contributor

Hyung-bharvest commented Dec 6, 2018

same issue seen with my intranet(docker).
genesis is GoS current version and sdk 0.27.1.
4 nodes with power 10000 each.

we log all the variables about pool and delaccum. we see that all variables are blank.
so no reward evidence was not seen from withdrawal but from variable logger.
also when we withdraw it gives nothing.

but the same environtment with inflation 1000 gives us proper variables seen.

@rigelrozanski
Copy link
Contributor

please include the exact CLI commands used to determine the problem

@Hyung-bharvest
Copy link
Contributor

genesis.json used : https://raw.githubusercontent.com/dlguddus/cosmos-testnets/master/genesis.json

withdraw cmd

sudo gaiacli tx dist withdraw-rewards --from bharvest --is-validator --trust-node --chain-id gaia-9003kr

withdraw result

Committed at block 64 (tx hash: 299940FD84A0DF148DF5D9F29ED35CB2E9F2F34D1A1F6199911846885CBA2D98, response: {Code:0 Data:[] Log:Msg 0: Info: GasWanted:200000 GasUsed:4941 Tags:[{Key:[97 99 116 105 111 110] Value:[119 105 116 104 100 114 97 119 95 118 97 108 105 100 97 116 111 114 95 114 101 119 97 114 100 115 95 97 108 108] XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0} {Key:[115 111 117 114 99 101 45 118 97 108 105 100 97 116 111 114] Value:[99 111 115 109 111 115 118 97 108 111 112 101 114 49 99 118 115 54 102 50 110 114 100 119 113 97 57 101 116 55 48 118 112 108 53 116 109 53 54 117 120 52 122 57 53 109 97 51 100 104 54 56] XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0}] Codespace: XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0})

query account cmd

sudo gaiacli query account cosmos1cvs6f2nrdwqa9et70vpl5tm56ux4z95mc9ezk5 --trust-node

query account result

{"type":"auth/Account","value":{"address":"cosmos1cvs6f2nrdwqa9et70vpl5tm56ux4z95mc9ezk5","coins":[{"denom":"photinos","amount":"10000000000"}],"public_key":{"type":"tendermint/PubKeySecp256k1","value":"A6tiOPUI7kr4vuVVH/k7YHiLANdaFkYtO7O71piLGWQW"},"account_number":"171","sequence":"2"}}

@Hyung-bharvest
Copy link
Contributor

Hyung-bharvest commented Dec 7, 2018

If we try this with each node with 300,000 power(total 4 nodes), rewards coming in normally.

So, I think it is relevant to the total power amount and blockly inflation amount.
If total power amount or total blockly inflation amount is small enough, from somewhere in sdk, all rewards are neglected, then result in no reward chain.

Therefore, in GoS, we have total power of several millions STAKE, so reward will be normal I expect

@rigelrozanski
Copy link
Contributor

I think there is likely something else going on here than a problem in the mechanism based on the results of the testnets. Likely has to do with your setup. Are you sure cosmos1cvs6f2nrdwqa9et70vpl5tm56ux4z95mc9ezk5 is an active validator?... Also try updating the latest develop - we upgraded inflation mechanism - what version (hash) of the cosmos-sdk are you using?

@Hyung-bharvest
Copy link
Contributor

Hyung-bharvest commented Dec 7, 2018

the address is in GoS genesis. GoS submition address. and sdk version is 0.27.1-0-gdfd00a6. We are using the official GoS genesis with only different name gaia-9003kr. different options(inflation 1000 or power 300,000) are working fine but with inflation100 & power 10,000 for 4 nodes doesnt work properly.

beware that total power is 40,000 not millions.

total blockly reward = 40000 × 100 / 8766 / 60 / 60 × 5 = 0.63

about 0.15 for each 10,000 power validator. 9.6 for 64 height.

@wlsaud619
Copy link

image
(The photographs are additional test data)

..

Test conditions

  1. We proceeded with 10000STAKE stakes on 4 nodes.
  2. We did not delegate and withdraw-reward from any node.
  3. gaiad, gaiacli version: 0.27.1-0-gdfd00a66

Additional test content
Inflation is not paid in 300block when inflation is 157.78, but inflation is paid in 2block when inflation is 157.79.

When inflation is 157.78,
It is about 0.0005% (15,778 / 365/24/60/60) per second, and even when inflation is 157.79
It is about 0.0005% (15,779 / 365/24/60/60) per second.

157.79 and 157.78 have the same inflation rate per second, but inflation was not paid at 157.78.

This seems obviously a problem.

@Hyung-bharvest
Copy link
Contributor

excelent finding!

157.78×40000/8766/60/60×5=0.9999
157.79×40000/8766/60/60×5=1.0000

it is a strong evidence that sdk is doing a decimal truncation when total blockly inflation is less than 1.

@Hyung-bharvest
Copy link
Contributor

Hyung-bharvest commented Dec 8, 2018

// get the provisions for a block based on the annual provisions rate
func (m Minter) BlockProvision(params Params) sdk.Coin {
provisionAmt := m.AnnualProvisions.QuoInt(sdk.NewInt(int64(params.BlocksPerYear)))
return sdk.NewCoin(params.MintDenom, provisionAmt.TruncateInt())
}

from minter.go
do we need TruncateInt() there?

@cwgoes
Copy link
Contributor

cwgoes commented Dec 10, 2018

Yes, we do. At present this logic will not work if the amount of inflation per blocks is less than 1 unit. That is unlikely to happen in a real network, since the unit precision will be 10 or 18 orders of magnitude.

@Hyung-bharvest
Copy link
Contributor

oh ok. now i see why truncate. then this is normal to see.

@cwgoes
Copy link
Contributor

cwgoes commented Dec 12, 2018

I think the remaining action item here is perhaps to warn when this truncation would mean that inflation rewards are zero.

@cwgoes
Copy link
Contributor

cwgoes commented Jan 16, 2019

Splitting to #3310.

This is somewhat less of a concern with F1, which returns unpaid rewards where possible.

@cwgoes cwgoes closed this as completed Jan 16, 2019
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

6 participants