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.
@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?
@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.
@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.
@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.
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.
@alexanderbez @cwgoes OK, thanks for your clarification anyway.
Most helpful comment
@alexanderbez @cwgoes OK, thanks for your clarification anyway.