-
Notifications
You must be signed in to change notification settings - Fork 106
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
ZIP-221 and ZIP-244 commitment validation in non-finalized state #2609
Conversation
Moved to draft because I forgot about the checkpoint verifier. But otherwise it's OK to review. |
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.
This looks good so far.
I'd like to see a NU5 test, can we open a ticket for that?
(We might need to wait until we have the NU5 testnet activation height.)
We could wait for NU5 testnet activation and see if it works.
But if it doesn't, all our CI would fail, even on unrelated work.
c8a7858
to
988963d
Compare
Would you mind rebasing this PR on |
988963d
to
d39b44b
Compare
Done! |
Co-authored-by: teor <teor@riseup.net>
d39b44b
to
d497a2a
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.
This all looks great!
I'd like to get the cached state tests passing before we merge this PR, then I think we're good to go here.
I've also updated the name of the PR so I don't get the finalized and non-finalized state confused.
I've started a run here https://github.com/ZcashFoundation/zebra/actions/runs/1137516612 |
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.
I'd like to get the cached state tests passing before we merge this PR, then I think we're good to go here.
I've started a run here https://github.com/ZcashFoundation/zebra/actions/runs/1137516612
It passed!
// Test committing the next block with the wrong commitment | ||
let next_block = activation_block.make_fake_child(); | ||
let err = state | ||
.commit_block(next_block.clone().prepare(), &finalized_state) | ||
.unwrap_err(); | ||
match err { | ||
crate::ValidateContextError::InvalidBlockCommitment( | ||
zebra_chain::block::CommitmentError::InvalidChainHistoryRoot { .. }, | ||
) => {} | ||
_ => panic!( | ||
"Error must be InvalidBlockCommitment::InvalidChainHistoryRoot instead of {:?}", | ||
err | ||
), | ||
}; |
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.
💟
// Test committing the next block with the correct commitment | ||
let next_block = next_block.set_block_commitment(tree.hash().into()); | ||
state | ||
.commit_block(next_block.prepare(), &finalized_state) | ||
.unwrap(); |
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.
👍
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.
🎉
@dconnolly sorry! I think I've merged it before you finished reading through it 😅 |
No worries 😁 |
Motivation
ZIP-221 specifies a history tree to which each block must commit to. ZIP-244 expands this commitment to also include the authentication data commitment.
This adds both checks.
Specifications
https://zips.z.cash/zip-0221#block-header-semantics-and-consensus-rules
https://zips.z.cash/zip-0244#block-header-changes
Designs
N/A
Solution
Compute the correct commitment and compare with the commitment in the block header.
The ZIP-244 path is not tested because there aren't post-Nu5 blocks yet and I couldn't come up with a way to test it. Suggestions are welcome.
Review
#2547 must be reviewed & merged first.
This (hopefully) finishes what we need for minimal validation post-Nu5, so must be reviewed before that.
Reviewer Checklist
Follow Up Work
N/A
This change is