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

Feature requires: We need a query which can return all rotated validator keys by consumer chain_id #1251

Closed
liangping opened this issue Aug 31, 2023 · 8 comments · Fixed by #1503
Assignees
Labels
good first issue Good for newcomers S: ImprovingThings Improving things: Customer requests, performance improvements, reliability and usability scope: UI Addressing UX changes and improvements to user interface

Comments

@liangping
Copy link

liangping commented Aug 31, 2023

Hello,

This query can return a single rotated key with a given address. this is not efficient that we have to query the each by each on front-end.

https://github.com/cosmos/interchain-security/blob/d137d39f01a2e2c85f90e7ea0bc0d1738affb4b1/x/ccv/provider/types/query.pb.go#L425C6-L425C39

For example:

curl https://api-cosmoshub-ia.cosmosia.notional.ventures/interchain_security/ccv/provider/validator_consumer_addr?provider_address=cosmosvalcons1rtst6se0nfgjy362v33jt5d05crgdyhfvvvvay&chain_id=stride-1
{
  "consumer_address": "cosmosvalcons1dt6ezae48ll23atl940m6xkzs6vz0falch5k9r"
}

Would be great, if we can just use chain_id=stride-1 and return something like this:

{
    "<old_key>": "<new_key>",
    "cosmosvalcons1rtst6se0nfgjy362v33jt5d05crgdyhfvvvvay" : "cosmosvalcons1dt6ezae48ll23atl940m6xkzs6vz0falch5k9r",
    "cosmosvalcons1rtst6se0nfgjy362v33jt5d05crgdyhfvvvvay" : "cosmosvalcons1dt6ezae48ll23atl940m6xkzs6vz0falch5k9r",
}
@mpoke mpoke added scope: UI Addressing UX changes and improvements to user interface S: ImprovingThings Improving things: Customer requests, performance improvements, reliability and usability labels Sep 1, 2023
@mpoke mpoke added this to Cosmos Hub Sep 1, 2023
@github-project-automation github-project-automation bot moved this to 🩹 F1: Triage in Cosmos Hub Sep 1, 2023
@mpoke mpoke moved this from 🩹 F1: Triage to 📥 F2: Todo in Cosmos Hub Sep 1, 2023
@mpoke mpoke moved this from 📥 F2: Todo to 🩹 F1: Triage in Cosmos Hub Sep 1, 2023
@mpoke mpoke added the good first issue Good for newcomers label Sep 1, 2023
@mpoke mpoke moved this from 🩹 F1: Triage to 🤔 F1: Investigate in Cosmos Hub Sep 14, 2023
@ThanhNhann
Copy link
Contributor

ThanhNhann commented Dec 6, 2023

Can I handle this issue? @mpoke

@mpoke
Copy link
Contributor

mpoke commented Dec 7, 2023

Thanks @ThanhNhann. I assigned you. Ping if you need help.

@mpoke mpoke moved this from 🤔 F1: Investigate to 🏗 F3: InProgress in Cosmos Hub Dec 7, 2023
@ThanhNhann
Copy link
Contributor

HI @liangping and @mpoke, I want to clarify that the goal of this issue is to have a list of pairs {providerConsAddr, consumerAddr} right ?

@liangping
Copy link
Author

@ThanhNhann this is what I am expected. but a list of key pairs is ok to me

{
    "<old_key>": "<new_key>",
    "cosmosvalcons1rtst6se0nfgjy362v33jt5d05crgdyhfvvvvay" : "cosmosvalcons1dt6ezae48ll23atl940m6xkzs6vz0falch5k9r",
    "cosmosvalcons1rtst6se0nfgjy362v33jt5d05crgdyhfvvvvay" : "cosmosvalcons1dt6ezae48ll23atl940m6xkzs6vz0falch5k9r",
}

@ThanhNhann
Copy link
Contributor

thank @liangping for the fast reply

@ThanhNhann
Copy link
Contributor

I just made a pr for this issue, can you take a look to check it? @liangping

@liangping
Copy link
Author

@ThanhNhann I just got a new idea!

We need a api like this: /cosmos/staking/v1beta1/validators

it returns a full validator list with validator's rotated key on the consumer chain.

Currently consumer chain does not provide validators api since there's no staking module, so it would be better to have this instead of the list of key pair.

but you can keep the key pair list.

@mpoke mpoke moved this from 🏗 F3: InProgress to 👀 F3: InReview in Cosmos Hub Jan 4, 2024
@github-project-automation github-project-automation bot moved this from 👀 F3: InReview to 👍 F4: Assessment in Cosmos Hub Jan 5, 2024
@mpoke mpoke moved this from 👍 F4: Assessment to ✅ Done in Cosmos Hub Jan 11, 2024
@freak12techno
Copy link
Contributor

freak12techno commented Mar 24, 2024

Hi, just wondering if that's expected: on my node, the REST endpoint returns some binary data instead of cosmosvalcons addresses, is that expected:
Example on my node: https://api.cosmos.quokkastake.io/interchain_security/ccv/provider/consumer_chain_id?chain_id=neutron-1
image

Also, querying it via CLI doesn't work:

validator@cosmos-validator ~ ❯ gaiad q provider all-pairs-valconsensus-address stride-1
Error: yaml: control characters are not allowed
Usage:
  gaiad query provider all-pairs-valconsensus-address [flags]

UPD: apparently this patch in x/ccv/provider/keeper/grpc_query.go, makes both of the issues working:

	for _, data := range validatorConsumerPubKeys {
		consumerAddr, err := ccvtypes.TMCryptoPublicKeyToConsAddr(*data.ConsumerKey)
		if err != nil {
			return nil, err
		}

		var providerAddr sdk.ConsAddress = data.ProviderAddr

		pairValConAddrs = append(pairValConAddrs, &types.PairValConAddrProviderAndConsumer{
			ProviderAddress: providerAddr.String(),
			ConsumerAddress: consumerAddr.String(),
			ConsumerKey:     data.ConsumerKey,
		})
	}

I patched it on my node (see link above), and it seems to return consensus addresses now.
image

@mpoke I can make a PR on that, do you mind?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers S: ImprovingThings Improving things: Customer requests, performance improvements, reliability and usability scope: UI Addressing UX changes and improvements to user interface
Projects
No open projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

4 participants