-
Notifications
You must be signed in to change notification settings - Fork 113
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
39
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.
+357
−301
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
arya2
reviewed
Jan 28, 2025
github-actions
bot
added
the
C-trivial
Category: A trivial change that is not worth mentioning in the CHANGELOG
label
Jan 30, 2025
upbqdn
removed
the
C-trivial
Category: A trivial change that is not worth mentioning in the CHANGELOG
label
Jan 30, 2025
arya2
approved these changes
Jan 31, 2025
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.
Looks good, thank you!
Comment on lines
+444
to
+449
verifier | ||
.is_valid(NetworkUpgrade::Blossom, input_index + 1) | ||
.expect_err("verification should fail"); | ||
verifier | ||
.is_valid(NetworkUpgrade::Blossom, input_index + 1) | ||
.expect_err("verification should fail"); |
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.
Suggested change
verifier | |
.is_valid(NetworkUpgrade::Blossom, input_index + 1) | |
.expect_err("verification should fail"); | |
verifier | |
.is_valid(NetworkUpgrade::Blossom, input_index + 1) | |
.expect_err("verification should fail"); | |
verifier | |
.is_valid(NetworkUpgrade::Blossom, input_index + 1) | |
.expect_err("verification should fail"); |
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
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
.NetworkUpgrade::previous_upgrade
and refactorNetworkUpgrade::next_upgrade
so that it doesn't explicitly enumerate all upgrades.NETWORK_UPGRADES_IN_ORDER
pub
.Tests
PR Author's Checklist
PR Reviewer's Checklist