Build, test, contribute
1. Why this chapter exists
This is the chapter you return to every day. It documents the
toolchain, the test commands, the CI graph as mirrored locally, and
the PR compliance gate that gates every contribution to
zcash/librustzcash. Reading
the rest of the course teaches you the protocol; this chapter teaches
you how to ship a patch the maintainers will accept.
If you open a PR without satisfying the gate in section 4 it will be closed, regardless of how good the code is.
2. Definitions
Workspace (Cargo): a set of crates sharing a single
Cargo.toml at the repository root. See
Cargo.toml
for the member list (18 crates as of the discovery pin).
MSRV (Minimum Supported Rust Version): 1.85.1, pinned by
rust-toolchain.toml.
The toolchain file forces rustup to install this exact version, so
running cargo inside the repo gives you the same compiler the CI
uses.
cargo-vet: supply-chain auditing tool. The repository carries
audit metadata under
supply-chain/.
PRs that add or upgrade dependencies must update this metadata.
3. The code
3.1 Setup
rustup show # rustup auto-installs 1.85.1 per the toolchain file
cargo --version # cargo 1.85.x
cargo install cargo-vet # only if you touch dependencies
3.2 The local test loop
# Build every crate in the workspace.
cargo build --workspace --all-features
# Run unit + integration tests across the workspace.
cargo test --workspace --all-features
# Focused: a single crate.
cargo test -p zcash_client_sqlite
# Focused: a single test function.
cargo test -p zcash_primitives transaction::tests::roundtrip
3.3 Lint and format
cargo fmt --all -- --check
cargo clippy --workspace --all-features --all-targets -- -D warnings
The CI workflow
.github/workflows/ci.yml
runs the same commands on a build matrix. Reproducing CI locally
means running these four commands; if all four pass, the most common
CI failures are gone.
3.4 Other workflows
audits.ymlrunscargo vet. Any dependency change must updatesupply-chain/audits.tomlorsupply-chain/imports.lock.mutants.ymlrunscargo mutants. Mutation surviving the test suite is a hint the tests are weak.zizmor.ymllints the workflow files themselves for known CI-supply-chain pitfalls.
4. PR compliance gate (mandatory)
Read this verbatim. It comes from
AGENTS.md.
The gate applies to human contributors and AI agents alike.
Before opening a PR:
- Discuss the change on a GitHub issue first. Drive-by PRs are closed.
- Wait for a
librustzcashteam member to acknowledge the issue. An issue existing is not enough. The team must respond. - Link the issue from the PR description.
Additional rules from
CONTRIBUTING.md:
- Each crate has its own
CHANGELOG.md. User-facing changes require a changelog entry in the affected crate, in a dedicated commit. - The PR title should match the convention of recent merged PRs in
the same area; check
git log --onelineof the touched crate. - Sign commits with DCO if the repo requires it (
git commit -s).
5. Failure modes
- Skipping the issue gate. The PR will be closed without review. Trying to bypass by opening "draft" PRs counts as skipping.
- Bundling a changelog entry with the code change. Splits the reviewer's attention and breaks the rule above. Use two commits.
- Touching multiple crates in one PR without justification. Reviewers prefer small, single-crate PRs because the test surface is smaller.
- Forgetting
cargo vetafter adding a dependency. Theaudits.ymlworkflow fails and blocks merge. - Editing generated files (e.g.
supply-chain/imports.lock) by hand instead of regenerating them with the tool.
6. Spec pointers
AGENTS.md: the contribution gate and agent-facing policy. Read in full before the first PR.CONTRIBUTING.md: the human-facing contribution guide. Section "Coding Style" lists the rulescargo fmtandclippycannot catch.- Zcash R&D Discord
#librarieschannel: where to ask before opening the issue.
7. Hot files (last 6 months)
The 10 files that have seen the most churn are listed in
onboarding/discovery.md.
Summary:
zcash_client_backend/CHANGELOG.md(62 touches)supply-chain/imports.lock(59)zcash_client_sqlite/CHANGELOG.md(50)zcash_client_sqlite/src/wallet.rs(49)Cargo.lock(49)zcash_client_sqlite/src/lib.rs(38)components/eip681/src/parse.rs(36)zcash_transparent/CHANGELOG.md(33)zcash_primitives/CHANGELOG.md(31)zcash_client_backend/src/data_api/ll/wallet.rs(29)
The pattern: most contribution activity targets the wallet layer
(zcash_client_sqlite + zcash_client_backend) and the transparent
pool. If your goal is to ship a PR fast, find an open issue in those
areas, follow the gate, and you will land in a familiar review path.
8. Exercises
- Clone the repository fresh, run
cargo build --workspace --all-features, and report the total build time on your machine. Compare with theci.ymlmatrix; identify which target your machine matches. - Pick a single test in
zcash_client_sqliteand reproduce it with the focused-test command from section 3.2. Modify the assertion so it fails, re-run, then restore. The goal is to confirm your test loop is wired. - Open the
issuestab and find an open issue labelled "good first issue" (or, if none, any small open issue). Write down which chapter of this course prepares you to solve it. - Read
CONTRIBUTING.mdfront to back. Then re-read section 4 above and confirm in your own words how the issue + ack rule applies to a one-line typo fix.
Answers in the code
- Build time: depends on machine; the GitHub Actions runners take ~25 minutes for the full matrix.
- Focused-test pattern:
cargo test -p <crate> <module>::<test>per section 3.2. - Good first issues: filtered list at https://github.com/zcash/librustzcash/labels/good%20first%20issue.
- Typo rule: the gate applies. Even a typo fix should reference an
issue. The maintainers' reasoning is in
AGENTS.mdunder "MUST READ FIRST".
9. Further reading
- The Cargo Book - Workspaces to understand the workspace dependency surface.
- cargo-vet documentation for the supply-chain auditing model used here.