-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Use changes tries in query_storage RPC #1082
Conversation
4eb8ffc
to
6a8cc30
Compare
last: Block::Hash, | ||
key: &[u8] | ||
first: NumberFor<Block>, | ||
last: BlockId<Block>, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
core/client/db/src/lib.rs
Outdated
config: &ChangesTrieConfiguration, | ||
best_finalized_block: u64 | ||
) -> u64 { | ||
let min_blocks_to_keep = match self.min_blocks_to_keep { |
There was a problem hiding this comment.
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)
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh okay. ty :)
* use changes tries in query_storage RPC * let + match + return + call -> match
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
).