Cardano-wallet: Order stake pools by non-myopic member rewards

Created on 3 Jun 2020  Â·  14Comments  Â·  Source: input-output-hk/cardano-wallet

Context

We want to implement this endpoint for (the cardano-node-) Shelley.
https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/listStakePools

To help users chose between pools, the endpoint, which was added during the ITN, used to provide:

  • apparent_performance
  • desirability
  • (and saturation)

According to the delegation design spec pools should be sorted by non-myopic member rewards.

The node's has a local state query for non-myopic member rewards which we can use.

Decision

We should:

  • Order stake pools by non-myopic member rewards
  • Add non-myopic member rewards to the API response

And then:

  • Remove the fields apparent_performance, desirability, saturation?

Acceptance Criteria

  • GET /stake-pools must be ordered by non-myopic member rewards
  • GET /stake-pools should contain non-myopic member rewards in the response

Development

QA

Most helpful comment

So cardano-node from https://github.com/input-output-hk/cardano-node/pull/1350 includes the fix

$ cardano-wallet-shelley stake-pool list --stake 1000000 | jq 'map(.metrics.non_myopic_member_rewards.quantity) | .[:5]'
Ok.
[
  144,
  131,
  129,
  128,
  128
]

$ cardano-wallet-shelley stake-pool list --stake 1000000000000 | jq 'map(.metrics.non_myopic_member_rewards.quantity) | .[:5]'
Ok.
[
  144460917,
  131335062,
  129802259,
  128592762,
  128223388
]

^ seems more promising

All 14 comments

Remove the fields apparent_performance, desirability, saturation?

@Anviking double-check this with Alex + Darko. I don't think this is desirable. So we probably need to push this upstream if these values aren't yet available from the local state query protocol. The saturation we can likely compute from knowing the total stake delegated to the pool. Others, it'd be preferable to get from the local state query (I don't have the formula in mind but can't we also compute the desirability from the non-myopic utilty?)

At present time this sorting can be "attacked" by fake pledge amount. Just tested my app on shelley-testnet and found this:

image

Its a non-myopic member rewards for 100K ada stake in the top-right corner and pledge of the pool 0c6fb7f6499477e3100bcc93624ab218abc58782fc79c2bcc27a91af below

So this is a vector for in-wallet ratings manipulations for now.
Is it possible to verify the pledge by somehow? Yes, I can just drop all pools with pledge value more than the total supply, but it is not the real solution of the problem.

@Fell-x27 There was a problem with the calculation of the non-myopic member rewards fixed by https://github.com/input-output-hk/cardano-ledger-specs/pull/1601. Before that change makes it to cardano-node, the ranking will be… well, I think pretty useless.

It previously mistakingly used the pool owners' stake as the stake of the pool member about to delegate.

Well, everything I need is building master branch, right?

No, the cardano-ledger-specs dependency inside cardano-node needs to be bumped, which they do regularly

I think let's keep this item in QA until the https://github.com/input-output-hk/cardano-ledger-specs/pull/1601 goes into cardano-node. @Anviking it is not in the node 1.14.2, correct?

I think let's keep this item in QA

Yeah, I think that's sane to do.

it is not in the node 1.14.2, correct?

No, it's not even on (cardano-node-)master yet. It was updated 6 days ago, but the fix was merged yesterday.

Thanks! Will watch this.

So cardano-node from https://github.com/input-output-hk/cardano-node/pull/1350 includes the fix

$ cardano-wallet-shelley stake-pool list --stake 1000000 | jq 'map(.metrics.non_myopic_member_rewards.quantity) | .[:5]'
Ok.
[
  144,
  131,
  129,
  128,
  128
]

$ cardano-wallet-shelley stake-pool list --stake 1000000000000 | jq 'map(.metrics.non_myopic_member_rewards.quantity) | .[:5]'
Ok.
[
  144460917,
  131335062,
  129802259,
  128592762,
  128223388
]

^ seems more promising

@piotr-iohk is this ok now?

@Anviking I don't see difference on current wallet master and cardano-node 1.4.2:

# cardano-wallet-shelley stake-pool list --stake 100000000 | jq 'map(.metrics.non_myopic_member_rewards.quantity) | .[:5]'
Ok.
[
  7050526840142,
  3283649681,
  517920152,
  481603771,
  269570962
]
# cardano-wallet-shelley stake-pool list --stake 1 | jq 'map(.metrics.non_myopic_member_rewards.quantity) | .[:5]'
Ok.
[
  7050526840142,
  3283649681,
  517920152,
  481603771,
  269570962
]

It should be working with https://github.com/input-output-hk/cardano-node/commit/a2161bac700fac55d2400b37f9935ed8ea527550 which is what is specified on the wallet readme

lgtm

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Anviking picture Anviking  Â·  8Comments

paweljakubas picture paweljakubas  Â·  6Comments

gufmar picture gufmar  Â·  9Comments

KtorZ picture KtorZ  Â·  11Comments

Mercurial picture Mercurial  Â·  5Comments