Go to file
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
.cargo Update librustzcash commit and adapt to changes in `DiversifierKey`. 2022-09-14 19:39:20 +01:00
.github build: update book.yml 2022-09-19 12:24:18 +02:00
build-aux/m4 Partial revert of "Update links". See #4904 2020-12-17 01:42:03 +00:00
contrib script: Enable SC2001 rule for Gitian scripts 2022-08-20 03:15:12 +00:00
depends depends: Update Rust to 1.63.0 2022-08-11 15:51:57 +00:00
doc Update rust.md 2022-09-01 10:01:38 -07:00
qa Merge pull request #6132 from sellout/rpc-test-improvements 2022-08-22 16:06:50 -06:00
share Enable ShellCheck rules 2022-08-20 03:13:52 +00:00
src wallet: Refactor `ThreadNotifyWallets` to support batch memory limits 2022-09-21 01:27:42 +00:00
test/lint doc: Correct spelling errors in comments 2022-08-20 03:15:12 +00:00
zcutil Merge pull request #5617 from str4d/zcash-inspect 2022-08-22 17:24:59 +01:00
.editorconfig Define some basic cross-editor configuration 2022-08-17 09:44:03 -06:00
.gitattributes Separate protocol versioning from clientversion 2014-10-29 00:24:40 -04:00
.gitignore rust: Add `zcash-inspect` binary for inspecting Zcash data 2022-08-19 04:13:05 +00:00
CONTRIBUTING.md Link to development guidelines in CONTRIBUTING.md 2019-06-11 10:27:52 -05:00
COPYING COPYING: Address feedback about the use of "permissive". Also refer to zcashd instead of "Zcash". 2022-06-29 13:39:44 -06:00
Cargo.lock Update librustzcash commit and adapt to changes in `DiversifierKey`. 2022-09-14 19:39:20 +01:00
Cargo.toml Update librustzcash commit and adapt to changes in `DiversifierKey`. 2022-09-14 19:39:20 +01:00
INSTALL Typo Fix 2019-08-21 11:17:21 -04:00
Makefile.am Add an `rpc-tests` make target 2022-08-22 13:38:16 -06:00
README.md Apply suggestions from code review 2022-09-06 15:36:31 -06:00
SECURITY.md Rename responsible_disclosure.md to SECURITY.md 2021-02-18 23:38:32 +00:00
autogen.sh Enable ShellCheck rules 2022-08-20 03:13:52 +00:00
code_of_conduct.md Beef up the CoC to address use of dog-whistles. 2020-10-11 08:24:37 +01:00
configure.ac Merge pull request #6083 from zcash/leveldb-1.22 2022-08-10 18:14:43 -06:00
libzcash_script.pc.in Rename libzcashconsensus.la -> libzcash_script.la 2021-01-25 22:20:25 +00:00
rust-toolchain depends: Update Rust to 1.63.0 2022-08-11 15:51:57 +00:00

README.md

Zcash 5.2.0

What is Zcash?

Zcash is an implementation of the "Zerocash" protocol. Initially based on Bitcoin's design, Zcash intends to offer a far higher standard of privacy through a sophisticated zero-knowledge proving scheme that preserves confidentiality of transaction metadata. More technical details are available in our Protocol Specification.

The zcashd Full Node

This repository hosts the zcashd software, a Zcash consensus node implementation. It downloads and stores the entire history of Zcash transactions. Depending on the speed of your computer and network connection, the synchronization process could take several days.

The zcashd code is derived from a source fork of Bitcoin Core. The code was forked initially from Bitcoin Core v0.11.2, and the two codebases have diverged substantially.

🔒 Security Warnings

See important security warnings on the Security Information page.

Zcash is experimental and a work in progress. Use it at your own risk.

📒 Deprecation Policy

This release is considered deprecated 16 weeks after the release day. There is an automatic deprecation shutdown feature which will halt the node some time after this 16-week period. The automatic feature is based on block height.

Other Zcash Implementations

The Zebra project offers a different Zcash consensus node implementation, written largely from the ground up.

Getting Started

Please see our user guide for instructions on joining the main Zcash network.

Need Help?

  • 📘 See the documentation at the ReadTheDocs for help and more information.
  • 📨 Ask for help on the Zcash forum.
  • 💬 Join our community on Discord

Participation in the Zcash project is subject to a Code of Conduct.

Building

Build Zcash along with most dependencies from source by running the following command:

./zcutil/build.sh -j$(nproc)

Currently, Zcash is only officially supported on Debian and Ubuntu. See the Debian / Ubuntu build for detailed instructions.

License

For license information see the file COPYING.