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

Add a command to Gaia to retrieve all consumer chain keys for a specific consumer chain #2555

Closed
5 tasks
mmulji-ic opened this issue May 30, 2023 · 5 comments · Fixed by #2885
Closed
5 tasks
Assignees
Labels
more-info-needed Further information is requested S: ImprovingThings Improving things: Customer requests, performance improvements, reliability and usability scope: CLI Issues and features pertaining to Gaia's CLI client. type: feature-request New feature or request improvement

Comments

@mmulji-ic
Copy link
Contributor

Summary

Add a command for getting all consumer keys for a consumer chain.

Problem Definition

I want to be able to add a consumer chain support for my monitoring bot, and I’ll need to query for consumer keys on all validators, and it’s more correct to query all of it at once with one query instead of querying it for each validator separately

Proposal


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
  • Is a spike necessary to map out how the issue should be approached?
@mmulji-ic mmulji-ic added type: feature-request New feature or request improvement more-info-needed Further information is requested scope: CLI Issues and features pertaining to Gaia's CLI client. status: waiting-triage This issue/PR has not yet been triaged by the team. labels May 30, 2023
@freak12techno
Copy link
Contributor

freak12techno commented May 30, 2023

As a suggester of the feature in the first place, here's my usecase.

I am writing a tool to track validators' uptime on cosmos-sdk chains. For that, I need two things

  1. a validator info
  2. a signing info for this validator

Without RS it's quite easy, as I can just query SigningInfos and Validators, and for each validator I can find its signing info by taking its consensus address and finding the SigningInfos entry with the same consensus address.
With RS and without key assignment it's pretty much the same (but I need to query Validators from provider chain and SigningInfos from consumer chains).
With RS and key assignments it's getting more fun. Let's say, a validator issues an assign-consensus-key transaction. Then, if I do it with the algorithm above, when I query validators list, this validator will have its own consensus pubkey returned, and I won't be able to map it to consumer chain's signing info, as it uses a different pubkey.
The correct way would be to query 1) Validators, from a provider chain, 2) SigningInfos, from a consumer chain, and 3) assigned keys for this consumer chain from a provider chain.
Then I can do the following:

  • assume ConsensusKey is the validator's consensus key
  • if validator has assigned consensus key for a consumer chain, assume ConsensusKey as this assigned consensus key
  • find SigningInfo with consensus address equal to the ConsensusKey
  • calculate missed blocks counter

Problem is, imagine there are 175 validators. To calculate missed blocks for all active validators, I need to do the following queries as of now:

  • 1 query to a validators list to get all validators
  • 1 query to a signing info list to get all signing infos (unfortunately on cosmoshub there's a bug so I need to do 175 requests, but that's discussed here: Missing address in signing_infos of rest api #1344 #1734, and it's not related to this topic, and generally it's working with 1 request on all other chains I've tested)
  • 175 requests per each validator to get an assigned consensus key

This might be 1) slow and 2) unreliable, and it'd be nice to have a possibility to query for all assigned consensus key for a consumer chain, so I'll need to do 3 queries in total to calculate the missed blocks counter for all validators on a consumer chain.
Also this kinda resembles the N+1 problems from the databases: https://stackoverflow.com/questions/97197/what-is-the-n1-selects-problem-in-orm-object-relational-mapping

I am pretty sure other maintainers of bots tracking the validators' uptime will face it, so I think this will be useful.

I'm mostly interested in the API to return all the consensus keys on a specific consumer chain, however having a command to do it from CLI shouldn't be that difficult to make I assume.

@glnro
Copy link
Contributor

glnro commented May 30, 2023

Wouldn't this make sense to define the cobra command in interchain-security and then import into gaia?

@freak12techno
Copy link
Contributor

freak12techno commented May 30, 2023

Actually it seems like the keeper method is already in place: https://github.com/cosmos/interchain-security/blob/e8868556cadfa95a6b0786bd75d7a42debabc57a/x/ccv/provider/keeper/key_assignment.go#L62. I guess what's needed is only 1) add a query handler and 2) add a CLI command.

If it's that simple I can try implementing this on my own, is that good?

@glnro

Wouldn't this make sense to define the cobra command in interchain-security and then import into gaia?

Seems so

@mmulji-ic
Copy link
Contributor Author

mmulji-ic commented May 30, 2023

Wouldn't this make sense to define the cobra command in interchain-security and then import into gaia?

This is to track when it actually lands in Gaia. cc @freak12techno

Will create an ICS issue linked to this.

@mpoke
Copy link
Contributor

mpoke commented Jun 9, 2023

This issue is blocked for now as the work will be done on the interchain-security repo.

@mpoke mpoke removed the status: waiting-triage This issue/PR has not yet been triaged by the team. label Jun 9, 2023
@mpoke mpoke added the S: ImprovingThings Improving things: Customer requests, performance improvements, reliability and usability label Sep 15, 2023
@mpoke mpoke linked a pull request Jan 10, 2024 that will close this issue
18 tasks
@mpoke mpoke closed this as completed Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more-info-needed Further information is requested S: ImprovingThings Improving things: Customer requests, performance improvements, reliability and usability scope: CLI Issues and features pertaining to Gaia's CLI client. type: feature-request New feature or request improvement
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

4 participants