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

Support height queries for queriers #4382

Merged
merged 19 commits into from
May 29, 2019
Merged

Conversation

alexanderbez
Copy link
Contributor

@alexanderbez alexanderbez commented May 20, 2019

A (working) POC stab at supporting height queries for querier based queries (wow what a mouthful). This POC does not handle merkle proofs in any way. Doing so warrants further discussion and is not immediately feasible because the node may modify state returned from any internal queries (eg. staking).

If this POC is agreed upon, perhaps we may potentially include it in a release with a clear stipulation that proofs are not supported.

closes: #4318

Follow up: Create an issue to allow a height query param to be provided to REST endpoints.

/cc @zmanian @cwgoes @jackzampolin @mossid


  • Targeted PR against correct branch (see CONTRIBUTING.md)

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added a relevant changelog entry: clog add [section] [stanza] [message]

  • rereviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@codecov
Copy link

codecov bot commented May 20, 2019

Codecov Report

Merging #4382 into master will increase coverage by 0.04%.
The diff coverage is 58.33%.

@@            Coverage Diff             @@
##           master    #4382      +/-   ##
==========================================
+ Coverage   54.53%   54.58%   +0.04%     
==========================================
  Files         247      248       +1     
  Lines       15908    15967      +59     
==========================================
+ Hits         8676     8716      +40     
- Misses       6602     6617      +15     
- Partials      630      634       +4

@zmanian
Copy link
Member

zmanian commented May 20, 2019

If I remember right, app.go used call LoadVersion(0) which basically loaded all versions in the store into memory. It appears not to do this any more.

Then this would be correct and provide the expected lazy loading behavior.

@alexanderbez alexanderbez changed the title POC/DNM: Support height queries for queriers Support height queries for queriers May 21, 2019
@alexanderbez
Copy link
Contributor Author

*MutableTree#LoadVersion still loads all the node roots into memory for each store on startup.

@alexanderbez alexanderbez marked this pull request as ready for review May 21, 2019 18:12
@alexanderbez alexanderbez removed the WIP label May 21, 2019
@alexanderbez
Copy link
Contributor Author

/cc @jordansexton

@zmanian
Copy link
Member

zmanian commented May 21, 2019

With 876f0d8, does this now support proofs?

@alexanderbez
Copy link
Contributor Author

With 876f0d8, does this now support proofs?

@zmanian unfortunately not. That commit relates to direct key lookups. Querier-based queries will need a bit more thought (eg. tracing each lookup). I'm brainstorming...

@zmanian
Copy link
Member

zmanian commented May 22, 2019

Oh okay. the loss of proofs is not a regression.

@alexanderbez
Copy link
Contributor Author

Oh okay. the loss of proofs is not a regression.

Correct. More like the continuance of their absence.

Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me, although there could be efficiency concerns with particular usecases - e.g. querying all height sequentially would call LoadVersion each time, which might be inefficient (not sure if the IAVL library would keep the existing mostly-the-same version in memory or reload everything from disk).

Copy link
Member

@jackzampolin jackzampolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good with the tradeoffs here. This also gets us into a better place wrt proofs it looks like.

@alexanderbez
Copy link
Contributor Author

alexanderbez commented May 28, 2019

Looks reasonable to me, although there could be efficiency concerns with particular usecases - e.g. querying all height sequentially would call LoadVersion each time, which might be inefficient (not sure if the IAVL library would keep the existing mostly-the-same version in memory or reload everything from disk).

Hmmm, iirc, this is not true with my implementation (I could very well be wrong). What makes you assume this? Querier queries call CacheMultiStoreWithVersion, which ultimately calls GetImmutable on the IAVL tree store which in turn only loads a single root node/height (if it even exists).


EDIT: I see you wrote, sequentially. Ahhh, then yes, it would. Do you have any suggestions on mitigation? Looks like tree.ndb.getRoot(version) just does a DB lookup which may already be cached (depending on the tuned parameters/config of the underlying DB).

@alexanderbez
Copy link
Contributor Author

@mossid I will merge this today, try to review if you can.

@jackzampolin
Copy link
Member

🔥 🔥 🔥 🔥 🔥 🔥

@alexanderbez alexanderbez merged commit 8b1d75c into master May 29, 2019
@alexanderbez alexanderbez deleted the bez/4318-height-query-support branch May 29, 2019 00:58
@alexanderbez
Copy link
Contributor Author

Merged, but still would appreciate a review @mossid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Height Queries
5 participants