cosmos / cosmjs

The Swiss Army knife to power JavaScript based client solutions ranging from Web apps/explorers over browser extensions to server-side clients like faucets/scrapers.
https://cosmos.github.io/cosmjs/
Apache License 2.0
646 stars 331 forks source link

Query client validatorDelegations hangs on cosmos nodes #1209

Closed oblak1 closed 2 years ago

oblak1 commented 2 years ago

We've tried calling validatorDelegations from staking module on multiple cosmos nodes (public as well as our own) and every time it hangs - the node actually stops syncing - without returning anything. Sometimes we get the 504 Timeout which doesn't mean much.

We've been using cosmjs on multiple other tendermint nodes (such as axelar and gravity-bridge) where this issue doesn't arise.

Perhaps this issue happens due to the larger data scale on cosmos. We've tried to manually creating staking extension with a smaller pagination size but it still didn't work.

Steps to replicate

Connect to cosmos node and call QueryClient.staking.validatorDelegations on one of the active validators.

webmaster128 commented 2 years ago

I can reproduce the behaviour using Cosmos Hub endpoint https://rpc.cosmos.network. The issue even exists for inactive validators. Same for Juno, even for https://www.mintscan.io/juno/validators/junovaloper1fv38y5g8xwxa88g00epp2qyht3qysecvle9r6x who has one delegator only.

The local tests against the simapp blockchain work.

🤷‍♂️

oblak1 commented 2 years ago

In addition, using REST api endpoint for validator delegations via port 1317, for example: /cosmos/staking/v1beta1/validators/cosmosvaloper1sjllsnramtg3ewxqwwrwjxfgc4n4ef9u2lcnj0/delegations?pagination.limit=100 works as well.

Could this be a bug inside cosmos SDK?

webmaster128 commented 2 years ago

Could this be a bug inside cosmos SDK?

Yes, that's possible.

Would be great to test with a generic gRPC client on the grpc port of the nodes (9000?). But I'm not super familiar with this tooling.

oblak1 commented 2 years ago

Did the testing on port 9090 (grpc server) via grpcurl: grpcurl -plaintext -d '{"pagination": {"limit": 100}, "validator_addr": "cosmosvaloper1sjllsnramtg3ewxqwwrwjxfgc4n4ef9u2lcnj0" }' node:9090 cosmos.staking.v1beta1.Query/ValidatorDelegations

It works.

Can't really think of anything else to try at this point. Afaik all the queries in cosmjs are essentially done via the same generic query call.

While testing I also noticed a similar issue with accounts call in auth module so it could be related to the scale of queried data.

nooomski commented 2 years ago

If I understand you right, your node actually stops syncing after calling QueryClient.staking.validatorDelegations when the data is large enough? If so, that sounds to me like an SDK problem, not something for CosmJS.

Would you be able to create an issue on the SDK repo @oblak1 ? Closing this unless there's new information to indicate the issue is appropriate here.