moonbeam icon indicating copy to clipboard operation
moonbeam copied to clipboard

Nominators amount issue

Open avtishin opened this issue 3 years ago • 4 comments

Hello,

I extracted staking information data from polkadot.js using the following code:

const hash = await api.rpc.chain.getBlockHash(1939800);

console.log(JSON.stringify(hash))

const stake = await api.query.parachainStaking.atStake.at(hash, 1080, '0x73Fd06aBCa1669725CE4ecA539bf55393B228f23')
console.log(JSON.stringify(stake.toHuman()))

I expected to see the list of nominations with the amount of nominations. However, for some nominations, there is 0 in the nomination amount. Could you clarify this issue? The problem is that 0 nomination amount is not correct because the sum of all nomination amounts + collator self-bond is not equal to the total amount of stake in this case.

For example: Screenshot 2022-09-26 at 09 56 39

avtishin avatar Sep 26 '22 05:09 avtishin

@4meta5 Can you get a look at this issue please ?

crystalin avatar Sep 26 '22 12:09 crystalin

The 0 nominations in AtStake were introduced in https://github.com/PureStake/moonbeam/pull/1408 to NOT count the pending bond_less and revoke delegations. So the AtStake doesn't always match CandidateState because the CandidateState counts all delegations while AtStake only snapshots the counted delegations. You can expect AtStake to replace every delegation for which there is a revoke request with a 0 delegation.

To be clear, AtStake is a snapshot taken at the start of the round for payout calculation later. If you would like the list of all delegations for a candidate, use CandidateState and if you'd like the list of all delegations by a delegator use DelegatorState.

4meta5 avatar Sep 27 '22 15:09 4meta5

@4meta5 Thank you for your answer, it clarifies my questions. However, I cannot find CandidateState in the pallet. Can you explain how to use CandidateState? Thanks!

avtishin avatar Oct 02 '22 06:10 avtishin

@avtishin The map is CandidateInfo, this is what I meant to say instead of CandidateState: https://github.com/PureStake/moonbeam/blob/master/pallets/parachain-staking/src/lib.rs#L488-L492

There are two maps below it which contains the TopDelegations and BottomDelegations per candidate.

As mentioned before, use DelegatorState to get all delegations per delegator

4meta5 avatar Oct 02 '22 20:10 4meta5

Closing due to inactivity. Feel free to reopen or keep asking questions if you need help :)

4meta5 avatar Oct 27 '22 20:10 4meta5