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 #1978

Merged
merged 8 commits into from
Apr 6, 2021

Conversation

teor2345
Copy link
Contributor

@teor2345 teor2345 commented Apr 6, 2021

This PR is a copy of #1958, which has already been approved. But it was merged into the wrong branch.

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

Interactive replace using:
```sh
fastmod RootHash Commitment
fastmod root_hash commitment
fastmod root_bytes commitment_bytes
git mv zebra-chain/src/block/root_hash.rs zebra-chain/src/block/commitment.rs
```

All replacements were accepted.
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 A-consensus Area: Consensus rule updates A-rust Area: Updates to Rust code C-cleanup Category: This is a cleanup NU-5 Network Upgrade: NU5 specific tasks P-Medium labels Apr 6, 2021
@teor2345 teor2345 added this to the 2021 Sprint 6 milestone Apr 6, 2021
@teor2345 teor2345 self-assigned this Apr 6, 2021
@teor2345
Copy link
Contributor Author

teor2345 commented Apr 6, 2021

@dconnolly already approved these changes as #1958.

@teor2345 teor2345 merged commit 05b60db into ZcashFoundation:main Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-consensus Area: Consensus rule updates A-rust Area: Updates to Rust code C-cleanup Category: This is a cleanup NU-5 Network Upgrade: NU5 specific tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate consensus rules on root hash and change data modeling.
1 participant