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

Add HistoryTree struct #2396

Merged
merged 5 commits into from
Jul 6, 2021
Merged

Add HistoryTree struct #2396

merged 5 commits into from
Jul 6, 2021

Conversation

conradoplg
Copy link
Collaborator

@conradoplg conradoplg commented Jun 25, 2021

Motivation

ZIP-221 specifies a header commitment to a history tree of the previous blocks.

Thie PR adds a HistoryTree struct that keeps track of the history using the zcash_history.rs wrapper of librustzcash.

Specifications

Relevant: https://zips.z.cash/zip-0221 (though this is just part of it)

Designs

See #2135 for some design discussion.

Solution

The HistoryTree struct keeps track of the tree, adding blocks, pruning the tree, and computing the root hash.

There are also some changes to zcash_history.rs that I only realized were needed when writing this.

Review

This was split off from #2301 to reduce its size so it was partially reviewed.

This has no tests because it is tested indirectly by #2301. However I'm thinking of adding some basic tests; feedback is welcome.

@teor2345 may want to finish reviewing it, and @dconnolly may want to take a look to review the future interaction of this code with the note commitment trees.

Reviewer Checklist

  • Code implements Specs and Designs
  • Tests for Expected Behaviour
  • Tests for Errors

Follow Up Work

Part of #2135

Removing blocks will be added in #2378.
Pruning will be refactored in #2377.

Proper Orchard support will be added along with zcash_history support in #2283. Currently it only has the placeholder parameters for the Orchard roots.

@teor2345
Copy link
Contributor

I'm going to get @dconnolly to review this PR, feel free to tag me if you have any questions.

@teor2345 teor2345 requested a review from dconnolly June 27, 2021 23:56
@dconnolly dconnolly added the A-rust Area: Updates to Rust code label Jun 28, 2021
@mpguerra mpguerra linked an issue Jun 29, 2021 that may be closed by this pull request
6 tasks
@dconnolly
Copy link
Contributor

@conradoplg made some comments and suggestions for you

Copy link
Collaborator Author

@conradoplg conradoplg left a comment

Choose a reason for hiding this comment

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

I've addressed the comments

Copy link
Contributor

@dconnolly dconnolly left a comment

Choose a reason for hiding this comment

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

Looks good to me! 🌲

@dconnolly dconnolly requested a review from teor2345 July 6, 2021 08:41
@teor2345 teor2345 merged commit d430e95 into main Jul 6, 2021
@teor2345 teor2345 deleted the history-tree branch July 6, 2021 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rust Area: Updates to Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ZIP-221: Validate chain history commitments in the non-finalized state
3 participants