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

Clean up block commitment enum and parsing #1958

Conversation

teor2345
Copy link
Contributor

@teor2345 teor2345 commented Mar 29, 2021

Motivation

The goal of this PR is to finish the outstanding cleanups on the block commitment field from #881.

After they're done, we can create a good design for its FinalSaplingRoot, ChainHistoryRoot, and BlockCommitments variants.

Solution

  • Comment cleanups after interactive replace
  • Distinguish Sapling tree roots from other tree roots
  • Add the NU5 BlockCommitmentsHash variant to block::Commitment
  • Validate reserved values in Block::commitment

This PR is based on #1957.

Review

@oxarbitrage is going to work on ZIP-244 and ZIP-221 with me, so he can review this.

Related Issues

Closes #881
Makes some progress on #1874

Follow Up Work

Do a design for #1874, #1567, and #958

This change parses the hash, but does not perform validation.
- change Block::commitment to return a Result rather than an Option
- enforce the all-zeroes reserved value consensus rules
- change `PreSaplingReserved([u8; 32])` to `PreSaplingReserved`
- change `ChainHistoryActivationReserved([u8; 32])` to `ChainHistoryActivationReserved`
- update the function comments to describe when each variant is verified
@teor2345 teor2345 added C-enhancement Category: This is an improvement C-cleanup Category: This is a cleanup NU-5 Network Upgrade: NU5 specific tasks P-Medium labels Mar 29, 2021
@teor2345 teor2345 added this to the 2021 Sprint 6 milestone Mar 29, 2021
@teor2345 teor2345 requested a review from oxarbitrage March 29, 2021 05:41
@teor2345 teor2345 self-assigned this Mar 29, 2021
@teor2345 teor2345 marked this pull request as draft March 29, 2021 05:41
@teor2345
Copy link
Contributor Author

I'm setting this to draft until #1957 merges.

@teor2345 teor2345 changed the title Block commitment consensus Clean up block commitment enum and parsing Mar 29, 2021
@teor2345 teor2345 marked this pull request as ready for review March 30, 2021 23:52
@teor2345 teor2345 requested a review from dconnolly March 30, 2021 23:52
@teor2345
Copy link
Contributor Author

@oxarbitrage is busy, so pinging @dconnolly for this.

Comment on lines +36 to +39
/// since Zebra checkpoints on Canopy, we don't need to validate this
/// field, but since it's included in the ChainHistoryRoot, we are
/// already calculating it, so we might as well validate it
FinalSaplingRoot(sapling::tree::Root),
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@teor2345 teor2345 merged commit b620c62 into ZcashFoundation:block-commitment-rename Mar 31, 2021
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.

👍


/// Errors that can occur when checking RootHash consensus rules.
///
/// Each error variant corresponds to a consensus rule, so enumerating
Copy link
Contributor

Choose a reason for hiding this comment

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

💖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: This is a cleanup C-enhancement Category: This is an improvement NU-5 Network Upgrade: NU5 specific tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants