Cosmos-sdk: Add support for query parameters on staking queriers

Created on 31 Aug 2018  Â·  11Comments  Â·  Source: cosmos/cosmos-sdk

Summary

Add support for query parameters on staking queriers for Gaia-lite GET requests

Problem Definition

No current way to query staking parameters from validators or delegation txs.

Rephrasing @sunnya97 https://github.com/cosmos/cosmos-sdk/pull/2139#discussion_r213881407:

It'd be nice for staking queriers to support query parameters so you can query specifically bonded, jailed, etc

Same applies for the state of delegations, unbonds and redelegations on a specific block height, which is currently supported on CLI

Proposal

Delegation txs:

For the following endpoints:

  • delegator summary (delegators/{delegatorAddr})
  • .../<delegations>/...
  • .../unbonding-delegations/...
  • .../redelegations/...

Queries supported:

  • ?height=<block_height>: status at a specific block height.

Examples:

GET /stake/delegators/{delegatorAddr}?height=<block_height>
GET /stake/delegators/{delegatorAddr}/delegations/{validatorAddr}?height=<block_height>
GET /stake/delegators/{delegatorAddr}/unbonding-delegations/{validatorAddr}?height=<block_height>

Validators query

For the following endpoints:

  • .../validators:

Queries supported:

  • ?jailed=<true/false>
  • ?status=<bonded/unbonding/unbonded>
  • ?height=<block_height>: status at a specific block height. Useful to track voting power progress
  • ?moniker=<name>
  • ?website=<website>

Examples:

GET /stake/delegators/{delegatorAddr}/validators?jailed=true&status=unbonded
GET /stake/validators?height=32213

For Admin Use

  • [ ] Not duplicate issue
  • [ ] Appropriate labels applied
  • [ ] Appropriate contributors tagged
  • [ ] Contributor assigned/self-assigned
Legacy API REST UX good first issue proposal-accepted staking

All 11 comments

Concept ACK.

Some of these are efficient and others are not - retrieving bonded validators, for example, is easy - but we aren't going to add an index from monikers or websites to validator addresses, so those queries would require O(n) iteration.

What is the benefit of querying for jailed or status?
I also don't think splitting the delegation summary provides a huge benefit. An application will probably always want to query all of them.

@fedekunze Can this be closed?

@cwgoes I don't think so. We can label it pre1.0 if you want, not high priority but definitely a nice to have

cc @alessio

Is this still something we want @fedekunze?

I think so, yes. Would it be possible to set the context to a specific height i.e ctx = ctx.WithBlockHeight(height) and then do the query as usual ? cc @alexanderbez @rigelrozanski

I've already implemented supporting height queries for querier-based queries (wow) here. Does this accomplish your needs?

cool ! do we need to add REST query params or it only supports CLI for the moment ?

Only CLI atm because it was super trivial. REST will involve more work. Essentially each REST handler will have to parse for a height query param and update the context. Still trivial and easy to implement, just more places in the code to this.

cc @aayushijain23

Closing as implemented.

Was this page helpful?
0 / 5 - 0 ratings