Skip to content

Conversation

@nuttycom
Copy link
Contributor

@nuttycom nuttycom commented Jan 4, 2022

This builds atop #5395 to address #5395 (review)

softminus and others added 30 commits November 18, 2021 10:39
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
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
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
LarryRuane and others added 3 commits January 5, 2022 12:07
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>
@nuttycom nuttycom added this to the Core Sprint 2021-52 milestone Jan 5, 2022
@nuttycom nuttycom added the S-committed Status: Planned work in a sprint label Jan 5, 2022
@nuttycom nuttycom self-assigned this Jan 5, 2022
@nuttycom nuttycom force-pushed the feature/wallet_unified_addresses-fix_receiver_order branch from a167abc to 0245bab Compare January 5, 2022 16:59
@nuttycom nuttycom force-pushed the feature/wallet_unified_addresses-fix_receiver_order branch from 0245bab to fe777c5 Compare January 6, 2022 01:33
@nuttycom nuttycom requested review from daira and str4d January 6, 2022 16:24
Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

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

utACK fe777c5

Copy link
Contributor

@str4d str4d left a 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
Comment on lines 73 to 77
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" }
Copy link
Contributor

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) {
Copy link
Contributor

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, UnifiedAddress stores its internals in the exact order provided by UnifiedAddress::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 the std::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.

Copy link
Contributor

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 @@
[
Copy link
Contributor

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"],
Copy link
Contributor

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.

@str4d str4d added NU5 Network upgrade: NU5-specific tasks A-rust-ffi Area: The Rust FFI in the librustzcash library. labels Jan 6, 2022
@nuttycom nuttycom removed their assignment Jan 6, 2022
@nuttycom nuttycom merged commit 89755a1 into zcash:feature/wallet_unified_addresses Jan 6, 2022
@nuttycom nuttycom deleted the feature/wallet_unified_addresses-fix_receiver_order branch January 6, 2022 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rust-ffi Area: The Rust FFI in the librustzcash library. NU5 Network upgrade: NU5-specific tasks S-committed Status: Planned work in a sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants