v30.3-roots.1 · Commit 12: [PATCH 12/68] release: add pre-tag artifact rehearsal
AGENTS.md
Before: /dev/null · After: AGENTS.md
File metadata
new file mode 100644 index 0000000000000000000000000000000000000000..a593ae772cc2b58b690cc1a406bce164d8abca91
Download original patch · Release notes
Diff rows 1–400 of 472. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.
AGENTS.md
ADDED
|
@@ -0,0 +1,472 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AGENTS.md
|
| 2 |
+
|
| 3 |
+
This file is the operational guide for AI agents working in this repository. It
|
| 4 |
+
applies to the whole tree unless a more specific `AGENTS.md` is added below it.
|
| 5 |
+
|
| 6 |
+
## Project identity and non-negotiable invariants
|
| 7 |
+
|
| 8 |
+
This repository is **Bitcoin Roots**, not an unmodified Bitcoin Core or Bitcoin
|
| 9 |
+
Knots checkout. It is a C++20 full-node, wallet, GUI, and utility suite based directly on
|
| 10 |
+
Bitcoin Core v30.3, with selected historical policy features inherited from Bitcoin Knots
|
| 11 |
+
`29.3.knots20260507`.
|
| 12 |
+
|
| 13 |
+
Read `README.md` before changing behavior. In particular:
|
| 14 |
+
|
| 15 |
+
- Bitcoin Roots stays compatible with Bitcoin Core consensus.
|
| 16 |
+
- Conservative transaction relay and mempool policy is intentional and
|
| 17 |
+
configurable. A transaction rejected by local policy can still be valid by
|
| 18 |
+
consensus; blocks containing it must remain acceptable.
|
| 19 |
+
- This revision deliberately does **not** enforce RDTS/BIP110 consensus rules.
|
| 20 |
+
Do not add, imply, or silently enable those rules, and do not confuse the
|
| 21 |
+
startup warning/consent code with consensus enforcement.
|
| 22 |
+
- Consensus, validation, serialization, wallet, networking, and cryptographic
|
| 23 |
+
changes are security-critical. Make the smallest justified change and add
|
| 24 |
+
regression coverage. Never “clean up” consensus-adjacent code incidentally.
|
| 25 |
+
|
| 26 |
+
Much of `doc/`, comments, scripts, and test output still uses the inherited
|
| 27 |
+
names “Bitcoin Core” or “Bitcoin Knots.” Do not mass-rebrand this text. Determine
|
| 28 |
+
whether a name is a historical/upstream reference, a protocol compatibility
|
| 29 |
+
identifier, or user-facing Roots branding before changing it. The current
|
| 30 |
+
`doc/release-notes.md` is inherited and contains RDTS migration language that is
|
| 31 |
+
not an authoritative statement of Roots policy. For fork identity and policy,
|
| 32 |
+
prefer, in order: current source behavior and tests, root `README.md`, current
|
| 33 |
+
build configuration, then inherited documentation.
|
| 34 |
+
|
| 35 |
+
## Repository map
|
| 36 |
+
|
| 37 |
+
- `src/`: production C++ and internal libraries.
|
| 38 |
+
- `bitcoind.cpp`, `bitcoin-cli.cpp`, `bitcoin-tx.cpp`, `bitcoin-util.cpp`, and
|
| 39 |
+
`bitcoin-wallet.cpp` are command-line entry points.
|
| 40 |
+
- `qt/` contains the `bitcoin-qt` GUI and GUI tests.
|
| 41 |
+
- `node/` owns P2P/RPC server orchestration and node-specific behavior.
|
| 42 |
+
- `kernel/` is the validation/consensus engine being separated from the node.
|
| 43 |
+
- `consensus/`, `script/`, `primitives/`, and much of `validation.cpp` are
|
| 44 |
+
consensus-sensitive.
|
| 45 |
+
- `policy/` and mempool code define local admission, relay, and mining policy;
|
| 46 |
+
policy must not leak into block-validity decisions.
|
| 47 |
+
- `wallet/` contains wallet databases, coin selection, signing, and wallet RPC.
|
| 48 |
+
- `rpc/` contains non-wallet RPC implementations; `interfaces/` contains
|
| 49 |
+
abstract boundaries between node, wallet, and GUI.
|
| 50 |
+
- `common/` is higher-level shared application code; `util/` is lower-level,
|
| 51 |
+
broadly reusable platform/support code; `crypto/` is standalone primitives.
|
| 52 |
+
- `index/`, `zmq/`, `ipc/`, `init/`, and `logging/` are feature-focused areas.
|
| 53 |
+
- `test/`, `wallet/test/`, and `qt/test/` contain C++ unit tests.
|
| 54 |
+
- `test/functional/`: Python integration tests that launch isolated regtest
|
| 55 |
+
nodes and drive RPC/P2P behavior. `test_framework/` is their shared harness.
|
| 56 |
+
- `test/lint/`: repository lint checks; its runner is a Rust crate.
|
| 57 |
+
- `test/fuzz/` and `src/test/fuzz/`: fuzz runner and C++ fuzz targets.
|
| 58 |
+
- `cmake/`, root `CMakeLists.txt`, and `src/**/CMakeLists.txt`: the primary build
|
| 59 |
+
system. This tree no longer uses Autotools for the main build.
|
| 60 |
+
- `depends/`: reproducible pinned third-party dependency builder, used for
|
| 61 |
+
release and cross builds.
|
| 62 |
+
- `ci/` and `.github/workflows/`: canonical CI configurations. CI intentionally
|
| 63 |
+
exercises different feature/compiler/platform combinations.
|
| 64 |
+
- `contrib/`: developer, packaging, tracing, deployment, and maintenance tools.
|
| 65 |
+
- `doc/`: build, runtime, interface, design, and contributor documentation.
|
| 66 |
+
- `share/`: example configuration, desktop integration, icons, and RPC auth tool.
|
| 67 |
+
|
| 68 |
+
Embedded `src/secp256k1`, `src/leveldb`, `src/crc32c`, `src/crypto/ctaes`, and
|
| 69 |
+
`src/minisketch` are maintained as upstream subtrees. Avoid direct cosmetic or
|
| 70 |
+
cross-cutting edits there. Fix upstream when possible and use
|
| 71 |
+
`test/lint/git-subtree-check.sh` when intentionally updating a subtree.
|
| 72 |
+
|
| 73 |
+
### Library boundaries
|
| 74 |
+
|
| 75 |
+
Follow `doc/design/libraries.md`. The important dependency direction is:
|
| 76 |
+
|
| 77 |
+
- `crypto` has no internal dependencies.
|
| 78 |
+
- `consensus` depends only on `crypto`.
|
| 79 |
+
- `util` depends only on `crypto` and must remain suitable for kernel users.
|
| 80 |
+
- `common` depends only on `util`, `consensus`, and `crypto`.
|
| 81 |
+
- `kernel` depends only on `util`, `consensus`, and `crypto`; internally only
|
| 82 |
+
`node` should depend on `kernel`.
|
| 83 |
+
- Node, wallet, and GUI implementations must not link directly to one another.
|
| 84 |
+
Communicate through abstract types in `src/interfaces/`.
|
| 85 |
+
|
| 86 |
+
When adding production C++ files, add them to the appropriate library target in
|
| 87 |
+
`src/CMakeLists.txt` or the nearest feature `CMakeLists.txt`. When adding a unit
|
| 88 |
+
test file, register it in `src/test/CMakeLists.txt`,
|
| 89 |
+
`src/wallet/test/CMakeLists.txt`, or `src/qt/test/CMakeLists.txt`.
|
| 90 |
+
|
| 91 |
+
## Toolchain and dependencies
|
| 92 |
+
|
| 93 |
+
The minimums documented by this checkout are CMake 3.22, Python 3.10, GCC 11.1
|
| 94 |
+
or Clang 16, Boost 1.74, and libevent 2.1.8. The code is compiled as C++20.
|
| 95 |
+
The default build is `RelWithDebInfo` (`-O2 -g` on typical Unix compilers).
|
| 96 |
+
|
| 97 |
+
Minimal Debian/Ubuntu setup for a headless descriptor-wallet build:
|
| 98 |
+
|
| 99 |
+
```bash
|
| 100 |
+
sudo apt-get install build-essential cmake pkgconf python3 \
|
| 101 |
+
libevent-dev libboost-dev libsqlite3-dev capnproto libcapnp-dev
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
Common optional packages are `python3-zmq`, `libzmq3-dev`,
|
| 105 |
+
`libminiupnpc-dev`, `systemtap-sdt-dev`, `libqrencode-dev`, and Qt development
|
| 106 |
+
packages. See `doc/build-unix.md` and `doc/dependencies.md` for the current full
|
| 107 |
+
list and the macOS/BSD/Windows-specific documents under `doc/` for those hosts.
|
| 108 |
+
|
| 109 |
+
Descriptor wallets use SQLite and are enabled by default. Core 30.3 does not
|
| 110 |
+
build Berkeley DB legacy wallets. Migration tests use pinned previous-release
|
| 111 |
+
fixtures where needed. A node-only build avoids the wallet database with
|
| 112 |
+
`-DENABLE_WALLET=OFF`.
|
| 113 |
+
|
| 114 |
+
Do not install dependencies or run package-manager commands without user
|
| 115 |
+
authorization. Prefer reporting the exact missing dependency. The `depends/`
|
| 116 |
+
system is the source of pinned release dependencies and toolchain files; read
|
| 117 |
+
`depends/README.md` before using it.
|
| 118 |
+
|
| 119 |
+
## Configure and build
|
| 120 |
+
|
| 121 |
+
Always build out of source. The conventional directory is `build/`:
|
| 122 |
+
|
| 123 |
+
```bash
|
| 124 |
+
cmake -B build
|
| 125 |
+
cmake --build build -j 4
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
Use a conservative fixed `-j` value on memory-limited hosts; compilation needs
|
| 129 |
+
roughly 1.5 GiB or more and highly parallel C++ builds can exhaust RAM. Inspect
|
| 130 |
+
available configuration switches with `cmake -B build -LH`.
|
| 131 |
+
|
| 132 |
+
Useful configurations:
|
| 133 |
+
|
| 134 |
+
```bash
|
| 135 |
+
# Debug symbols, assertions, lock-order and lock-contention instrumentation
|
| 136 |
+
cmake -B build-debug -DCMAKE_BUILD_TYPE=Debug
|
| 137 |
+
|
| 138 |
+
# Headless node without wallet or GUI dependencies
|
| 139 |
+
cmake -B build-node -DENABLE_WALLET=OFF -DBUILD_GUI=OFF
|
| 140 |
+
|
| 141 |
+
# GUI (Qt 6 by default; use -DWITH_QT_VERSION=5 for optional Qt 5)
|
| 142 |
+
cmake -B build-gui -DBUILD_GUI=ON
|
| 143 |
+
|
| 144 |
+
# Treat warnings as errors for CI-like compilation
|
| 145 |
+
cmake -B build -DWERROR=ON
|
| 146 |
+
|
| 147 |
+
# Generate compile_commands.json for tooling
|
| 148 |
+
cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
+
The `dev-mode` preset enables nearly every optional target and dependency and
|
| 152 |
+
uses `build_dev_mode/`; it is useful only when those dependencies are installed:
|
| 153 |
+
|
| 154 |
+
```bash
|
| 155 |
+
cmake --preset dev-mode
|
| 156 |
+
cmake --build build_dev_mode -j 4
|
| 157 |
+
```
|
| 158 |
+
|
| 159 |
+
Native Core IPC/libmultiprocess support is retained. Use `-DENABLE_IPC=OFF`
|
| 160 |
+
for a deliberately limited profile when Cap'n Proto is unavailable; do not
|
| 161 |
+
claim that profile proves IPC functionality. Treat the generated CMake summary
|
| 162 |
+
as truth when checking which optional components a preset enables.
|
| 163 |
+
|
| 164 |
+
Build only the target needed during iteration, for example:
|
| 165 |
+
|
| 166 |
+
```bash
|
| 167 |
+
cmake --build build --target bitcoind -j 4
|
| 168 |
+
cmake --build build --target test_bitcoin -j 4
|
| 169 |
+
cmake --build build --target bitcoin-qt -j 4
|
| 170 |
+
```
|
| 171 |
+
|
| 172 |
+
Binaries are emitted under `build/bin/`. Installation is optional:
|
| 173 |
+
`cmake --install build`. Never install system-wide unless explicitly requested.
|
| 174 |
+
|
| 175 |
+
## Running safely
|
| 176 |
+
|
| 177 |
+
Use regtest and a disposable, explicit data directory for development. Never
|
| 178 |
+
point tests or experimental builds at a user's real mainnet wallet/datadir.
|
| 179 |
+
|
| 180 |
+
```bash
|
| 181 |
+
build/bin/bitcoind -regtest -datadir=/absolute/path/to/disposable-dir \
|
| 182 |
+
-daemon -fallbackfee=0.0002
|
| 183 |
+
build/bin/bitcoin-cli -regtest -datadir=/absolute/path/to/disposable-dir \
|
| 184 |
+
getblockchaininfo
|
| 185 |
+
build/bin/bitcoin-cli -regtest -datadir=/absolute/path/to/disposable-dir stop
|
| 186 |
+
```
|
| 187 |
+
|
| 188 |
+
By default the data directory is `~/.bitcoin` on Linux,
|
| 189 |
+
`~/Library/Application Support/Bitcoin` on macOS, and `%LOCALAPPDATA%\Bitcoin`
|
| 190 |
+
on Windows. Chain state is below `regtest/`, `signet/`, `testnet3/`, or
|
| 191 |
+
`testnet4/`; `bitcoin.conf` is normally at the datadir root. Command-line values
|
| 192 |
+
override configuration values. Do not edit `settings.json` while the program is
|
| 193 |
+
running; changes may be ignored or overwritten.
|
| 194 |
+
|
| 195 |
+
`bitcoind -help` is the authority for options in the built revision. RPC help is
|
| 196 |
+
available through `bitcoin-cli help [command]`. Prefer graceful shutdown via
|
| 197 |
+
the `stop` RPC and wait for the process to exit before reusing a datadir.
|
| 198 |
+
|
| 199 |
+
## Testing and validation
|
| 200 |
+
|
| 201 |
+
Choose the narrowest test that proves the changed behavior, then expand based
|
| 202 |
+
on risk. Do not claim success without running the relevant command on the final
|
| 203 |
+
working tree.
|
| 204 |
+
|
| 205 |
+
### C++ unit and utility tests
|
| 206 |
+
|
| 207 |
+
```bash
|
| 208 |
+
ctest --test-dir build --output-on-failure
|
| 209 |
+
build/bin/test_bitcoin --list_content
|
| 210 |
+
build/bin/test_bitcoin -l all -t getarg_tests
|
| 211 |
+
build/bin/test_bitcoin -l all -t getarg_tests/doubledash
|
| 212 |
+
```
|
| 213 |
+
|
| 214 |
+
`ctest` also runs tests from embedded subprojects and utility tests. Use
|
| 215 |
+
`ctest --test-dir build -N` to list registered tests and `-R <regex>` to select
|
| 216 |
+
one. Failure details are saved in `build/Testing/Temporary/LastTest.log`.
|
| 217 |
+
|
| 218 |
+
### Functional tests
|
| 219 |
+
|
| 220 |
+
Configure and build first. Run from the repository root so paths and globs are
|
| 221 |
+
unambiguous:
|
| 222 |
+
|
| 223 |
+
```bash
|
| 224 |
+
build/test/functional/test_runner.py feature_rbf.py
|
| 225 |
+
build/test/functional/test_runner.py --jobs=4
|
| 226 |
+
build/test/functional/test_runner.py --extended
|
| 227 |
+
```
|
| 228 |
+
|
| 229 |
+
An individual generated test script can also be invoked directly, for example
|
| 230 |
+
`build/test/functional/feature_rbf.py`. The default suite is already large;
|
| 231 |
+
`--extended` is larger still. Run the focused test while iterating, then the
|
| 232 |
+
appropriate suite before handoff.
|
| 233 |
+
|
| 234 |
+
Functional tests launch isolated regtest nodes. Their first output line gives
|
| 235 |
+
the temporary directory. On failure inspect:
|
| 236 |
+
|
| 237 |
+
- `<tmpdir>/test_framework.log`
|
| 238 |
+
- `<tmpdir>/nodeN/regtest/debug.log`
|
| 239 |
+
- merged output from
|
| 240 |
+
`build/test/functional/combine_logs.py -c <tmpdir> | less -r`
|
| 241 |
+
|
| 242 |
+
Useful flags are `--nocleanup`, `--tracerpc`, `--jobs=N`, `--tmpdir=...`, and
|
| 243 |
+
the per-test `-l debug`. Run the runner with `-h` for the current set. Do not
|
| 244 |
+
kill all host `bitcoind` processes as a routine cleanup step; that can destroy
|
| 245 |
+
an unrelated user's running node. Identify and terminate only test-owned PIDs.
|
| 246 |
+
|
| 247 |
+
When changing RPC/P2P behavior, add or update a functional test. Reuse helpers
|
| 248 |
+
from `test/functional/test_framework/`, use deterministic assertions, and avoid
|
| 249 |
+
wall-clock sleeps. If the framework already exposes a synchronization helper,
|
| 250 |
+
use it.
|
| 251 |
+
|
| 252 |
+
### Lint and formatting
|
| 253 |
+
|
| 254 |
+
The full lint runner requires Rust plus the tools listed in
|
| 255 |
+
`test/lint/README.md` and `ci/lint/04_install.sh`:
|
| 256 |
+
|
| 257 |
+
```bash
|
| 258 |
+
(cd test/lint/test_runner && cargo fmt && cargo clippy && \
|
| 259 |
+
RUST_BACKTRACE=1 cargo run)
|
| 260 |
+
```
|
| 261 |
+
|
| 262 |
+
Run selected lints with, for example:
|
| 263 |
+
|
| 264 |
+
```bash
|
| 265 |
+
(cd test/lint/test_runner && \
|
| 266 |
+
RUST_BACKTRACE=1 cargo run -- --lint=doc --lint=trailing_whitespace)
|
| 267 |
+
```
|
| 268 |
+
|
| 269 |
+
Format only changed C++ lines, not whole legacy files:
|
| 270 |
+
|
| 271 |
+
```bash
|
| 272 |
+
git diff -U0 --no-color | contrib/devtools/clang-format-diff.py -p1 -i
|
| 273 |
+
```
|
| 274 |
+
|
| 275 |
+
Python formatting/lint behavior is defined by `.style.yapf` and the lint runner
|
| 276 |
+
(which invokes pinned tools such as Ruff). Check `git diff --check` for
|
| 277 |
+
whitespace errors.
|
| 278 |
+
|
| 279 |
+
### Fuzzing, sanitizers, and benchmarks
|
| 280 |
+
|
| 281 |
+
```bash
|
| 282 |
+
cmake --preset=libfuzzer
|
| 283 |
+
cmake --build build_fuzz -j 4
|
| 284 |
+
FUZZ=process_message build_fuzz/bin/fuzz /path/to/corpus
|
| 285 |
+
|
| 286 |
+
cmake -B build-asan -DSANITIZERS=address,undefined
|
| 287 |
+
cmake --build build-asan -j 4
|
| 288 |
+
|
| 289 |
+
cmake -B build-bench -DBUILD_BENCH=ON
|
| 290 |
+
cmake --build build-bench --target bench_bitcoin -j 4
|
| 291 |
+
build-bench/bin/bench_bitcoin
|
| 292 |
+
```
|
| 293 |
+
|
| 294 |
+
The fuzz seed corpora live in the separate `bitcoin-core/qa-assets` repository.
|
| 295 |
+
Do not add arbitrary corpora or crash artifacts to this repository. Address and
|
| 296 |
+
thread sanitizers are mutually incompatible. Use the suppressions in
|
| 297 |
+
`test/sanitizer_suppressions/` as documented in `doc/developer-notes.md`.
|
| 298 |
+
Performance claims should include a focused `bench_bitcoin` comparison and, for
|
| 299 |
+
user-visible paths such as IBD, an end-to-end measurement where practical.
|
| 300 |
+
|
| 301 |
+
## Debugging workflow
|
| 302 |
+
|
| 303 |
+
1. Reproduce with the smallest deterministic unit or functional test.
|
| 304 |
+
2. Record the exact configure flags, executable, arguments, and datadir.
|
| 305 |
+
3. Read the relevant `debug.log`; enable categories with `-debug=<category>`
|
| 306 |
+
and severity with `-loglevel=<level>`. Runtime categories can be toggled via
|
| 307 |
+
the `logging` RPC. Qt `qDebug()` output uses the `qt` category.
|
| 308 |
+
4. Use a Debug or sanitizer build when the symptom warrants it.
|
| 309 |
+
5. Form a concrete root-cause hypothesis before editing and add a regression
|
| 310 |
+
test that fails for the original bug.
|
| 311 |
+
|
| 312 |
+
Common commands:
|
| 313 |
+
|
| 314 |
+
```bash
|
| 315 |
+
gdb --args build/bin/bitcoind -regtest -datadir=/path/to/test-datadir
|
| 316 |
+
gdb build/bin/test_bitcoin
|
| 317 |
+
build/bin/test_bitcoin --catch_system_errors=no -t suite/test
|
| 318 |
+
```
|
| 319 |
+
|
| 320 |
+
A Debug build enables `DEBUG_LOCKORDER` and `DEBUG_LOCKCONTENTION`. Use
|
| 321 |
+
`-debug=lock` or the runtime `logging` RPC for contention records. For a unit
|
| 322 |
+
test that needs a persistent temporary datadir, pass application arguments
|
| 323 |
+
after `--`, for example:
|
| 324 |
+
|
| 325 |
+
```bash
|
| 326 |
+
build/bin/test_bitcoin -t getarg_tests/doubledash -- \
|
| 327 |
+
-testdatadir=/absolute/path/to/test-output -printtoconsole=1
|
| 328 |
+
```
|
| 329 |
+
|
| 330 |
+
Do not “fix” flaky functional tests by increasing sleeps. Check stale test
|
| 331 |
+
processes, port conflicts, the generated cache under `build/test/cache`, and
|
| 332 |
+
the combined logs. Only remove generated test cache after confirming its exact
|
| 333 |
+
path and that no test is using it.
|
| 334 |
+
|
| 335 |
+
## Coding rules that matter most
|
| 336 |
+
|
| 337 |
+
The complete rules are in `doc/developer-notes.md`; functional-test rules are
|
| 338 |
+
in `test/functional/README.md`. Preserve these essentials:
|
| 339 |
+
|
| 340 |
+
- Four spaces, no tabs (except Makefile recipes), LF endings, final newline,
|
| 341 |
+
and no trailing whitespace. CMake/YAML commonly use two spaces as specified
|
| 342 |
+
by `.editorconfig`.
|
| 343 |
+
- New C++ uses `snake_case` variables/namespaces, `m_` members, `g_` globals,
|
| 344 |
+
`UPPER_CASE` constants, and `PascalCase` classes/functions/methods. Do not
|
| 345 |
+
rename broad legacy surfaces merely to match modern style.
|
| 346 |
+
- Prefer RAII, value returns, `std::optional` for genuine optional values,
|
| 347 |
+
`nullptr`, list initialization, explicit namespace qualification, named
|
| 348 |
+
casts, and `++i`.
|
| 349 |
+
- Keep includes minimal and in the order enforced by project lint. Include the
|
| 350 |
+
corresponding header first in implementation files where the project does so.
|
| 351 |
+
- Use project synchronization annotations/macros and established lock order.
|
| 352 |
+
Do not call unknown/external code while holding a lock without analyzing
|
| 353 |
+
reentrancy and order. Run a Debug build for synchronization changes.
|
| 354 |
+
- Use `Assert`, `Assume`, `CHECK_NONFATAL`, or explicit error handling according
|
| 355 |
+
to the distinctions documented under “Assertions and Checks”; never rely on
|
| 356 |
+
assertions for untrusted input validation.
|
| 357 |
+
- Monetary RPC values must use `AmountFromValue`/`ValueFromAmount`, not floating
|
| 358 |
+
point or hand parsing. RPC methods are lowercase; new argument/result fields
|
| 359 |
+
use established names or `snake_case`. Treat omitted and `null` arguments
|
| 360 |
+
consistently.
|
| 361 |
+
- Keep GUI work off the GUI thread when it can block. Preserve node/wallet/GUI
|
| 362 |
+
separation through interfaces.
|
| 363 |
+
- Python functional tests use `snake_case`, named constants instead of magic
|
| 364 |
+
values, precise `assert_equal`-style helpers, and framework synchronization.
|
| 365 |
+
- Add comments for why and for invariants, not line-by-line narration. Keep
|
| 366 |
+
patches reviewable; avoid unrelated refactors and formatting churn.
|
| 367 |
+
|
| 368 |
+
For new user-facing strings, follow the translation helpers already used by
|
| 369 |
+
the surrounding component. Do not manually edit translated
|
| 370 |
+
`src/qt/locale/bitcoin_*.ts` files. `bitcoin_en.ts` is generated with the
|
| 371 |
+
`translate` target as described in `doc/translation_process.md`.
|
| 372 |
+
|
| 373 |
+
## Change-specific checklist
|
| 374 |
+
|
| 375 |
+
- **Consensus/validation/script/serialization:** obtain explicit intent; verify
|
| 376 |
+
compatibility with historical data and peers; add unit, functional, and/or
|
| 377 |
+
fuzz coverage; test reindex/load paths when relevant. Preserve the Roots
|
| 378 |
+
consensus-neutral invariant.
|
| 379 |
+
- **Policy/mempool/mining:** prove the rule affects admission/relay/template
|
| 380 |
+
policy only unless a consensus change was explicitly requested. Test both
|
| 381 |
+
rejection and block acceptance where that boundary is at risk.
|
| 382 |
+
- **RPC:** update implementation, help text, argument/result schemas, and
|
| 383 |
+
functional tests together. Run `bitcoin-cli help <rpc>` and relevant doc lint.
|
| 384 |
+
- **Wallet/database:** test descriptor-wallet behavior by default and legacy
|
| 385 |
+
BDB behavior only with a compatible BDB build. Cover upgrade, unload/reload,
|
| 386 |
+
backup, and watch-only/signing implications as applicable.
|
| 387 |
+
- **P2P/networking:** test malformed and adversarial input, disconnect/ban
|
| 388 |
+
behavior, permissions, and resource bounds. Prefer P2P test-framework helpers
|
| 389 |
+
and add fuzz coverage for parsers.
|
| 390 |
+
- **GUI:** build with `-DBUILD_GUI=ON`, run `test_bitcoin-qt` when enabled, and
|
| 391 |
+
manually check the affected interaction without a real wallet/datadir.
|
| 392 |
+
- **Build/CI/platform:** configure at least one affected minimal combination;
|
| 393 |
+
remember options interact. Consult `ci/test/00_setup_env_*.sh` rather than
|
| 394 |
+
assuming the default build represents CI.
|
| 395 |
+
- **User-visible feature/config/API:** add `doc/release-notes-<PR>.md` when a PR
|
| 396 |
+
number is known. Do not invent a number; report the need in the handoff.
|
| 397 |
+
|
| 398 |
+
## Generated files, docs, and repository hygiene
|
| 399 |
+
|
| 400 |
+
- Never edit files in a build directory as source; reconfigure/regenerate them.
|