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

gRPC query returns non-decimaled value for DecCoin objects #13128

Closed
minxylynx opened this issue Sep 1, 2022 · 8 comments
Closed

gRPC query returns non-decimaled value for DecCoin objects #13128

minxylynx opened this issue Sep 1, 2022 · 8 comments

Comments

@minxylynx
Copy link

Summary of Bug

When querying via CLI, any response that returns a DecCoin value has the decimal point in the proper place. However, when querying via grpcurl for the same value, the decimal point goes missing. This also occurs when using the gRPC queries via code.

This makes it difficult to be sure you have the correct value, when you have to make an assumption of how many decimal places should be there.

Version

v0.45.4

Steps to Reproduce

Example via CLI:

~/go/bin/provenanced-1.11.1 --node=https://rpc.provenance.io:443 q distribution rewards pb1pr037jp6tyrlfvjxz3n8chd8g28m0xu5erswhm pbvaloper1d7yum2cxwkhmmuxa096prlv5gawjxw0gc2sykq

rewards:
- amount: "16925427.725182038000000000"
  denom: nhash

Example via grpcurl

grpcurl  -d '{"delegator_address": "pb1pr037jp6tyrlfvjxz3n8chd8g28m0xu5erswhm","validator_address":"pbvaloper1d7yum2cxwkhmmuxa096prlv5gawjxw0gc2sykq"}'  grpc.provenance.io:443 cosmos.distribution.v1beta1.Query/DelegationRewards

{
  "rewards": [
    {
      "denom": "nhash",
      "amount": "16925437387891251000000000"
    }
  ]
}
@alexanderbez
Copy link
Contributor

Very odd, they both get string-ified, so I'm not sure how this could happen. @facundomedica or @julienrbrt do you think you could confirm this?

I mean querying against the Hub should be able to check really quickly

@atheeshp
Copy link
Contributor

atheeshp commented Sep 5, 2022

Yes, I can confirm this is behaving as reported by @minxylynx, both rest & CLI are working as expected, but grpcurl isn't.
Just checked with the local testnet
CLI & rest :

./simd q distribution rewards cosmos1nr0dvlwugtgm48nyszcuspcwctd80knphueawh cosmosvaloper1nr0dvlwugtgm48nyszcuspcwctd80knpjgdgzy --home test 
rewards:
- amount: "285117.966000000000000000"
  denom: stake

grpcurl :

grpcurl -plaintext  -d '{"delegator_address": "cosmos1nr0dvlwugtgm48nyszcuspcwctd80knphueawh","validator_address":"cosmosvaloper1nr0dvlwugtgm48nyszcuspcwctd80knpjgdgzy"}' localhost:9090  cosmos.distribution.v1beta1.Query/DelegationRewards
{
  "rewards": [
    {
      "denom": "stake",
      "amount": "285117966000000000000000"
    }
  ]
}

@alexanderbez
Copy link
Contributor

Interesting. How can this happen? What does direct gRPC calls do to make this happen? Is it some post-processing of the response?

@AmauryM or @aaronc do you have any ideas?

@UmeeAndrey
Copy link

UmeeAndrey commented Feb 6, 2023

@facundomedica
Has there been any progress regarding this ?
I am experiencing the same issue with the gRPC client.

QueryDelegationRewardsResponse Rewards is of type []*v1beta1.DecCoin. This seems like an outdated type and is not consistent with Cosmos DecCoin

@alexanderbez
Copy link
Contributor

Is this this the only query like that?

@UmeeAndrey
Copy link

alexanderbez

Is this this the only query like that?

No ValidatorOutstandingRewards , ValidatorAccumulatedCommission, DelegationRewards , DelegationTotalRewards and CommunityPool queries response types all return *v1beta1.DecCoin. The coin.pulsar.go file used by the client uses a string type rather than an sdk.Dec type.

@aaronc
Copy link
Member

aaronc commented Feb 9, 2023

Replacing sdk.Dec with a better solution is something I've been hoping we can do for years. #10863 I believe describes what is actually causing this

@tac0turtle
Copy link
Member

closing in favour of #10863

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