← All calls
ARBORIST#36

Moving zcash_script to zcashd

A proposal to move the zcash_script crate into the zcashd repository and the cause of sync memory spikes were discussed.

Agenda summary 5

  1. Zebra beta.15 release

    Zcash Foundation · Teor

    • beta.15 focused on sync and RPC performance improvements. Reads of cached state that used to block now run in parallel, which helps users running it as a lightwalletd backend and some sync situations.
    • While preparing the release candidate, the team started building a Docker binary image for releases. The network API was changed to return more peer metadata, and ECC showed interest in using it for the DNS seeder.
    • There is a breaking change for lightwalletd backend users. Multi-threaded RPC must be turned on directly in configuration; turning it on disables the port conflict check, so multiple instances can run on the same port, which is why it is not the default.
    • A release candidate means lightwalletd support and the NU5 consensus rules are ready for final testing and audit. It has not yet been audited, so it is not a stable release.
  2. Zcashd update - mobile SDK and memory optimization

    Electric Coin Company · Steven

    • The top priority is fast sync for the mobile SDK used by Edge, Unstoppable and Nighthawk. Sync improvements will be released in two or more SDK updates.
    • The first update includes unified address support and incremental sync improvements. This is because it was easier to layer the sync work on top of the UA work already done for NU5 support.
    • The team reproduced internally the phenomenon of memory spiking during sync and causing OOM, and found three memory-saving optimizations. The third is in final testing, and the remaining performance improvements will be bundled into a release after 5.3.0.
  3. Fee change - ZIP 317 principles and next steps

    Electric Coin Company · Steven, Nate, Daira

    • Steven presented three principles of fee design: they must be fair and consistent regardless of the number of transactions or the composition of inputs and outputs, must not have unnecessary impact on ordinary small payments, and must take UX into account as well.
    • They pointed out a UX problem: input notes are hard for users to control, so whether someone holds the same 10 ZEC as one note or as 1000 notes of 0.1 ZEC, the number of inputs can grow unexpectedly.
    • In Greg's on-chain analysis, a considerable share of transparent transactions came out below the threshold when ZIP 317 fees were applied. Because the parameters are hardcoded, too low has no effect and too high could hurt adoption.
    • As next steps, the team will ask wallet vendors about the possibility of adopting the change and find out how many wallets do Bitcoin-style fee increases. A proposal was also made to collect feedback through staged rollout before enforcement.
    • Daira said there was major progress on documentation issues and cleaning up the formula at Wednesday's ZIP sync, and a PR reflecting this was posted to Aditya's branch.
  4. Root cause analysis of the zcashd wallet sync memory issue

    Electric Coin Company · Str4d, Daira, Steven

    • In 5.2.0 batch parallel trial decryption was added, but the wallet update thread fetched updates at whole-second boundaries, so when wallet scanning was slower than chain scanning, the wallet tip kept falling behind the node tip.
    • Batch scanning put all the data into the batch at once, which raised memory load and led to OOM over time. The team implemented manual backpressure that puts in data only up to a memory threshold and interleaves the rest.
    • A bigger cause was returning 600 to 700 bytes as an Option for every output that failed to decrypt. Memory was proportional to the number of on-chain outputs.
    • It was fixed to send a value only on success and signal failure implicitly by closing the channel's sender, so the memory spike occurs only during decryption and disappears afterward.
    • As a side effect, metrics for batch scanner throughput and memory, the chain tip sync point and the wallet scan height were added to zcashd. Steven praised Str4d and Daira for finding the cause with heap trace files.
  5. Discussion of maintaining the zcash_script crate

    Zcash Foundation · Conrado, Daira, Str4d, Teor, Nate

    • Conrado explained that zcash_script, which Zebra uses for transparent signature verification, wraps zcashd's C++ code and requires copying the source, so it has to be kept in step with each zcashd dependency update.
    • The alternative is to move the crate into the zcashd repository. Options are to keep the existing build.rs and cc::Build or to integrate it into zcashd's build system, and the latter raises a concern about growing build dependencies.
    • Str4d said distributing libzcash_script as a static library is hard because it requires builds for every target. They suggested a hybrid that copies the source and pulls in only build.rs changes.
    • Daira said dependency versions must be pinned for consensus compatibility. They also said a long-term plan to remove Bitcoin-style script is needed, and Str4d said removing the transparent pool would make this easier.
    • On Nate's question about separating script, Str4d answered that it is very entangled and hard. Teor said that moving it to the zcashd repository would let CI verify updates.
    • Conrado said to create a WIP PR moving it into the zcashd repository while keeping the build system, as Str4d suggested. Str4d said Rust 1.64's workspace common dependency feature would help.

This summary is based on the original meeting notes; check them for exact details.