Skip to content

Commit 4c526f5

Browse files
committed
Merge bitcoin#30741: doc: update documentation and scripts related to build directories
6a68343 doc: Prepend 'build/' to binary paths under 'src/' in docs (Lőrinc) 91b3bc2 doc: Update documentation generation example in developer-notes.md (Lőrinc) Pull request description: In [the other readmes](https://github.com/bitcoin/bitcoin/blob/6ce50fd9d0ae6850d54bf883e7a7c1bcb6912c5c/src/test/README.md?plain=1#L19) we've provided a default build directory instead, unified the `developer-notes.md` to specify it explicitly. In the next commit I've used this default to go over each reference to our binaries and changed their in-source references to the build directory. Some of these changes were in example outputs - I haven't validated that the outputs are still the same. I haven't modified the build folders in the devtools. ACKs for top commit: maflcko: review ACK 6a68343 pablomartin4btc: ACK 6a68343 fanquake: ACK 6a68343 - we still need to followup with other scripts/devtools, and likely unify what we are doing in some way, but this is an improvement. Tree-SHA512: 905d9c68cafe1e405e98d6aa089d7a36a34c9e03403df5c67ac2c9a98cfa54a0305b647cb92247dcb9f49e9b509a8ba88367392b95618c67059684c67b6c36fb
2 parents a74bdee + 6a68343 commit 4c526f5

10 files changed

+74
-73
lines changed

contrib/tracing/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ about the connection. Peers can be selected individually to view recent P2P
8282
messages.
8383

8484
```
85-
$ python3 contrib/tracing/p2p_monitor.py ./src/bitcoind
85+
$ python3 contrib/tracing/p2p_monitor.py ./build/src/bitcoind
8686
```
8787

8888
Lists selectable peers and traffic and connection information.
@@ -150,7 +150,7 @@ lost. BCC prints: `Possibly lost 2 samples` on lost messages.
150150

151151

152152
```
153-
$ python3 contrib/tracing/log_raw_p2p_msgs.py ./src/bitcoind
153+
$ python3 contrib/tracing/log_raw_p2p_msgs.py ./build/src/bitcoind
154154
```
155155

156156
```
@@ -188,7 +188,7 @@ In a different terminal, starting Bitcoin Core in SigNet mode and with
188188
re-indexing enabled.
189189

190190
```
191-
$ ./src/bitcoind -signet -reindex
191+
$ ./build/src/bitcoind -signet -reindex
192192
```
193193

194194
This produces the following output.
@@ -241,7 +241,7 @@ A BCC Python script to log the UTXO cache flushes. Based on the
241241
`utxocache:flush` tracepoint.
242242

243243
```bash
244-
$ python3 contrib/tracing/log_utxocache_flush.py ./src/bitcoind
244+
$ python3 contrib/tracing/log_utxocache_flush.py ./build/src/bitcoind
245245
```
246246

247247
```
@@ -300,7 +300,7 @@ comprising a timestamp along with all event data available via the event's
300300
tracepoint.
301301

302302
```console
303-
$ python3 contrib/tracing/mempool_monitor.py ./src/bitcoind
303+
$ python3 contrib/tracing/mempool_monitor.py ./build/src/bitcoind
304304
```
305305

306306
```

contrib/tracing/connectblock_benchmark.bt

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
This script requires a 'bitcoind' binary compiled with eBPF support and the
1818
'validation:block_connected' USDT. By default, it's assumed that 'bitcoind' is
19-
located in './src/bitcoind'. This can be modified in the script below.
19+
located in './build/src/bitcoind'. This can be modified in the script below.
2020

2121
EXAMPLES:
2222

@@ -67,7 +67,7 @@ BEGIN
6767
connected block is between the start and end height (or the end height is
6868
unset).
6969
*/
70-
usdt:./src/bitcoind:validation:block_connected /arg1 >= $1 && (arg1 <= $2 || $2 == 0 )/
70+
usdt:./build/src/bitcoind:validation:block_connected /arg1 >= $1 && (arg1 <= $2 || $2 == 0 )/
7171
{
7272
$height = arg1;
7373
$transactions = arg2;
@@ -102,7 +102,7 @@ usdt:./src/bitcoind:validation:block_connected /arg1 >= $1 && (arg1 <= $2 || $2
102102
blocks where the time it took to connect the block is above the
103103
<logging threshold in ms>.
104104
*/
105-
usdt:./src/bitcoind:validation:block_connected / (uint64) arg5 / 1000> $3 /
105+
usdt:./build/src/bitcoind:validation:block_connected / (uint64) arg5 / 1000> $3 /
106106
{
107107
$hash = arg0;
108108
$height = (int32) arg1;

contrib/tracing/log_p2p_traffic.bt

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ BEGIN
55
printf("Logging P2P traffic\n")
66
}
77

8-
usdt:./src/bitcoind:net:inbound_message
8+
usdt:./build/src/bitcoind:net:inbound_message
99
{
1010
$peer_id = (int64) arg0;
1111
$peer_addr = str(arg1);
@@ -15,7 +15,7 @@ usdt:./src/bitcoind:net:inbound_message
1515
printf("inbound '%s' msg from peer %d (%s, %s) with %d bytes\n", $msg_type, $peer_id, $peer_type, $peer_addr, $msg_len);
1616
}
1717

18-
usdt:./src/bitcoind:net:outbound_message
18+
usdt:./build/src/bitcoind:net:outbound_message
1919
{
2020
$peer_id = (int64) arg0;
2121
$peer_addr = str(arg1);

contrib/tracing/log_utxos.bt

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
This script requires a 'bitcoind' binary compiled with eBPF support and the
1010
'utxocache' tracepoints. By default, it's assumed that 'bitcoind' is
11-
located in './src/bitcoind'. This can be modified in the script below.
11+
located in './build/src/bitcoind'. This can be modified in the script below.
1212

1313
NOTE: requires bpftrace v0.12.0 or above.
1414
*/
@@ -22,7 +22,7 @@ BEGIN
2222
/*
2323
Attaches to the 'utxocache:add' tracepoint and prints additions to the UTXO set cache.
2424
*/
25-
usdt:./src/bitcoind:utxocache:add
25+
usdt:./build/src/bitcoind:utxocache:add
2626
{
2727
$txid = arg0;
2828
$index = (uint32)arg1;
@@ -44,7 +44,7 @@ usdt:./src/bitcoind:utxocache:add
4444
/*
4545
Attaches to the 'utxocache:spent' tracepoint and prints spents from the UTXO set cache.
4646
*/
47-
usdt:./src/bitcoind:utxocache:spent
47+
usdt:./build/src/bitcoind:utxocache:spent
4848
{
4949
$txid = arg0;
5050
$index = (uint32)arg1;
@@ -66,7 +66,7 @@ usdt:./src/bitcoind:utxocache:spent
6666
/*
6767
Attaches to the 'utxocache:uncache' tracepoint and uncache UTXOs from the UTXO set cache.
6868
*/
69-
usdt:./src/bitcoind:utxocache:uncache
69+
usdt:./build/src/bitcoind:utxocache:uncache
7070
{
7171
$txid = arg0;
7272
$index = (uint32)arg1;

contrib/valgrind.supp

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# dependencies that cannot be fixed in-tree.
33
#
44
# Example use:
5-
# $ valgrind --suppressions=contrib/valgrind.supp src/test/test_bitcoin
5+
# $ valgrind --suppressions=contrib/valgrind.supp build/src/test/test_bitcoin
66
# $ valgrind --suppressions=contrib/valgrind.supp --leak-check=full \
7-
# --show-leak-kinds=all src/test/test_bitcoin
7+
# --show-leak-kinds=all build/src/test/test_bitcoin
88
#
99
# To create suppressions for found issues, use the --gen-suppressions=all option:
1010
# $ valgrind --suppressions=contrib/valgrind.supp --leak-check=full \
1111
# --show-leak-kinds=all --gen-suppressions=all --show-reachable=yes \
12-
# --error-limit=no src/test/test_bitcoin
12+
# --error-limit=no build/src/test/test_bitcoin
1313
#
1414
# Note that suppressions may depend on OS and/or library versions.
1515
# Tested on:

doc/developer-notes.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,10 @@ Recommendations:
338338

339339
### Generating Documentation
340340

341-
The documentation can be generated with `cmake --build <build_dir> --target docs`.
342-
The resulting files are located in `<build_dir>/doc/doxygen/html`; open
343-
`index.html` in that directory to view the homepage.
341+
Assuming the build directory is named `build`,
342+
the documentation can be generated with `cmake --build build --target docs`.
343+
The resulting files will be located in `build/doc/doxygen/html`;
344+
open `index.html` in that directory to view the homepage.
344345

345346
Before building the `docs` target, you'll need to install these dependencies:
346347

@@ -467,11 +468,11 @@ which includes known Valgrind warnings in our dependencies that cannot be fixed
467468
in-tree. Example use:
468469

469470
```shell
470-
$ valgrind --suppressions=contrib/valgrind.supp src/test/test_bitcoin
471+
$ valgrind --suppressions=contrib/valgrind.supp build/src/test/test_bitcoin
471472
$ valgrind --suppressions=contrib/valgrind.supp --leak-check=full \
472-
--show-leak-kinds=all src/test/test_bitcoin --log_level=test_suite
473-
$ valgrind -v --leak-check=full src/bitcoind -printtoconsole
474-
$ ./test/functional/test_runner.py --valgrind
473+
--show-leak-kinds=all build/src/test/test_bitcoin --log_level=test_suite
474+
$ valgrind -v --leak-check=full build/src/bitcoind -printtoconsole
475+
$ ./build/test/functional/test_runner.py --valgrind
475476
```
476477

477478
### Compiling for test coverage

doc/multisig-tutorial.md

+28-28
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This tutorial uses [jq](https://github.com/stedolan/jq) JSON processor to proces
99
Before starting this tutorial, start the bitcoin node on the signet network.
1010

1111
```bash
12-
./src/bitcoind -signet -daemon
12+
./build/src/bitcoind -signet -daemon
1313
```
1414

1515
This tutorial also uses the default WPKH derivation path to get the xpubs and does not conform to [BIP 45](https://github.com/bitcoin/bips/blob/master/bip-0045.mediawiki) or [BIP 87](https://github.com/bitcoin/bips/blob/master/bip-0087.mediawiki).
@@ -27,7 +27,7 @@ These three wallets should not be used directly for privacy reasons (public key
2727
```bash
2828
for ((n=1;n<=3;n++))
2929
do
30-
./src/bitcoin-cli -signet createwallet "participant_${n}"
30+
./build/src/bitcoin-cli -signet createwallet "participant_${n}"
3131
done
3232
```
3333

@@ -47,9 +47,9 @@ declare -A xpubs
4747

4848
for ((n=1;n<=3;n++))
4949
do
50-
xpubs["internal_xpub_${n}"]=$(./src/bitcoin-cli -signet -rpcwallet="participant_${n}" listdescriptors | jq '.descriptors | [.[] | select(.desc | startswith("wpkh") and contains("/1/*"))][0] | .desc' | grep -Po '(?<=\().*(?=\))')
50+
xpubs["internal_xpub_${n}"]=$(./build/src/bitcoin-cli -signet -rpcwallet="participant_${n}" listdescriptors | jq '.descriptors | [.[] | select(.desc | startswith("wpkh") and contains("/1/*"))][0] | .desc' | grep -Po '(?<=\().*(?=\))')
5151

52-
xpubs["external_xpub_${n}"]=$(./src/bitcoin-cli -signet -rpcwallet="participant_${n}" listdescriptors | jq '.descriptors | [.[] | select(.desc | startswith("wpkh") and contains("/0/*") )][0] | .desc' | grep -Po '(?<=\().*(?=\))')
52+
xpubs["external_xpub_${n}"]=$(./build/src/bitcoin-cli -signet -rpcwallet="participant_${n}" listdescriptors | jq '.descriptors | [.[] | select(.desc | startswith("wpkh") and contains("/0/*") )][0] | .desc' | grep -Po '(?<=\().*(?=\))')
5353
done
5454
```
5555

@@ -71,8 +71,8 @@ Define the external and internal multisig descriptors, add the checksum and then
7171
external_desc="wsh(sortedmulti(2,${xpubs["external_xpub_1"]},${xpubs["external_xpub_2"]},${xpubs["external_xpub_3"]}))"
7272
internal_desc="wsh(sortedmulti(2,${xpubs["internal_xpub_1"]},${xpubs["internal_xpub_2"]},${xpubs["internal_xpub_3"]}))"
7373

74-
external_desc_sum=$(./src/bitcoin-cli -signet getdescriptorinfo $external_desc | jq '.descriptor')
75-
internal_desc_sum=$(./src/bitcoin-cli -signet getdescriptorinfo $internal_desc | jq '.descriptor')
74+
external_desc_sum=$(./build/src/bitcoin-cli -signet getdescriptorinfo $external_desc | jq '.descriptor')
75+
internal_desc_sum=$(./build/src/bitcoin-cli -signet getdescriptorinfo $internal_desc | jq '.descriptor')
7676

7777
multisig_ext_desc="{\"desc\": $external_desc_sum, \"active\": true, \"internal\": false, \"timestamp\": \"now\"}"
7878
multisig_int_desc="{\"desc\": $internal_desc_sum, \"active\": true, \"internal\": true, \"timestamp\": \"now\"}"
@@ -94,7 +94,7 @@ There are other fields that can be added to the descriptors:
9494
* `internal`: Indicates whether matching outputs should be treated as something other than incoming payments (e.g. change).
9595
* `timestamp`: Sets the time from which to start rescanning the blockchain for the descriptor, in UNIX epoch time.
9696

97-
Documentation for these and other parameters can be found by typing `./src/bitcoin-cli help importdescriptors`.
97+
Documentation for these and other parameters can be found by typing `./build/src/bitcoin-cli help importdescriptors`.
9898

9999
`multisig_desc` concatenates external and internal descriptors in a JSON array and then it will be used to create the multisig wallet.
100100

@@ -107,17 +107,17 @@ Then import the descriptors created in the previous step using the `importdescri
107107
After that, `getwalletinfo` can be used to check if the wallet was created successfully.
108108

109109
```bash
110-
./src/bitcoin-cli -signet -named createwallet wallet_name="multisig_wallet_01" disable_private_keys=true blank=true
110+
./build/src/bitcoin-cli -signet -named createwallet wallet_name="multisig_wallet_01" disable_private_keys=true blank=true
111111

112-
./src/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" importdescriptors "$multisig_desc"
112+
./build/src/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" importdescriptors "$multisig_desc"
113113

114-
./src/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" getwalletinfo
114+
./build/src/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" getwalletinfo
115115
```
116116

117117
Once the wallets have already been created and this tutorial needs to be repeated or resumed, it is not necessary to recreate them, just load them with the command below:
118118

119119
```bash
120-
for ((n=1;n<=3;n++)); do ./src/bitcoin-cli -signet loadwallet "participant_${n}"; done
120+
for ((n=1;n<=3;n++)); do ./build/src/bitcoin-cli -signet loadwallet "participant_${n}"; done
121121
```
122122

123123
### 1.4 Fund the wallet
@@ -131,9 +131,9 @@ The url used by the script can also be accessed directly. At time of writing, th
131131
Coins received by the wallet must have at least 1 confirmation before they can be spent. It is necessary to wait for a new block to be mined before continuing.
132132

133133
```bash
134-
receiving_address=$(./src/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" getnewaddress)
134+
receiving_address=$(./build/src/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" getnewaddress)
135135

136-
./contrib/signet/getcoins.py -c ./src/bitcoin-cli -a $receiving_address
136+
./contrib/signet/getcoins.py -c ./build/src/bitcoin-cli -a $receiving_address
137137
```
138138

139139
To copy the receiving address onto the clipboard, use the following command. This can be useful when getting coins via the signet faucet mentioned above.
@@ -145,7 +145,7 @@ echo -n "$receiving_address" | xclip -sel clip
145145
The `getbalances` RPC may be used to check the balance. Coins with `trusted` status can be spent.
146146

147147
```bash
148-
./src/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" getbalances
148+
./build/src/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" getbalances
149149
```
150150

151151
### 1.5 Create a PSBT
@@ -161,13 +161,13 @@ For simplicity, the destination address is taken from the `participant_1` wallet
161161
The `walletcreatefundedpsbt` RPC is used to create and fund a transaction in the PSBT format. It is the first step in creating the PSBT.
162162

163163
```bash
164-
balance=$(./src/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" getbalance)
164+
balance=$(./build/src/bitcoin-cli -signet -rpcwallet="multisig_wallet_01" getbalance)
165165

166166
amount=$(echo "$balance * 0.8" | bc -l | sed -e 's/^\./0./' -e 's/^-\./-0./')
167167

168-
destination_addr=$(./src/bitcoin-cli -signet -rpcwallet="participant_1" getnewaddress)
168+
destination_addr=$(./build/src/bitcoin-cli -signet -rpcwallet="participant_1" getnewaddress)
169169

170-
funded_psbt=$(./src/bitcoin-cli -signet -named -rpcwallet="multisig_wallet_01" walletcreatefundedpsbt outputs="{\"$destination_addr\": $amount}" | jq -r '.psbt')
170+
funded_psbt=$(./build/src/bitcoin-cli -signet -named -rpcwallet="multisig_wallet_01" walletcreatefundedpsbt outputs="{\"$destination_addr\": $amount}" | jq -r '.psbt')
171171
```
172172

173173
There is also the `createpsbt` RPC, which serves the same purpose, but it has no access to the wallet or to the UTXO set. It is functionally the same as `createrawtransaction` and just drops the raw transaction into an otherwise blank PSBT. [[source](https://bitcointalk.org/index.php?topic=5131043.msg50573609#msg50573609)] In most cases, `walletcreatefundedpsbt` solves the problem.
@@ -181,9 +181,9 @@ Optionally, the PSBT can be decoded to a JSON format using `decodepsbt` RPC.
181181
The `analyzepsbt` RPC analyzes and provides information about the current status of a PSBT and its inputs, e.g. missing signatures.
182182

183183
```bash
184-
./src/bitcoin-cli -signet decodepsbt $funded_psbt
184+
./build/src/bitcoin-cli -signet decodepsbt $funded_psbt
185185

186-
./src/bitcoin-cli -signet analyzepsbt $funded_psbt
186+
./build/src/bitcoin-cli -signet analyzepsbt $funded_psbt
187187
```
188188

189189
### 1.7 Update the PSBT
@@ -193,17 +193,17 @@ In the code above, two PSBTs are created. One signed by `participant_1` wallet a
193193
The `walletprocesspsbt` is used by the wallet to sign a PSBT.
194194

195195
```bash
196-
psbt_1=$(./src/bitcoin-cli -signet -rpcwallet="participant_1" walletprocesspsbt $funded_psbt | jq '.psbt')
196+
psbt_1=$(./build/src/bitcoin-cli -signet -rpcwallet="participant_1" walletprocesspsbt $funded_psbt | jq '.psbt')
197197

198-
psbt_2=$(./src/bitcoin-cli -signet -rpcwallet="participant_2" walletprocesspsbt $funded_psbt | jq '.psbt')
198+
psbt_2=$(./build/src/bitcoin-cli -signet -rpcwallet="participant_2" walletprocesspsbt $funded_psbt | jq '.psbt')
199199
```
200200

201201
### 1.8 Combine the PSBT
202202

203203
The PSBT, if signed separately by the co-signers, must be combined into one transaction before being finalized. This is done by `combinepsbt` RPC.
204204

205205
```bash
206-
combined_psbt=$(./src/bitcoin-cli -signet combinepsbt "[$psbt_1, $psbt_2]")
206+
combined_psbt=$(./build/src/bitcoin-cli -signet combinepsbt "[$psbt_1, $psbt_2]")
207207
```
208208

209209
There is an RPC called `joinpsbts`, but it has a different purpose than `combinepsbt`. `joinpsbts` joins the inputs from multiple distinct PSBTs into one PSBT.
@@ -217,9 +217,9 @@ The `finalizepsbt` RPC is used to produce a network serialized transaction which
217217
It checks that all inputs have complete scriptSigs and scriptWitnesses and, if so, encodes them into network serialized transactions.
218218

219219
```bash
220-
finalized_psbt_hex=$(./src/bitcoin-cli -signet finalizepsbt $combined_psbt | jq -r '.hex')
220+
finalized_psbt_hex=$(./build/src/bitcoin-cli -signet finalizepsbt $combined_psbt | jq -r '.hex')
221221

222-
./src/bitcoin-cli -signet sendrawtransaction $finalized_psbt_hex
222+
./build/src/bitcoin-cli -signet sendrawtransaction $finalized_psbt_hex
223223
```
224224

225225
### 1.10 Alternative Workflow (PSBT sequential signatures)
@@ -229,11 +229,11 @@ Instead of each wallet signing the original PSBT and combining them later, the w
229229
After that, the rest of the process is the same: the PSBT is finalized and transmitted to the network.
230230

231231
```bash
232-
psbt_1=$(./src/bitcoin-cli -signet -rpcwallet="participant_1" walletprocesspsbt $funded_psbt | jq -r '.psbt')
232+
psbt_1=$(./build/src/bitcoin-cli -signet -rpcwallet="participant_1" walletprocesspsbt $funded_psbt | jq -r '.psbt')
233233

234-
psbt_2=$(./src/bitcoin-cli -signet -rpcwallet="participant_2" walletprocesspsbt $psbt_1 | jq -r '.psbt')
234+
psbt_2=$(./build/src/bitcoin-cli -signet -rpcwallet="participant_2" walletprocesspsbt $psbt_1 | jq -r '.psbt')
235235

236-
finalized_psbt_hex=$(./src/bitcoin-cli -signet finalizepsbt $psbt_2 | jq -r '.hex')
236+
finalized_psbt_hex=$(./build/src/bitcoin-cli -signet finalizepsbt $psbt_2 | jq -r '.hex')
237237

238-
./src/bitcoin-cli -signet sendrawtransaction $finalized_psbt_hex
238+
./build/src/bitcoin-cli -signet sendrawtransaction $finalized_psbt_hex
239239
```

0 commit comments

Comments
 (0)