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

Release Blocker: Stop trying to verify coinbase inputs using the script verifier #2404

Merged
merged 3 commits into from
Jun 29, 2021

Conversation

teor2345
Copy link
Contributor

Motivation

Fixes #2401, a transaction::Verifier bug introduced by PR #2382.

This bug stops Zebra syncing after the mandatory Canopy checkpoint, as soon as the transaction::Verifier starts being used.

Specifications

Unfortunately, the Zcash specification doesn't cover all the validation rules for coinbase inputs and outputs.

Solution

  • Stop passing coinbase inputs to the script verifier
  • Add tests with transparent coinbase outputs

Review

@jvff can review this PR, it's a high priority, because it stops syncing. (And makes other code hard to test.)

Reviewer Checklist

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

Follow Up Work

We'll do shielded coinbase tests as part of the shielded coinbase ticket.

And create tests to catch similar bugs earier.
@teor2345 teor2345 added C-bug Category: This is a bug A-consensus Area: Consensus rule updates P-High labels Jun 28, 2021
@teor2345 teor2345 added this to the 2021 Sprint 12 milestone Jun 28, 2021
@teor2345 teor2345 requested a review from jvff June 28, 2021 07:48
@teor2345 teor2345 self-assigned this Jun 28, 2021
@mpguerra mpguerra removed this from the 2021 Sprint 12 milestone Jun 28, 2021
jvff
jvff previously approved these changes Jun 28, 2021
Copy link
Contributor

@jvff jvff 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! I added some comments, but they're all optional.

zebra-consensus/src/transaction/tests.rs Show resolved Hide resolved
let result = verifier
.oneshot(Request::Block {
transaction: Arc::new(transaction),
known_utxos: Arc::new(known_utxos),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I'd remove the known_utxos variable to avoid the impression that there are any known UTXOs in the test.

Suggested change
known_utxos: Arc::new(known_utxos),
known_utxos: Arc::new(HashMap::new()),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 3ee905f

Comment on lines +446 to +448
// TODO: Remove `should_panic` once the NU5 activation heights for testnet and mainnet have been
// defined.
#[should_panic]
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: Maybe also add this to #1841?

Copy link
Contributor Author

@teor2345 teor2345 Jun 28, 2021

Choose a reason for hiding this comment

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

Done!

I just noticed a bug here: these functions should all use Testnet, because it will have an activation height first.

(Ideally they should use both networks, but that's a larger change.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bug fixed in 09b815c, also I updated the ticket, and added "any other should_panic" tests.

We've marked these tests as should_panic until there is a NU5 activation
height. But Testnet will have an activation height first, so we should
prefer it in the tests. (Or use both networks.)
@teor2345 teor2345 requested a review from jvff June 29, 2021 00:09
@teor2345
Copy link
Contributor Author

This is ready for another review.

But since all the changes were optional, I can also merge once CI passes.

@teor2345 teor2345 merged commit 7c44ee2 into main Jun 29, 2021
@teor2345 teor2345 deleted the fix-unexpected-coinbase-input branch June 29, 2021 00:49
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 C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"unexpected coinbase input" error stops Zebra syncing past Canopy checkpoint
3 participants