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

Refactor validation of Sapling shielded data in transaction::Verifier #2419

Merged

Conversation

jvff
Copy link
Contributor

@jvff jvff commented Jun 30, 2021

Motivation

As part of NU5, there is a new transaction format and consensus rules (version 5). Zebra already had initial support for the new transaction, but the consensus rules aren't fully implemented. In order to properly validate the new transaction version, some validation code related to Sapling shielded data will be shared between V4 and V5 transactions, so this PRs refactors it to prepare for code sharing.

This is the fourth PR that's part of #1981.

Specifications

The new transaction encoding and consensus rules are detailed in the specification.

Designs

Solution

A new verify_sapling_shielded_data method is created by this PR, and the verify_v4_transaction uses it.

Two tests were also added. Both test if transactions from the test vectors are accepted by the verifier.

These tests might need some sort of fix or workaround for the shared batch verifier worker task issue (#2390). If the CI fails with a Closed error message, then it is likely the same cause. Can #2397 be merged as a temporary solution?

Review

@teor2345

Reviewer Checklist

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

Follow Up Work

@jvff jvff requested a review from teor2345 June 30, 2021 02:00
@zfnd-bot zfnd-bot bot assigned jvff Jun 30, 2021
@teor2345
Copy link
Contributor

These tests might need some sort of fix or workaround for the shared batch verifier worker task issue (#2390). If the CI fails with a Closed error message, then it is likely the same cause. Can #2397 be merged as a temporary solution?

Yes, we can merge #2397 now if you want.

I triaged it as optional because it didn't impact any other work. But now we need it for other things we can merge.

Can you please add an estimate to #2397 before you merge it?
(It is unexpected work in this sprint, so it needs an estimate.)

@teor2345
Copy link
Contributor

Tests for rejecting invalid transactions according to the transaction rules:

These all look like cryptographic tests to me. Can you open a ticket?

Then I'll get one of the cryptographers to triage it, and make sure we're not duplicating that work.

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.

We could merge this code as-is.

But we might want to change the validation function arguments so they will work for V5 transactions.

zebra-chain/Cargo.toml Show resolved Hide resolved
zebra-chain/src/transaction/arbitrary.rs Show resolved Hide resolved
zebra-consensus/src/transaction.rs 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.

We need to rebase on main, and use the shared runtime.

Move the code to verify Sapling shielded data into a new helper method
that returns `AsyncChecks`.
@jvff jvff force-pushed the refactor-verify-sapling-shielded-data branch from 841f070 to 0f0d40f Compare July 1, 2021 01:10
jvff added 4 commits July 1, 2021 01:36
Use the test vectors to find a transaction that has Sapling spends and
test if it the verifier considers it valid.
Transforms the block test vectors into a list of transactions and block
heights for each transaction.
Also use the block height for that transaction as specified in the test
vector.
Find a transaction V4 vector that has Sapling outputs but no spends, and
check that the verifier accepts it.
@jvff jvff force-pushed the refactor-verify-sapling-shielded-data branch from 0f0d40f to ec8e9bc Compare July 1, 2021 01:39
@jvff
Copy link
Contributor Author

jvff commented Jul 1, 2021

These all look like cryptographic tests to me. Can you open a ticket?

Then I'll get one of the cryptographers to triage it, and make sure we're not duplicating that work.

Done: #2426.

@jvff jvff requested a review from teor2345 July 1, 2021 01:59
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.

It passes

@teor2345 teor2345 merged commit 76fca5f into ZcashFoundation:main Jul 1, 2021
@jvff jvff deleted the refactor-verify-sapling-shielded-data branch July 1, 2021 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants