Commit Graph

16825 Commits

Author SHA1 Message Date
Jack Grigg e88ea11055 wallet: Add dynamic memory usage tracking to `BatchScanner` 2022-09-21 01:27:42 +00:00
Jack Grigg 58d7eb0f2c wallet: Refactor `ThreadNotifyWallets` to support batch memory limits
ThreadNotifyWallets was created in order to decouple wallet scanning of
transactions from the main chain updates, avoiding timing leaks to
network peers. To further ensure that not even lock contention could be
used to extract timing information, ThreadNotifyWallets collects update
information from the main chain on integer second boundaries.

In general this means that the wallet is processing the last second's
worth of blocks between each synchronization point. However, when there
are sequences of blocks that are costly for the wallet to scan, it may
take the wallet longer than a second to process a second's worth of
blocks connected to the main chain. This means that ThreadNotifyWallets
needs to wait until the next integer second boundary before collecting
the next set of updates, which means it will be processing at least two
seconds' worth of blocks. For extended periods where the chain contains
many outputs, the wallet will get progressively further behind the main
chain.

At the time that ThreadNotifyWallets was created, the above behaviour
was fine, because while the wallet scanning process consumed a lot of
CPU time, it did not consume much memory (as blocks are stored on disk).
However, we recently added batch scanning, which requires allocating
memory for each output that is being scanned. For a wallet with a
growing gap between its scanned-to height and the chain tip height, the
size of the necessary allocation will grow with each integer second
boundary crossed, until the node reaches OOM.

The solution is to implement backpressure: if we reach a memory limit
before we've finished adding blocks to the batch scanners, then we start
consuming the results from the batch scanner to free up memory space for
subsequent batches.

This commit implements the logic necessary to interleave batch creation
and batch result consumption. It does not apply any batch memory limits,
and as such should be effectively a no-op refactor.

Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-09-21 01:27:42 +00:00
Jack Grigg 38e79f0b63 wallet: Use `auto&` to avoid copying inside `ThreadNotifyWallets`
We were (most likely) copying potentially large structures in places
where we only required references to the data, for the same reason as
the bug fixed in zcash/zcash#6169: in most cases, `auto` does not infer
a reference, causing assignments to `auto` variables to invoke the copy
constructor.

Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-09-19 21:30:53 +00:00
Daira Hopwood 4792b1730a
Merge pull request #6169 from daira/fix-implicit-orchard-bundle-clone
Avoid an implicit clone of the Orchard bundle in ContextualCheckTransaction
2022-09-19 22:27:37 +01:00
str4d 8ba5f6cc6f
Merge pull request #6170 from sashashura/patch-1
GitHub Workflows security hardening
2022-09-19 14:44:35 +01:00
Alex 9d4b6795c8 build: update book.yml
Signed-off-by: sashashura <93376818+sashashura@users.noreply.github.com>
2022-09-19 12:24:18 +02:00
Daira Hopwood 01e4c74739 Avoid an implicit clone of the Orchard bundle in ContextualCheckTransaction.
C++ `auto`, as opposed to `auto&`, does not infer reference types (except when it does:
https://blog.petrzemek.net/2017/12/08/when-auto-seemingly-deduces-a-reference-in-cpp/
but that doesn't apply here). The inferred type of `orchard_bundle` was therefore
`const OrchardBundle`. This made the assignment a call to `OrchardBundle::operator=`
which calls `orchard_bundle_clone`. A reference assignment is sufficient, because `tx`
is in scope throughout `ContextualCheckTransaction`.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-09-18 17:21:17 +01:00
Kris Nuttycombe 1ef254ca80
Merge pull request #6160 from str4d/migrate-to-latest-zcash_primitives
rust: Migrate to latest `zcash_primitives` revision
2022-09-14 18:32:16 -06: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
Daira Hopwood 8930cf44d3
Merge pull request #6155 from sellout/reindex-chainstate
Don't recommend -reindex-chainstate.
2022-09-13 12:34:53 +01:00
Greg Pfeil db1b4313c3 Don't recommend -reindex-chainstate.
As mentioned in #5964 and #5977, `-reindex-chainstate` is currently broken. This
removes it from error messages so that we don't suggest its use, but rather a
full `-reindex`.

This change should be reverted if/when those issues are fixed.
2022-09-12 11:28:51 -06:00
Kris Nuttycombe 50b5cdfec3
Merge pull request #6146 from nathan-at-least/improve-book-on-adding-rust-dependencies
`./doc/book/src/dev/rust.md`: Clarify docs for adding rust dependencies.
2022-09-10 11:09:09 -06:00
Daira Hopwood 0c76702f59
Merge pull request #6147 from nathan-at-least/readme-clarify-protocol-vs-zcashd
`README.md`: Clarify distinction between protocol vs zcashd implementation; link to Zebra; line wrapping.
2022-09-07 10:53:45 +01:00
Kris Nuttycombe 6f49cc709b
Apply suggestions from code review
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-09-06 15:36:31 -06:00
user ebac50aa24 README.md: Clarify distinction between protocol vs zcashd implementation; link to Zebra; line wrapping. 2022-09-02 10:15:34 -07:00
Nathan Wilcox b8ed6aaa99
Update rust.md 2022-09-01 10:01:38 -07:00
Kris Nuttycombe 294d96778a
Merge pull request #5953 from nuttycom/doc/reclaim_gitlab_docs
Restore documentation that had been moved to zcash.readthedocs.io
2022-09-01 09:42:34 -06:00
Daira Hopwood 2621efd0da
Update doc/book/src/user/security-warnings.md 2022-08-30 14:40:34 +01:00
Daira Hopwood a6c05f1a28
Apply suggestions from code review 2022-08-30 14:39:37 +01:00
Daira Hopwood bf2ad58114
Merge pull request #6140 from nuttycom/cxx_sapling_prover
Replace manual mangement of the Sapling proving context with cxx
2022-08-30 14:20:16 +01:00
str4d 2df8b253f7
Merge pull request #6141 from str4d/6065-rust-parallel-lib-and-bins
build: Build Rust library and binaries at the same time
2022-08-29 14:15:58 +01:00
Jack Grigg 5609706d9b build: Build Rust library and binaries at the same time
This enables `cargo` to parallelize the library and binary builds
internally, reducing the Rust build time by the build time of the
binaries (because they are overall faster than the library build).

Part of zcash/zcash#6065.
2022-08-29 11:27: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
Kris Nuttycombe d3e8b3b114
Merge pull request #6118 from sellout/canonical-paths
Canonicalize some user-provided paths
2022-08-25 16:11:34 -06:00
Kris Nuttycombe fbdfbae593 Move restored documentation into the zcashd book 2022-08-25 10:44:11 -06:00
Greg Pfeil 07d52d006e Backport tor.md changes from readthedocs
This is an separate from the other backporting because this was an upstream
document, so isolating it helps with future backports from upstream.
2022-08-25 10:44:11 -06:00
Kris Nuttycombe ad72a606c2 Backport changes from zcash.readthedocs.io 2022-08-25 10:44:11 -06:00
Kris Nuttycombe e9234ed50f Fix documentation line wrapping 2022-08-25 10:44:09 -06:00
Kris Nuttycombe ef07ba47bc Revert "redirect and update source documentation"
This reverts commit 70ebc0942a.
2022-08-25 10:29:54 -06:00
Greg Pfeil a5d1088683 Also canonicalize paramsdir. 2022-08-25 09:46:17 -06:00
Kris Nuttycombe f84a57e71b
Merge pull request #6106 from centromere/fix-compile-and-linker-errors
Fix compile and linker errors
2022-08-23 07:36:06 -06:00
Kris Nuttycombe e9b1d9d35f
Merge pull request #6114 from DeckerSU/fix-miner-maxsols
miner: fix MAXSOLS
2022-08-23 07:18:09 -06:00
Kris Nuttycombe da5fbfe747
Merge pull request #6132 from sellout/rpc-test-improvements
RPC test improvements
2022-08-22 16:06:50 -06:00
Greg Pfeil 6766e39ad1 Add simplejson to requirements for rpc-tests 2022-08-22 13:38:16 -06:00
Greg Pfeil 113d7a4840 Add an `rpc-tests` make target
This ensures that zcashd is up-to-date with any changes before running the
tests.
2022-08-22 13:38:16 -06:00
str4d 46d6636a68
Merge pull request #6131 from conradoplg/patch-1
Include algorithm.h in cuckoocache.h
2022-08-22 17:26:00 +01:00
str4d 520b58f632
Merge pull request #5617 from str4d/zcash-inspect
rust: Add `zcash-inspect` binary for inspecting Zcash data
2022-08-22 17:24:59 +01: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
Conrado Gouvea b49dc8a100
Include algorithm.h in cuckoocache.h 2022-08-22 10:46:32 -03:00
Kris Nuttycombe acacf64331
Merge pull request #6129 from str4d/backport-shell-lints
Backport shell lint changes
2022-08-20 09:04:16 -06:00
Ben Woosley dd84f66600 doc: Correct spelling errors in comments
And ci script output.

Identified via test/lint/lint-spelling

(cherry picked from commit bitcoin/bitcoin@9b0e16226e)

Zcash: Only the change to `test/lint/lint-shell.sh`
2022-08-20 03:15:12 +00:00
Hennadii Stepanov c23889a150 script: Enable SC2001 rule for Gitian scripts
(cherry picked from commit bitcoin/bitcoin@17f81e9648)
2022-08-20 03:15:12 +00:00
Hennadii Stepanov f620206f03 script: Enable SC2155 rule for Gitian scripts
Also pwd command is replaced with $PWD variable everywhere for
consistency.

(cherry picked from commit bitcoin/bitcoin@61bb21b418)
2022-08-20 03:15:12 +00:00
Hennadii Stepanov fa3abe8819 script: Enable SC2006 rule for Gitian scripts
(cherry picked from commit bitcoin/bitcoin@577682d9e8)
2022-08-20 03:15:12 +00:00
Jack Grigg 0f84499556 lint: Disable some ShellChecks on Gitian descriptors
These trigger because our Gitian descriptors are out-of-sync with
upstream.
2022-08-20 03:15:12 +00:00
Hennadii Stepanov 3cf26a1c4f script: Lint Gitian descriptors with ShellCheck
(cherry picked from commit bitcoin/bitcoin@14aded46df)

Zcash: Applies CI change to GitHub Actions workflow.
2022-08-20 03:15:12 +00:00
Jack Grigg 3dd142d605 lint: Fix ShellCheck lints in Zcash scripts 2022-08-20 03:15:12 +00:00