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

[Bug]: Result and Pagination are not available in gRPC cosmos.base.tendermint.Service. GetValidatorSetByHeight / GetLastestValidatorSet #18054

Closed
1 task done
chemonoworld opened this issue Oct 11, 2023 · 3 comments · Fixed by #20385
Assignees
Labels
S:zondax Squad: Zondax T:Bug

Comments

@chemonoworld
Copy link

chemonoworld commented Oct 11, 2023

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

This bug seems to be similar to #8560 but different a little bit.

The pagination "total" in the return result of this gRPC call to cosmos.base.tendermint.Service. GetValidatorSetByHeight is always 180 and the number of elements in Validators is 100 even if a PageRequest is already set in the GetValidatorSetByHeightRequest. The validator set will return maximum of 100 validators without the pagination key to query the next page. The corresponding rest API doesn't work.

Cosmos SDK Version

0.45, 0.47, 0.46(probably, but not checked)

How to reproduce?

Not happened in Tendermint RPC

https://rpc.cosmos.bh.rocks/validators?height=17300000

But it happens in rest API

https://rest.cosmos.directory/cosmoshub/cosmos/base/tendermint/v1beta1/validatorsets/latest
https://rest.cosmos.directory/cosmoshub/validatorsets/latest

It looks good on the face of it but the number of validators is always 100 even if "pagination.limit" in query string is changed.

Also happens in gRPC

grpcurl -plaintext cosmos-grpc.polkachu.com:14990 cosmos.base.tendermint.v1beta1.Service.GetLatestValidatorSet | jq '.pagination'

This always return the below result.

{
  "total": "180"
}

However,

grpcurl -plaintext cosmos-grpc.polkachu.com:14990 cosmos.base.tendermint.v1beta1.Service.GetLatestValidatorSet | jq '.validators | length'

This result in the return of this command is 100.

I also tried these with gRPC code(Golang) changing Request Pagination parameter but can take just only the same result.

@chemonoworld chemonoworld changed the title [Bug]: Result and Pagination is not available in gRPC cosmos.base.tendermint.Service. GetValidatorSetByHeight / GetLastestValidatorSet [Bug]: Result and Pagination are not available in gRPC cosmos.base.tendermint.Service. GetValidatorSetByHeight / GetLastestValidatorSet Oct 11, 2023
@educlerici-zondax educlerici-zondax added the S:zondax Squad: Zondax label Apr 11, 2024
@lucaslopezf
Copy link
Contributor

The core issue arises when querying validators from cometBFT, which enforces a maximum query limit of 100 validators to avoid overloading the node. This means that even if you set a limit above 100, 101 or 200, the query will always return the first page capped at 100 validators. You can find the code that enforces this limit here: cometBFT Code

Therefore, to retrieve the second page (the remaining 80 validators), you must use an offset equal to the limit you're setting, which is also the maximum limit allowed.

If you execute the following call:

grpcurl -plaintext -d '{"pagination": {"offset": "100","limit":100}}' cosmos-grpc.polkachu.com:14990 cosmos.base.tendermint.v1beta1.Service.GetLatestValidatorSet | jq '.validators | length'

You will receive the remaining 80 validators as expected.


@tac0turtle it would be great to have this pagination behavior documented. I couldn't find anything about it, do you know if it's documented somewhere? If not, should we add it? Where do you think would be a good place to put it?

@educlerici-zondax
Copy link
Contributor

@tac0turtle can you take a look at @lucaslopezf comment please? 🙏

@lucaslopezf
Copy link
Contributor

Hi @chemonoworld did the answer work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S:zondax Squad: Zondax T:Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants