-
Notifications
You must be signed in to change notification settings - Fork 111
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
fix(consensus): Verify consensus branch ID in SIGHASH precomputation #9139
Open
upbqdn
wants to merge
24
commits into
main
Choose a base branch
from
fix-sighash
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upbqdn
commented
Jan 18, 2025
upbqdn
added
C-bug
Category: This is a bug
A-consensus
Area: Consensus rule updates
NU-6
Network Upgrade: NU6 specific tasks
P-Medium ⚡
labels
Jan 24, 2025
upbqdn
changed the title
fix(consensus): Verify consensus branch ID before SIGHASH computation
fix(consensus): Verify consensus branch ID in SIGHASH precomputation
Jan 24, 2025
github-actions
bot
added
the
C-trivial
Category: A trivial change that is not worth mentioning in the CHANGELOG
label
Jan 24, 2025
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
C-trivial
Category: A trivial change that is not worth mentioning in the CHANGELOG
NU-6
Network Upgrade: NU6 specific tasks
P-Medium ⚡
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Close #9089.
Specifications & References
§ 4.10 SIGHASH Transaction Hashing
Solution
nConsensusBranchId
field. This precomputation is implemented inzebra-chain
, and is used by the tx verifier inzebra-consensus
and by the transparent script verifier inzebra-script
, but this verifier is only called from the tx verifier. It might be worth optimizing this, but that is currently not possible, as described in Compute the tx SIGHASH only once per tx verification #9165. The panic should never occur in regular use because the tx verifier implements another consensus branch ID check according to another consensus rule implemented here: https://github.com/zcashfoundation/zebra/blob/05a9b6171ccbc06bcc888470e4be8a60b1d574ef/zebra-consensus/src/transaction/check.rs#L513-L552, which takes effect early on and doesn't panic.zebra-chain
.NetworkUpgrade
instead ofConsensusBranchId
to the SIGHASH precomputation and tx conversion.TryFrom
instead of ad-hoc functions for conversion.TryFrom<&Transaction> for zcash_primitives::transaction::Transaction
Tests
PR Author's Checklist
PR Reviewer's Checklist