Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Use changes tries in query_storage RPC #1082

Merged
merged 4 commits into from
Jan 17, 2019
Merged

Conversation

svyatonik
Copy link
Contributor

@svyatonik svyatonik commented Nov 7, 2018

The idea is that state_queryStorage could use changes tries (if they're enabled) to avoid reading key(s) value(s) at every block of the range. Instead we could ask changes tries to filter blocks where the value has been changed && read values at these blocks only.
I assume that there will be no positive effect for small blocks ranges, but for big ranges + for keys that are changing rarely it should increase performance significantly. So probably it could be tweaked in the future (like if range.legth < 16 => do not use changes tries).

@svyatonik svyatonik added the A3-in_progress Pull request is in progress. No review needed at this stage. label Nov 7, 2018
@svyatonik svyatonik added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Nov 20, 2018
@gavofyork gavofyork added A3-needsresolving and removed A0-please_review Pull request needs code review. labels Jan 7, 2019
@svyatonik svyatonik added A0-please_review Pull request needs code review. A3-in_progress Pull request is in progress. No review needed at this stage. and removed A3-needsresolving A0-please_review Pull request needs code review. A3-in_progress Pull request is in progress. No review needed at this stage. labels Jan 9, 2019
@gavofyork gavofyork added this to the 1.0gamma milestone Jan 11, 2019
last: Block::Hash,
key: &[u8]
first: NumberFor<Block>,
last: BlockId<Block>,
Copy link
Member

Choose a reason for hiding this comment

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

any reason to switch API from hash to number?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When you identify blocks range by two hashes, there's additional ambiguity - blocks could be from different forks. When you identify range by first_number..last_hash, the only possible issue is when number(last) < first. That's the only reason, iirc.

@gavofyork gavofyork added A7-looksgoodcantmerge and removed A0-please_review Pull request needs code review. labels Jan 16, 2019
config: &ChangesTrieConfiguration,
best_finalized_block: u64
) -> u64 {
let min_blocks_to_keep = match self.min_blocks_to_keep {
Copy link
Member

Choose a reason for hiding this comment

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

Sorry for being late to the party, this can just be replaced by self.min_blocks_to_keep.unwrap_or(1).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Welcome! :) No, it can't, because None branch has return in it. I've changed code a bit so that now there's no explicit return + temp var.

Copy link
Member

Choose a reason for hiding this comment

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

Ohh okay. ty :)

@bkchr bkchr merged commit 81740bb into master Jan 17, 2019
@bkchr bkchr deleted the use_changes_tries_in_RPC branch January 17, 2019 09:08
MTDK1 pushed a commit to bdevux/substrate that referenced this pull request Apr 12, 2019
* use changes tries in query_storage RPC

* let + match + return + call -> match
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants