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

/cosmos/staking/validators/{validator}/delegators unstable when querying #10516

Closed
4 tasks
FloppyDisck opened this issue Nov 10, 2021 · 4 comments
Closed
4 tasks
Labels
C:x/staking T: Performance Performance improvements

Comments

@FloppyDisck
Copy link

Summary of Bug

This bug applies to any blockchain using the recent SDK (Terra and Cosmos). Querying any validator related information either takes an unexpectedly high amount of time (> 10 minutes) or ends in returning a 504 error.

Version

Cosmos SDK v0.42.6 (Gaia v5.0.2 / cosmoshub-4)

Steps to Reproduce

GET https://api.cosmos.network/cosmos/staking/validators/{validator}/delegators?pagination.limit=100

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@alexanderbez
Copy link
Contributor

Yeah I think we've seen numerous reports of staking related endpoints being completely unusable. @robert-zaremba or @AmauryM can you lmk if we already have this captured in another issue? Also, can you summarize why this is? Is it because of gRPC and mutex contention and/or poor index design?

@amaury1093
Copy link
Contributor

amaury1093 commented Nov 10, 2021

I don't think we have another issue for this, we can use this one.

Is it because of gRPC and mutex contention and/or poor index design?

I'd say poor index design (gut feeling). I think the current design forces us to loop through all delegations, unmarshal each of them, and check if each one's validator matches the requested one. We should do some benchmarks to verify this hypothesis though, and add new indices if needed.

Edit: see

pageRes, err := query.FilteredPaginate(valStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) {
delegation, err := types.UnmarshalDelegation(k.cdc, value)
and following lines

@amaury1093 amaury1093 added T: Performance Performance improvements C:x/staking labels Nov 10, 2021
@freak12techno
Copy link
Contributor

I researched it and came to the conclusion that it iterates over ALL of the delegation entries, including the ones by other validators, then takes first N (N = limit) entries. If there are less delegators than N, it'll iterate over all the delegations. Here's a bit of my research: #15162

@alexanderbez
Copy link
Contributor

Closing this one as it's a dup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:x/staking T: Performance Performance improvements
Projects
None yet
Development

No branches or pull requests

4 participants