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

DelegatorShares vs Tokens in staking/Validator struct #3771

Closed
4 tasks
ewagmig opened this issue Mar 1, 2019 · 7 comments
Closed
4 tasks

DelegatorShares vs Tokens in staking/Validator struct #3771

ewagmig opened this issue Mar 1, 2019 · 7 comments

Comments

@ewagmig
Copy link

ewagmig commented Mar 1, 2019

Summary of Bug

Right now there are 2 fields defined for the staking tokens in the validator struct, DelegatorShares and Tokens. But from the comments of the sepcification ,
I think the Tokens sums all the staking including self-delegation as well as stakes delegated by other delegators.
But the DelegatorShares should represent the delegation shares from all the delegators exclude self delegation.

Im not sure if Im right on this part, by if they are the same value except of Decimal and Integer. I think this would make no sense.

Steps to Reproduce


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@alexanderbez
Copy link
Contributor

alexanderbez commented Mar 1, 2019

@MattWangming indeed these terms, tokens and shares, can cause confusion in the same context -- they did for me.

I think the Tokens sums all the staking including self-delegation as well as stakes delegated by other delegators.

Correct.

But the DelegatorShares should represent the delegation shares from all the delegators exclude self delegation.

I don't think this is true. If we look at Keeper#Delegate, we notice that AddValidatorTokensAndShares is always called, regardless if it is a self-delegation or not.

So to understand these terms, I quote @cwgoes here:

Validators, at any given time, have tokens. When a delegator delegates, they transfer tokens to the validator and get back shares in return (stored in the delegation object). The validator's tokens might decrease, for example if they get slashed. When a delegator undelegates, they convert whatever shares they had delegated to tokens based on the current amount of tokens a validator has. Their initial amount of shares is constant, but the validators' tokens might have been changed (if they were slashed), so the delegator could get fewer tokens. The reason for shares is to avoid iteration over delegations for when a validator gets slashed for example.

Does this help clear things up? Or do you feel there is a bug somewhere or something could be improved upon?

@jackzampolin
Copy link
Member

Related: #3516

@ewagmig
Copy link
Author

ewagmig commented Mar 2, 2019

@alexanderbez @jackzampolin
Thanks for your clarification. Its clear on these 2 fields based on the current design mechanism. What I further want to draw your core members attention is on the validator self delegation part. Will there be a new field design on it?
From a users perspective, it could be better that the validators self delegation part could be listed with all the other information of the validator.

@alexanderbez
Copy link
Contributor

@MattWangming it seems you want the self-delegation to be a separate field/structure that's part of the validator. What is the main motivation here? It's not really treated different than any other delegation.

@ewagmig
Copy link
Author

ewagmig commented Mar 4, 2019

@alexanderbez Yes, that is what we desired. We are focusing one digital wallet DAPP based on cosmos SDK. From the perspect of delegators, they want to select the validators to staking based on some standards, e.g. the self delegation shares and delegation from others. So it coule be perfect if there is a seperate field on this information.

@cwgoes
Copy link
Contributor

cwgoes commented Mar 4, 2019

I don't think that would be conducive to code clarity, but it's easy to fetch the self-delegation - just find the delegation from the validator's address to itself.

@ewagmig
Copy link
Author

ewagmig commented Mar 4, 2019

@alexanderbez @cwgoes OK, thanks for your clarification anyway.

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