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

Small adjustments #2

Merged
merged 3 commits into from
May 17, 2024
Merged

Small adjustments #2

merged 3 commits into from
May 17, 2024

Conversation

serban300
Copy link
Collaborator

Did a more in-depth review of #1 . Overall the approach seems sane to me. Opening this PR just to propose some improvements that I noticed during the review.

The main change here is related to gen_node_proof_for_peak()

The idea is to sort the elements in the queue by height and pos. This way we can keep using the same strategy in the original crate (making these changes easier to upstream), avoid treating tiny corner cases, and it also improves the performance of generating an ancestry proof.

I suppose something similar can be done for calculate_peak_root() as well, but I'll check this at a later time and if possible, I'll open a separate PR.

The idea is to keep the elements in the queue sorted both by height and
pos. We make this adjustment in order to:
- make this method more similar with the original one (gen_proof_for_peak())
  => should be easier to upstream the changes
- avoid treating tiny corner cases
- improve performance (didn't do formal benchmarks, but just by running
  some unit tests looks like a 2-3x improvement)
@serban300 serban300 requested a review from acatangiu May 10, 2024 10:00
@serban300 serban300 self-assigned this May 10, 2024
@serban300 serban300 mentioned this pull request May 10, 2024
@acatangiu
Copy link
Collaborator

cc @Lederstrumpf

Copy link

@Lederstrumpf Lederstrumpf left a comment

Choose a reason for hiding this comment

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

tACK - presorting the (height, pos) queue makes sense to me - nice work!

@serban300 serban300 requested a review from svyatonik May 16, 2024 10:40
Copy link

@svyatonik svyatonik left a comment

Choose a reason for hiding this comment

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

Just a shallow review - haven't had a chance to do a thorough review

src/mmr.rs Show resolved Hide resolved
src/mmr.rs Show resolved Hide resolved
@acatangiu acatangiu merged commit c9ae0d6 into paritytech:master May 17, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants