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

Validate nConsensusBranchId #2100

Merged
merged 9 commits into from
May 10, 2021
Merged

Conversation

oxarbitrage
Copy link
Contributor

@oxarbitrage oxarbitrage commented May 3, 2021

Motivation

In #2075 we added the nConsensusBranchId to V5 transactions however we are not validating it yet.

Solution

Validate the field as described in the second action item of #2066

The code in this pull request has:

  • Documentation Comments
  • Unit Tests and Property Tests

Review

Related Issues

Close #2066 when merged.

Follow Up Work

We could add a test case to test the error.

@teor2345 teor2345 self-requested a review May 3, 2021 23:14
@teor2345 teor2345 added A-consensus Area: Consensus rule updates A-rust Area: Updates to Rust code NU-5 Network Upgrade: NU5 specific tasks P-Medium labels May 3, 2021
Copy link
Contributor

@teor2345 teor2345 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, just needs some doc and spec updates.

I also suggested a rename for the new error.

zebra-consensus/src/error.rs Outdated Show resolved Hide resolved
zebra-consensus/src/block/check.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

Thanks, that all looks good.

I also just realised that we need some tests.

Here is my suggestion:

  • run merkle_root_validity on all the blocks in MAINNET_BLOCKS and TESTNET_BLOCKS
  • run merkle_root_validity on all the blocks in MAINNET_BLOCKS and TESTNET_BLOCKS, after converting them using the fake_nu5 function

Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

Looks like we need to fix a bug in transaction_to_fake_v5 - I don't think either of us thought about upgrades after NU5.

zebra-consensus/src/block/tests.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

Thanks for these fixes, looks good to me!

I just added a comment explaining what the fake v5 test doesn't cover.

@teor2345 teor2345 enabled auto-merge (squash) May 10, 2021 01:06
@teor2345 teor2345 merged commit 29893f2 into ZcashFoundation:main May 10, 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 NU-5 Network Upgrade: NU5 specific tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the nConsensusBranchId field to v5 transactions
2 participants