Unable to paginate queries in StakingExtension/validatorDelegations
See original GitHub issueSince fetching all the validator delegations is a very intensive method, trying to get all values directly usually results in an error, as already noted here https://github.com/cosmos/cosmjs/issues/1049.
I’m trying to get a paginated result with Stargate, StakingExtension, and the method validatorDelegations but I don’t know what should I pass as the paginationKey parameter.
According to the docs, paginationKey should be an Uint8Array, but what should I set as my first paginationKey, when I have none? I have been trying by setting paginationKey as an object with pagination information, null, ‘’, etc. without result. All the time it tries to get all the results directly which means that the pagination is not working and the node is not able to answer this request.
This is my code:
const { StargateClient } = require('@cosmjs/stargate')
const provider = 'https://cosmoshub-rpc.stakely.io/'
const client = await StargateClient.connect(provider)
const validatorAdress = 'cosmosvaloper16yupepagywvlk7uhpfchtwa0stu5f8cyhh54f2'
...
// Test 1
const pagination = '' // Timeout, pagination not working
// Test 2
const pagination = null // Timeout, pagination not working
// Test 3
const pagination = {
countTotal: false,
key: null,
limit: 50,
reverse: false,
} // Timeout, pagination not working
// Test 4
const pagination = new Uint8Array() // Timeout, pagination not working
const queryData = await client.queryClient.staking.validatorDelegations(validatorAdress, pagination)
console.log(queryData )
This would be the request using the LCD, which works fine: https://cosmoshub-lcd.stakely.io/cosmos/staking/v1beta1/validators/cosmosvaloper16yupepagywvlk7uhpfchtwa0stu5f8cyhh54f2/delegations?pagination.limit=50
Thanks in advance.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
I have tried the query against one of our nodes that is deployed on a really powerful dedicated server and it times out.
This is strange. There is this code in Cosmos SDK v0.45.6:
and
which is used in
But maybe thos 100 is even too much because the query implementation is inefficient?
Can you test this on your own node?
See also https://github.com/cosmos/cosmjs/issues/1209 and https://github.com/cosmos/cosmos-sdk/issues/12756