This guide covers the development workflow, coding standards, and verification commands used across the project.
- Use the current stable Rust toolchain (Rust 2024 edition).
- Install C/C++ build tools (C++17 compiler such as
g++),clang,libclang-dev, andcmakefor native dependencies (RocksDB and bundled ZeroMQ). The default binary excludeslibbitcoinkernel, but RocksDB and ZeroMQ require native build tooling. - Kernel-enabled checks additionally require Boost headers
(
libboost-devon Debian/Ubuntu). No manifest enableskernelby default: the feature is an opt-in capability on the consensus, script, chainstate, node, and binary crates, and engine selection is the runtimevalidation.enginesetting. The exact defaults are owned by the validation-default contract.
From the repository root, install and select stable:
rustup toolchain install stable --component rustfmt --component clippy
rustup override set stable
cargo install --locked cargo-deny
cargo install --locked cargo-nextest --version 0.9.151 # optional: speeds the test lanes up; ci-pr.sh falls back to cargo testrust-toolchain.toml, CI, pre-commit hooks, and the
local commands above all select stable. Explicit +nightly commands below are
limited to checks that require nightly Rust.
Start with the affected package or test while developing, then run the applicable CI checks before submitting. The workflow files define the complete job set.
.depot/workflows/ci.yml runs for pull requests
against any base branch (including stacked PRs), on merge-group requests, and
for pushes to main. PR green is fast feedback only: fmt, deny,
contracts, clippy, and test-crates passed while book, test-binary,
and test-workspace are skipped. Merge-group green adds those three heavy
lanes as the pre-main integration signal; main checks are post-merge
evidence. Every lane fails fast at its first failing profile. Every gate
command lives in scripts/ci-pr.sh, which CI, the
pre-commit hooks, and this guide all invoke:
./scripts/ci-pr.sh fmt # format check
./scripts/ci-pr.sh clippy [lane] # kernel-free Clippy profiles, optional lane: services, node-runtime
./scripts/ci-pr.sh test-crates [lane] # per-crate profiles, optional lane: silent-payments, storage, consensus-chain, node-wire
./scripts/ci-pr.sh test-binary # binary profile
./scripts/ci-pr.sh test-workspace # workspace kernel-free pass
./scripts/ci-pr.sh test # every test lane in sequence, smallest first
./scripts/ci-pr.sh deny # full dependency graph, metadata only
./scripts/ci-pr.sh contracts # contract index drift check
./scripts/ci-pr.sh book # book build and link check
./scripts/ci-pr.sh deep # every profile, collecting all failures
./scripts/ci-pr.sh all # fmt + deep + deny + contractsIn CI the test lanes run under cargo-nextest's pooled scheduler and link
with mold (.github/actions/test-deps installs both); where nextest is not
installed the script falls back to cargo test --no-fail-fast, so local
runs and hooks need no extra tooling.
Plain cargo test --workspace and cargo clippy --workspace also enable the
library defaults, which are now kernel-free (the kernel feature is an opt-in
capability; the engine a run uses is validation.engine at runtime), so plain
workspace commands need no kernel toolchain. The script passes the kernel-free
feature selection. The mandatory default RocksDB storage engine still requires
a C++ toolchain, even for kernel-free commands. The binary and workspace test
lanes expect the
pinned Core fixture:
bash scripts/provision-ci-reference-fixtures.sh core.
Formal evidence has its own lane: provision with
bash scripts/provision-ci-reference-fixtures.sh formal, then run
python3 scripts/check_models.py. A --check-only invocation checks custody,
not model properties.
The pre-commit configuration runs the same script, so local hooks are the kernel-free PR gate, not the C++ full-node lane.
All merges to dev must pass through the GitHub merge queue. Direct merges
bypassing the queue are disallowed for standard pull requests.
The merge queue enforces the integration contract on the latest combined ref
(merge_group) before updating dev:
- PR green (
pull_request): Fast feedback only.ci-gaterequiresfmt,deny,contracts,clippy, andtest-crates;book,test-binary,test-workspace, and kernel/native checks are skipped to keep feedback fast (<3 min). - Merge-group green (
merge_group): Pre-dev integration eligibility.deep-gateindeep.ymlrequires thetestsmatrix (test-binary,test-workspace),book, andkernel(consensus kernel clippy with kernel-oracle parity, plus full-node kernel clippy);ci-gatekeeps requiring the PR lane. - Main green (
push): Post-merge historical evidence. Pushes tomainrun the extended campaigns and reference verifications indeep.yml.
Depot CI owns same-repository pull requests, merge groups, main pushes,
compatibility schedules, and manual validation runs. GitHub Actions runs
the fork pull-request fallback in
.github/workflows/ci.yml. Both paths use only
explicit depot-ubuntu-24.04 runner sizes and keep the same validation
commands. Their pull-request conditions do not overlap.
GitHub Actions also owns Pages publication, which uses the github-pages
environment, and the daily fuzz campaign, which publishes to the separate
corpus repository with FUZZ_CORPUS_TOKEN. Both use Depot runners. Keep
these publication permissions separate from read-only validation.
.depot/workflows/ci.yml publishes the ci-gate
aggregate job: it needs lint, fuzz, template-provider, and lane, fails
unless lint and lane succeed, and accepts fuzz and template-provider
as success or skipped because both are event-gated to pull requests and
manual runs (on pull requests their jobs return early success when the
touched paths do not match).
.depot/workflows/deep.yml publishes the
deep-gate aggregate job: it needs tests, book, kernel, and pinned,
requires the first three to succeed, and accepts pinned as success or
skipped because it is event-gated.
The repository rulesets do not currently require these gates by name. The
remaining owner step is requiring ci-gate on pull requests and deep-gate
with kernel on the merge queue; deep.yml never runs on pull requests, so
its jobs cannot be required as pull-request checks.
.depot/workflows/deep.yml runs kernel-enabled
tests and the main-only verification lanes. It triggers on pushes to main and
on manual dispatch. The lanes are bench smoke, native-script evidence, the
kernel oracle, and Core differential. Bench smoke
includes the witness-activation kernel regression and the SegWit-v0 kernel
oracle.
Pull-request-triggered checks are defined in
.depot/workflows/ci.yml. The fuzz
and template-provider jobs start on every pull request and on manual
dispatch; on pull requests each validation step is path-gated and also
covers shared workspace and crate manifests, while manual dispatch runs
every step.
Compiles with the mandatory default RocksDB storage engine and the
libbitcoinkernel verification oracle (requires cmake and libboost-dev):
cargo test -p bitcoin-rs --no-fail-fast \
--features "kernel"
cargo clippy -p bitcoin-rs --all-targets \
--features "kernel" -- -D warnings
cargo clippy -p bitcoin-rs-node --all-targets --features kernel -- -D warnings
cargo clippy -p bitcoin-rs-consensus --all-targets --features kernel -- -D warnings# Run deterministic consensus vectors
cargo test -p bitcoin-rs-consensus --no-fail-fast -- --include-ignored
# Run differential kernel parity verification (requires kernel feature)
cargo test -p bitcoin-rs-consensus --features kernel \
--test suite -- kernel_block_parity:: kernel_boundary_parity:: kernel_vector_parity:: --nocaptureThe tests in all three parity modules are not ignored. Passing --ignored
would skip them rather than run the oracle checks.
The bench-smoke job in main.yml installs the native prerequisites and runs
the witness-activation kernel regression plus the SegWit-v0 kernel oracle with
retained diagnostics.
Fuzz targets live under fuzz/ and run against imported corpora:
# Install the fuzz toolchain and runner if not present
rustup toolchain install nightly
cargo install cargo-fuzz
# Run a target (options: p2p_message, block_validate, tx_validate, script_eval, utxo_snapshot)
cargo +nightly fuzz run block_validate --target x86_64-unknown-linux-gnu -- -runs=10000ci.yml compiles every fuzz
target on pull requests that touch fuzz/** or any Cargo.toml; the scheduled campaign is defined in
.github/workflows/daily-fuzz.yml. See
fuzz/README.md for local fuzzing, the
campaign automation,
and the companion corpus repository.
Prove the declared ranges, not only the committed lockfile
(docs/contracts/dependency-range.md):
This lane changes Cargo.lock. Run it in a disposable checkout, with nightly
and kernel build dependencies installed:
# Oldest allowed direct-dependency versions (nightly, mutates Cargo.lock)
scripts/check-dep-range.sh minimal
# Newest versions still inside each declared range (mutates Cargo.lock)
scripts/check-dep-range.sh maximumThe original Cargo.lock is restored on exit unless KEEP_LOCK=1.
Each lane also runs cargo deny check bans against the mutated lockfile.
Optional native storage backends are owned by the named feature matrix, not
this script.
CI runs these endpoints in the scheduled/manual
scheduled.yml.
Live observable-behavior check against a pinned Core 31.1 bitcoind
(docs/contracts/core-differential.md,
reproduction details in docs/validation-tooling.md):
cargo build --locked -p bitcoin-rs --profile quickstart --features zmq
scripts/run-p2p-core-interop.sh \
--bitcoind-command "$(scripts/install-bitcoind.sh --print-path)" \
--bitcoin-rs-command target/quickstart/bitcoin-rsThe supported combinations are the rows in
scripts/feature-matrix.tsv, not a feature powerset:
scripts/check-feature-matrix.sh # every row (needs cmake/libboost for kernel)
scripts/check-feature-matrix.sh pure # kernel-free and C++-engine-free crate rowsCI runs the matrix and the MSRV gate in the scheduled/manual
scheduled.yml.
Read AGENTS.md, the relevant issue or PR, and the owning contract before changing a subsystem. The architecture contract owns the five-layer crate assignments, dependency direction, storage isolation, and their verification gate. The validation-default contract owns script-engine selection and its promotion criteria.
Keep implementation guidance with its owner instead of adding another architecture or validation specification here.
Follow the source and test organization policy when adding or reorganizing modules, tests, and fixtures.
External BIP authors and implementers are welcome to propose, prototype, and
implement BIP-based capabilities in bitcoin-rs. The
BIP adoption policy governs evaluation and
lifecycle decisions; contributors can follow this lightweight path:
- Propose: Open an ordinary GitHub issue (or join an existing discussion) with a link to the BIP or pinned draft revision, the intended node-facing use case, and an initial validation or interoperability idea. Non-consensus BIPs are explicitly welcome before Bitcoin Core merges or ships them; a Core merge is not a prerequisite for proposing or exploring an idea here.
- Experiment: Small, reversible, opt-in (default-off) implementation PRs are welcome. State which existing crate and state owner the implementation extends, and provide the first bounded proof (such as reference vectors, codecs, or a regtest prototype). Full production interoperability evidence is not required just to explore or merge an isolated experiment.
- Validate and promote: Merging an experimental implementation is distinct
from declaring production or
Shippedcompatibility. Promotion requires the policy's stronger external-consumer evidence, sync safety, and measured resource costs. Review is grounded in consensus invariance, synchronization safety, clean ownership, and bounded overhead, not whether Core accepted the idea first.
This workflow is intentionally lightweight: there is no separate BIP registry,
governance committee, scorecard, mandatory proposal template, or custom CI gate.
See docs/policies/bip-adoption.md for detailed
lifecycle criteria and docs/bip-support.md for the
current coverage map.
- Commit style: capitalized imperative subject line under 72 characters (for example,
Own Bitcoin protocol primitives natively). - Commit body: explain what changed and why. Include relevant issue numbers in footers (
Closes #NorFixes #N). - Atomic changes: keep commits self-contained and bisectable; the workspace should compile and pass tests at each step.
- Tests first: bug fixes should include regression tests proving the defect is resolved.
The project boundary is stable external contracts and replaceable internal architecture. Internal breaking changes are acceptable with a clear rationale. Breaking a supported external contract is a regression. Reviewers evaluate these questions for a change that reshapes internals:
- External contract preserved? Consensus, P2P, and every affected supported external API keep observable behavior, proven with the regression, differential, or black-box evidence the owning contract names.
- Better internals? A concrete improvement, clearer ownership, simpler boundaries, reduced duplication, measurable performance, or more reliable recovery, with its migration/resync and operational cost assessed.
- No compatibility debt without a requirement? No legacy adapters, dual paths, migration layers, or dead internal interfaces kept solely to avoid an intentional internal break.
- Fail safely? Durable-format changes keep explicit format gates, crash consistency, and fail-closed recovery; external contracts do not regress.
A breaking change is permitted, not a goal. The more aggressively internals are redesigned, the stronger the external validation evidence must be.
- docs/README.md: documentation index
- docs/contracts/README.md: normative architectural and protocol contracts
- docs/validation-tooling.md: validation tooling and differential evidence lanes
- docs/getting-started.md: node setup and configuration
- CONSTRAINTS.md: repository-wide project invariants
- CONCEPTS.md: domain terminology and concepts
Documentation follows the ownership policy. Keep requirements with their enforcing owners, and keep current execution evidence with CI or the PR.