-
Notifications
You must be signed in to change notification settings - Fork 715
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
optimize historical range #3658
base: master
Are you sure you want to change the base?
Conversation
d3bc7f3
to
3b35c08
Compare
39d1344
to
c8050d7
Compare
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.
We should have some benchmark results (either manual or preferably through a benchmark test) as part of this PR to verify the results
Range proofs benchmarking: The improvements are mostly seen when providing a small maxLength value compared to the total keys. I attached the result of a benchmark with the following input:
The benchmark was run using the same seed, and it was generating a rangeProof from a randomly chosen interval [start, end], from 2 different random merkleRoot's from the history, with a random maxLength [0, 0.2*totalKeys]. Results with 2 differents seeds:
Iterator benchmarking: I attached the result of a benchmark with the following input:
The benchmark was run using the same seed and it was randomly generating a start and a prefix for creating an iterator with the proper filtered changes.
|
362d0a8
to
9a19d2e
Compare
9a19d2e
to
89cac9a
Compare
Why this should be merged
Direct optimization:
startKey
and/orprefix
Indirect optimization
Fixes:
getChangesToGetToRoot(..)
no-ops being removed from outputHow this works
changeSummary
struct has a new field for having the changed keys in a sorted slicegetChangesToGetToRoot(..)
-> by having thesortedKeys
, we can search (binary search) for thestartKey
, and also easily stop iterating when we are afterendKey
.getValueChanges(..)
-> we can easily get change values betweenstartRoot
andendRoot
, with keys within[startKey, endKey]
in the following way:changes
,insertNumber
andindex
. Min => the root with the min key and min insertNumber (in this way, by popping out of the minheap, we traverse all the keys in ASC order by[key, insertNumber]
)[startKey, endKey]
, and push that initial state of each root into the heap (or not, if there are no keys inside that interval).IMPORTANT improvement for getValueChanges(..): we can stop whenever there are
maxLength
key changes found.How this was tested
Using the existing unit tests.
Adding new unit tests, or modifying existing ones to properly cover the new code.