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

Delegation is limited to int #2319

Closed
4 tasks
faboweb opened this issue Sep 12, 2018 · 7 comments
Closed
4 tasks

Delegation is limited to int #2319

faboweb opened this issue Sep 12, 2018 · 7 comments

Comments

@faboweb
Copy link
Contributor

faboweb commented Sep 12, 2018

Summary of Bug

I can have only a fraction of shares in a validator. But I can not stake fractions of atoms.

If I POST /stake/delegators/cosmosaccaddr1xlkl78w5cs5rd0tqxjla2pqqd82v57yj70r0d3/delegations the body:

{"delegations":[{"delegator_addr":"cosmosaccaddr1xlkl78w5cs5rd0tqxjla2pqqd82v57yj70r0d3","validator_addr":"cosmosaccaddr126ayk3hse5zvk9gxfmpsjr9565ef72pv9g20yx","delegation":{"denom":"steak","amount":"0.9999999998"}}],"begin_unbondings":[],"sequence":"6","name":"TEST3","password":"1234567890","account_number":"567","chain_id":"gaia-8001","gas":"50000000"}

The LCD returns the error:

math/big: cannot unmarshal "0.9999999998" into a *big.Int

Steps to Reproduce

GET /stake/delegators/cosmosaccaddr1xlkl78w5cs5rd0tqxjla2pqqd82v57yj70r0d3
Try to undelegate the shows shares: POST /stake/delegators/cosmosaccaddr1xlkl78w5cs5rd0tqxjla2pqqd82v57yj70r0d3/delegations

{"delegations":[],"begin_unbondings":[{"delegator_addr":"cosmosaccaddr1xlkl78w5cs5rd0tqxjla2pqqd82v57yj70r0d3","validator_addr":"cosmosaccaddr126ayk3hse5zvk9gxfmpsjr9565ef72pv9g20yx","shares":"0.0000000014"}],"sequence":"3","name":"TEST3","password":"1234567890","account_number":"567","chain_id":"gaia-8001","gas":"50000000"}

Error:

Couldn't decode shares amount. Error: Error{1:6,--= Error =--Data: common.FmtError{format:"string has too many decimals", args:[]interface {}(nil)}Msg Traces:--= /Error =--}

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@faboweb faboweb changed the title Delegation is limited to BigIng Delegation is limited to int Sep 12, 2018
@rigelrozanski
Copy link
Contributor

It is intended that you are not permitted to stake fractions of any token, all tokens used are intended to represent the smallest denomination of that token (aka the units we should actually be using are the equivalent of "a satoshi")... So this is in fact not a bug but the intended functionality.

There have been some discussions of allowing for multiple units of the same token to be submitted through the API - however this is a post-launch concern.

@rigelrozanski
Copy link
Contributor

rigelrozanski commented Sep 13, 2018

@faboweb

What happens if my 0.67 shares I unbond are worth 0.85 atoms?
Do I have then 0.85 atoms on my account

That scenario should never come up as validator’s (soon) will be holding whole atoms not fractions of atoms. Even slashing events will only take place on full atoms… I guess there is the situation in which after a slashing event your shares become worth a fraction of an atoms - those atoms should probably just be slashed I guess or just left in the pool for the other delegators maybe… I’ll open an issue for this, interesting edge case. #2327

BUT either way - this edge case is independent to your issue as 0.67 shares I unbond are worth 0.85 atoms is equivalent to saying 0.67 decimal shares I unbond are worth 85000000 sub-atoms which is actually how the computations will actually be performed

@faboweb
Copy link
Contributor Author

faboweb commented Sep 13, 2018

related #2327

thx

are worth 85000000 sub-atoms

Do we have sub-atoms already? Undelegation still returns atoms, am I mistaken?

@rigelrozanski
Copy link
Contributor

it's just the name of the denom - but yet we should probably rename the denom in gaia ASAP just to get the testnets looking more like the hub. Everything should be using sub-atoms within the UI we should obviously still just display things as decimal's with atoms however (but the CLI and LCD will use subatoms)

@faboweb
Copy link
Contributor Author

faboweb commented Sep 13, 2018

How do you exchange sub-atoms for atoms? Or are there just no atoms anymore?

@alexanderbez
Copy link
Contributor

iirc, atoms are just another way to represent a quantity of whole atoms. e.g. 1000000000 wei == 1 ETH.

@rigelrozanski
Copy link
Contributor

@alexanderbez is correct - An atom is just a concept representing 100000000 sub-atoms. Sub-atom is the only unit used in the SDK. To determine the amount of "atoms" you have you just perform a calculation in the UI or on a Napkin in the Joe's Dinner

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

No branches or pull requests

3 participants