Commit Graph

339 Commits

Author SHA1 Message Date
Daira Emma Hopwood f1956ae442 Fix/suppress clippy warnings.
Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-04-20 16:29:57 +01:00
Jack Grigg b1dc94249c rust: Migrate Ed25519 FFI to `cxx` 2023-04-11 16:36:26 +00:00
Jack Grigg 19fed267e3 Use `cxx` bridge for all Orchard bundle inspection and validation
zcash/zcash#5987 added a bridge to `orchard::Bundle<Authorized, Amount>`
for `getrawtransaction`. This commit expands it to also cover the
consensus rules, by migrating over missing functionality from the
hand-written FFI methods, and exposing the Orchard `BatchValidator` type
directly (as with Sapling) instead of via the C++ `AuthValidator`
intermediary.

Part of zcash/zcash#6397.
2023-04-07 12:16:28 +00:00
Jack Grigg c301e321e4 Migrate `OrchardMerkleFrontier` to use new `CppStream` APIs 2023-04-06 21:30:38 +00:00
Jack Grigg 7b005aaa7a Expand `CppStream` to cover all `Stream`-like C++ types
In its existing usage, `CppStream` was only used in a context where the
C++ `READWRITE` macro was being called with a `CDataStream`. However, in
other contexts the macro can be called with various other types with a
stream-like interface. Since we can't expose C++ templates across the
`cxx` bridge (or FFI generally), we instead turn `CppStream` into an
enum that covers all of the stream-like types we may want to use.
2023-04-06 21:30:38 +00:00
Jack Grigg 33367709f7 Merge most `cxx::bridge` definitions into a single bridge
This enables us to use Rust types across more bridged APIs, which we
can't do with multiple bridge definitions until `cxx` adds support.
2023-04-05 10:50:35 +00:00
Jack Grigg 7f35a0da5c Migrate to `zcash_primitives 0.10`
Closes zcash/zcash#6398.
2023-03-17 00:09:45 +00:00
Jack Grigg f5ed454f87 wallet: Use `zcash_note_encryption` in `CWalletTx::RecoverSaplingNote` 2023-03-14 21:50:31 +00:00
Jack Grigg 95157cd97c wallet: Use `zcash_note_encryption` in `CWalletTx::DecryptSaplingNote` 2023-03-14 21:50:31 +00:00
Jack Grigg a95cd3db09 Add `CChainParams::RustNetwork`
The `zcashd` impl of `consensus::Parameters` is moved into a new
`params` module. It still uses the `cxx::bridge` in `wallet_scanner`
because `cxx` doesn't support Rust type aliases yet.
2023-03-14 21:42:54 +00:00
str4d 5829feed10
Merge pull request #6434 from softminus/better-errors
Give better error messages if proof parameters aren't loaded
2023-02-22 15:36:39 +00:00
sasha 0d2d64ee43 Better error messages if proof parameters aren't loaded 2023-02-16 13:51:27 -08:00
Jack Grigg d3a88bc332 Fix 1.67.1 clippy lints 2023-02-16 16:10:13 +00:00
Jack Grigg 9ce6753909 Retroactively enable ZIP 216 before NU5 activation
This completes the work started in zcash/zcash#6000.

Closes zcash/zcash#6396.
2023-02-02 22:48:00 +00:00
Charlie O'Keefe 251432966f
Merge pull request #6401 from nuttycom/version-5.4.0-back_merge
Back-merge version-5.4.0 changes to `master`.
2023-02-02 15:36:12 -07:00
Kris Nuttycombe db0d0deef8
Merge pull request #6385 from rex4539/typos
Fix typo
2023-02-01 07:02:58 -07:00
Kris Nuttycombe 192804a081 Merge branch 'version-5.4.0' into 'master' 2023-01-30 21:19:54 -07:00
Jack Grigg 0d1e1ad438 Fix return type of `orchard_wallet_reset`
Part of zcash/zcash#6386.
2023-01-31 00:28:30 +00:00
Dimitris Apostolou 4464f81061
Fix typo 2023-01-31 00:26:47 +02:00
Kris Nuttycombe aab58d308f Bound wallet batch scanner size to 1000 blocks instead of 100 MiB
1000 blocks was selected as a balance between limiting the likely
maximum memory usage of the batch scanner, and avoiding
artificially restricting scanning throughput of small/fast blocks
due to the second-boundary lock synchronization point.

This also removes the `zcashd.wallet.batchscanner.usage.bytes` gague
value that was previously made available when `-prometheusport` was
specified.

Co-authored-by: Jack Grigg <jack@z.cash>
2023-01-26 12:26:31 -07:00
Jack Grigg 817276c02f rust: Migrate `OrchardMerkleFrontier` to `cxx`
Closes zcash/zcash#6333.
2023-01-24 21:04:48 +00:00
Jack Grigg 908675b5b9 rust: Add `cxx` version of `RustStream` 2023-01-24 04:15:09 +00:00
Kris Nuttycombe 3cec519ce4 scripted-diff: Update Zcash copyrights to 2023
-BEGIN VERIFY SCRIPT-
for party in "The Zcash developers" "The Bitcoin Core developers" "Bitcoin Developers"; do
  sed -i"" -e "s#Copyright (c) \([0-9]\{4\}\)\(-[0-9]\{4\}\)\? $party#Copyright (c) \1-2023 $party#" COPYING
  sed -i"" -e "s#\(.*\)\([0-9]\{4\}\)\(-[0-9]\{4\}\)\, $party#\1\2-2023, $party#" contrib/debian/copyright
done

sed -i"" -e "s/define(_COPYRIGHT_YEAR, [0-9]\{4\})/define(_COPYRIGHT_YEAR, 2023)/" configure.ac
sed -i"" -e "s/#define COPYRIGHT_YEAR [0-9]\{4\}/#define COPYRIGHT_YEAR 2023/" src/clientversion.h

git grep "^// Copyright (c) .* The Zcash developers" \
  | awk -F ':' '{print $1}' \
  | xargs -I {} sed -i"" -e "s#// Copyright (c) \([0-9]\{4\}\)\(-[0-9]\{4\}\)\? The Zcash developers#// Copyright (c) \1-2023 The Zcash developers#" {}
-END VERIFY SCRIPT-
2023-01-23 11:31:54 -07:00
Jack Grigg 7cf42562d3 zcash_primitives 0.9 2023-01-11 00:56:29 +00:00
Jack Grigg 93de2aae0e Place zcashd.debug.* metrics behind a -debugmetrics config option 2022-11-21 20:50:02 +00:00
Daira Hopwood 1889a466ec Report the prevout for each transparent input as it is being checked
Author: Kris Nuttycombe <kris@nutty.land>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-10-29 18:46:58 +01:00
Kris Nuttycombe fd2cd0f02b Add extra detail related to transparent inputs and outputs. 2022-10-29 18:44:53 +01:00
Kris Nuttycombe 16c49a844e Fix clippy lints. 2022-10-20 08:35:29 -06:00
Kris Nuttycombe 741e6b1108 Update to released versions of librustzcash crates. 2022-10-20 08:35:29 -06:00
Jack Grigg b0d6abc45b wallet: Improve estimation of `rayon` spawned task size
Ported from zcash/librustzcash@035e53990c.
2022-09-26 22:19:33 +00:00
Jack Grigg 0e3fc36a47 wallet: Correctly track heap usage of batch items
As of zcash/librustzcash#633, `SaplingDomain::IncomingViewingKey` now
allocates memory internally, and this memory persists as long as the
`BatchRunner` is alive. Now that we have decoupled the measurement of
heap usage for batch tasks from their internals, we can add bounds to
all of the generic parameters of `Batch` to enable correctly measuring
their actual heap usage.

Ported from zcash/librustzcash@913aa0a988.
2022-09-26 22:19:33 +00:00
Jack Grigg 0ba43dc714 wallet: Move heap tracking of batch tasks behind a trait
This enables the heap usage measurements to be conditionally enabled by
the `BatchRunner` user. Importantly, when heap usage measurements are
not enabled, the `DynamicUsage` bound on `Batch` is not required.

This refactor also fixes a bug in the prior implementation. We were
counting the heap usage of a task when it started to run, but the item
may have been in the `rayon` work-stealing queues for a non-negligible
period before then. We now count the heap usage immediately before
spawning the task into the `rayon` thread pool.

Ported from zcash/librustzcash@c98f04330d.
2022-09-26 22:17:04 +00:00
Daira Hopwood 3139559ee9 Include memory usage of the `tags` vector.
This fixes *one* of the bugs pointed out by @str4d at
https://github.com/zcash/zcash/pull/6156/files#r979122874

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-09-24 03:00:35 +01:00
Daira Hopwood e57e799170 Use prepared epks and ivks in trial decryption.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-09-23 22:31:28 +01:00
Jack Grigg f3e52478d9 Fix clippy lints 2022-09-23 03:44:07 +00:00
Jack Grigg f7f6c2070d wallet: Only store successful trial decryptions in batch scanner
Previously we were sending an `Option<DecryptedNote>` from each `Batch`
back to its parent `BatchRunner`. However, this requires allocating
sufficient space in the channel to handle the case where every output
can be decrypted. In general this will not be the case, and we can
instead signal "nothing decrypted" by just dropping the channel sender.
This reduces the post-batch-scanning memory usage of `BatchRunner` from
being linear in the number of on-chain outputs, to being linear in the
number of outputs for the wallet.
2022-09-21 01:27:42 +00:00
Jack Grigg 7bb6ff38d9 wallet: Collect metrics on the number of scanned outputs 2022-09-21 01:27:42 +00:00
Jack Grigg e88ea11055 wallet: Add dynamic memory usage tracking to `BatchScanner` 2022-09-21 01:27:42 +00:00
Jack Grigg c21786c351 rust: Migrate Rust tests to latest `zcash_primitives` revision 2022-09-14 20:02:54 +00:00
Daira Hopwood fe5faf94f2 Update librustzcash commit and adapt to changes in `DiversifierKey`.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-09-14 19:39:20 +01:00
Jack Grigg b05b1dafa6 rust: Migrate to latest `zcash_primitives` revision 2022-09-14 18:20:20 +00:00
Kris Nuttycombe 3ef12e98c1 Replace manual mangement of the Sapling proving context with cxx
Co-authored-by: Jack Grigg <jack@z.cash>
2022-08-25 22:07:23 -06:00
Jack Grigg 2a21051fbe rust: `zcash-inspect` 32-byte hex as maybe a commitment or nullifier 2022-08-22 13:52:43 +00:00
Jack Grigg a0efb40632 rust: Add shielded sighash to `zcash-inspect` output for txs 2022-08-22 13:47:10 +00:00
Jack Grigg f21ba7a822 rust: Place tighter bound on encoded heights in `zcash-inspect`
From NU5, block heights are required to be encoded in the 32-bit
`nExpiryHeight` field, which places a bound on the maximum length of the
height encoded in a coinbase transaction.

Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-08-19 04:20:10 +00:00
Jack Grigg e530f6f30a rust: Simplify `next_pow2` in `zcash-inspect`
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-08-19 04:18:36 +00:00
Jack Grigg fd7cb4bb4a rust: Add mnemonic phrase inspection to `zcash-inspect` 2022-08-19 04:13:05 +00:00
Jack Grigg b0bf639760 rust: Add address inspection to `zcash-inspect` 2022-08-19 04:13:05 +00:00
Jack Grigg a125180a50 rust: Add P2PKH signature checking to `zcash-inspect`
Co-authored-by: ying tong <yingtong@z.cash>
2022-08-19 04:13:05 +00:00
Jack Grigg 8d82cee9c8 rust: Add `zcash-inspect` binary for inspecting Zcash data
Currently supports Zcash blocks, block headers, and transactions. Some
consensus rules are also checked, and a JSON context object can be
optionally passed to provide any necessary details for extra contextual
consensus checks.
2022-08-19 04:13:05 +00:00