-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Make address serialization respect encoding order. #5450
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
Make address serialization respect encoding order. #5450
Conversation
Correct typo in docker run's volume argument.
This test-only change allows python (rpc) tests to specify, for example, that NU5 should be activated at height X, without having to specify all the previous network upgrades. Previous upgrades can (and must) still be specified if they activate at different block heights (than, in this example, NU5). This makes tests easier to write (and read), especially as the number of network upgrades increases over time. Note that this change only affects zcashd behavior in regtest mode. For the other network modes (testnet and mainnet), the activation heights are hard-coded in chainparams.cpp.
Thanks to metrics-rs/metrics#231 being merged, our dependency tree is now almost entirely de-duplicated!
In the three days since the last update, `futures 0.3.18` was yanked due to panics: rust-lang/futures-rs#2529
Batch-verify Orchard transactions at the block level.
Also adds a developer script to make updating the hashes easier.
…ogging Dont log ERROR: spent index not enabled
Update dependencies for 4.6.0
This reverts commit fb38cf0. The lint fix caused a problem on macOS, where the escaped double quote was interpreted as part of an argument, and not as defining an argument. We will need to find another way to address the lint. Closes zcash#5379.
We use the `zcash_address` crate to parse Unified Addresses (which we currently do nothing with). That crate returns an `UnsupportedAddress` error for unhandled address kinds, which we were previously logging. However, we _do_ support the other address kinds; we just parse them in the C++ code. Closes zcash#5321.
test: automatically add missing nuparams (network upgrade heights)
…essage rust: Remove misleading log message
- merkleroot - authdataroot - chainhistoryroot - blockcommitmentshash
`ed25519-zebra` 3
zcash/zcash: The `getmininginfo` RPC now omits `currentblockize` and `currentblocktx` when a block was never assembled via RPC on this node during its current process instantiation. The relevant RPCs are `generate` (regtest only) and `getblocktemplate`. Blocks are also assembled when running the internal miner (`zcashd -gen=1`), after the node mines its first block. (cherry picked from commit bitcoin/bitcoin@fa178a6)
[rpc] mining: Omit uninitialized currentblockweight, currentblocktx
Add defaultroots field to getblocktemplate
Revert lint: Fix false positive
Pre-4.6.0-rc1 changes
This test currently fails with submitblock returning the error "bad-heartwood-root-in-block". Added authdigest to GBT coinbasetxn field because we can't obtain this via getrawtransaction. Co-authored-by: Jack Grigg <jack@z.cash>
Script codes must be serialized in their field encoding, which includes the CompactSize length prefix. Co-authored-by: Jack Grigg <jack@z.cash>
We added support for the NU5 consensus rules in v4.5.0, which alters the block header to contain a `hashBlockCommitments` value instead of the chain history root. However, the output of `getblocktemplate` wasn't returning this value; once NU5 activated, the `blockcommitmentshash` field was being set to "null" (all-zeroes). In v4.6.0 we added full NU5 support to `getblocktemplate`, by adding a `defaultroots` field that gave default values for `hashBlockCommitments` and the components required to derive it. However, in doing so we introduced a regression in the (now-deprecated) legacy fields, where prior to NU5 activation they contained nonsense. This commit fixes the output of `getblocktemplate` to have the intended semantics for all fields: - The `blockcommitmentshash` and `authdataroot` fields in `defaultroots` are now omitted from block templates for heights before NU5 activation. - The legacy fields now always contain the default value to be placed into the block header (regaining their previous semantics). Co-authored-by: Larry Ruane <larry@z.cash>
a167abc to
0245bab
Compare
…ression-fix rpc: Fix regression in getblocktemplate output
Release v4.6.0-1
Hotfix v4.6.0-1
0245bab to
fe777c5
Compare
daira
left a comment
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.
utACK fe777c5
str4d
left a comment
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.
utACK. I verified that the diff between this PR and #5419 is just the last commit.
Cargo.toml
Outdated
| zcash_address = { git = "https://github.com/zcash/librustzcash.git", rev = "5622b060b1f57de7afc3d0b4e425b9b4b22482a0" } | ||
| zcash_history = { git = "https://github.com/zcash/librustzcash.git", rev = "5622b060b1f57de7afc3d0b4e425b9b4b22482a0" } | ||
| zcash_note_encryption = { git = "https://github.com/zcash/librustzcash.git", rev = "5622b060b1f57de7afc3d0b4e425b9b4b22482a0" } | ||
| zcash_primitives = { git = "https://github.com/zcash/librustzcash.git", rev = "5622b060b1f57de7afc3d0b4e425b9b4b22482a0" } | ||
| zcash_proofs = { git = "https://github.com/zcash/librustzcash.git", rev = "5622b060b1f57de7afc3d0b4e425b9b4b22482a0" } | ||
| zcash_address = { git = "https://github.com/zcash/librustzcash.git", rev = "7801dddf35ca247345cf4f5c5e48791297cad531" } | ||
| zcash_history = { git = "https://github.com/zcash/librustzcash.git", rev = "7801dddf35ca247345cf4f5c5e48791297cad531" } | ||
| zcash_note_encryption = { git = "https://github.com/zcash/librustzcash.git", rev = "7801dddf35ca247345cf4f5c5e48791297cad531" } | ||
| zcash_primitives = { git = "https://github.com/zcash/librustzcash.git", rev = "7801dddf35ca247345cf4f5c5e48791297cad531" } | ||
| zcash_proofs = { git = "https://github.com/zcash/librustzcash.git", rev = "7801dddf35ca247345cf4f5c5e48791297cad531" } |
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.
I checked that the change this corresponds to is just the introduction of the ZIP 316 changes.
| }; | ||
|
|
||
| let ua = match unified::Address::try_from_items_preserving_order(receivers) { | ||
| let ua = match unified::Address::try_from_items(receivers) { |
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.
This change keeps unit tests passing, but only because in #5455 the merge conflict with master was resolved in a way that discarded a bugfix (to the previous ZIP 316 implementation). The problem now is:
- On the C++ side,
UnifiedAddressstores its internals in the exact order provided byUnifiedAddress::AddReceiver. - This API now resorts the receivers into canonical order (as we want for ZIP 316).
- On subsequent parsing (where the merge conflict was), we are resorting from canonical order to preference order.
This is only round-trip compatible if UnifiedAddress::AddReceiver is always called in preference order. It just so happens that we do so, because in the previous ZIP 316 version we intended zcashd to produce UAs encoded in preference order, but that's insufficient to ensure API correctness.
What we need to do is refactor the C++ UnifiedAddress so that it no longer depends on any particular internal order, which the new canonical ZIP 316 encoding allows:
- Known receiver types should be stored separately in
std::optionals, while all unknown receivers remain in thestd::vec. - After this, the iteration APIs can be completely removed, because there's no longer any need to search for the known receivers within the preserved encoding order.
- This greatly simplifies the API of
UnifiedAddress, to the point that we might just be able to make it a wrapper around a Rust type (like has been done for UFVK etc).
None of this needs to happen in this PR, but the first point MUST be completed before we merge the feature branch.
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.
Opened #5456 to track this.
| @@ -1,14 +1,14 @@ | |||
| [ | |||
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.
I verified these changes matched the test vectors generated by zcash/zcash-test-vectors@61894e7.
| @@ -1,14 +1,14 @@ | |||
| [ | |||
| ["From https://github.com/zcash-hackworks/zcash-test-vectors/blob/master/unified_full_viewing_keys.py"], | |||
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.
I verified these changes matched the test vectors generated by zcash/zcash-test-vectors@61894e7.
This builds atop #5395 to address #5395 (review)