mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-05 18:52:29 +02:00
Merge bitcoin/bitcoin#24644: wallet: add tracepoints and algorithm information to coin selection
ab5af9ca72test: Add test for coinselection tracepoints (Andrew Chow)ca02b68e8adoc: document coin selection tracepoints (Andrew Chow)8e3f39e4fawallet: Add some tracepoints for coin selection (Andrew Chow)15b58383d0wallet: compute waste for SelectionResults of preset inputs (Andrew Chow)912f1ed181wallet: track which coin selection algorithm produced a SelectionResult (Andrew Chow) Pull request description: Tracepoints can be useful for coin selection as they would allow us to observe what is being selected, selection parameters, and calculation results. So this PR adds 4 new tracepoints: 1. After `SelectCoins` returns in order to observe the `SelectionResult` 2. After the first `CreateTransactionInternal` to observe the created transaction 3. Prior to the second `CreateTransactionInternal` to notify that the optimistic avoid partial spends selection is occurring 4. After the second `CreateTransactionInternal` to observe the created transaction and inform which solution is being used. This PR also adds an algorithm enum to `SelectionResult` so that the first tracepoint will be able to report which algorithm was used to produce that result. The primary use case for these tracepoints is in running coin selection simulations. The script I use to run these simulations use these tracepoints in order to gather data on the algorithm used and the calculated waste. ACKs for top commit: jb55: crACKab5af9ca72josibake: crACKab5af9ca720xB10C: ACKab5af9ca72. Code reviewed, ran the `interface_usdt_coinselection.py` test, and tested with the above bpftrace script (updated `%d` -> `%ld` where necessary, ty achow101). Tree-SHA512: a4bf7a910cdf464622f2f3b5d44c15b891f24852df6e7f8c5b177fe3d8aaa4a1164593a24c3960eb22b16544fa7140e5c745345367b9e291b78395084c0ac8ff
This commit is contained in:
@@ -168,6 +168,49 @@ Arguments passed:
|
||||
4. Value of the coin as `int64`
|
||||
5. If the coin is a coinbase as `bool`
|
||||
|
||||
### Context `coin_selection`
|
||||
|
||||
#### Tracepoint `coin_selection:selected_coins`
|
||||
|
||||
Is called when `SelectCoins` completes.
|
||||
|
||||
Arguments passed:
|
||||
1. Wallet name as `pointer to C-style string`
|
||||
2. Coin selection algorithm name as `pointer to C-style string`
|
||||
3. Selection target value as `int64`
|
||||
4. Calculated waste metric of the solution as `int64`
|
||||
5. Total value of the selected inputs as `int64`
|
||||
|
||||
#### Tracepoint `coin_selection:normal_create_tx_internal`
|
||||
|
||||
Is called when the first `CreateTransactionInternal` completes.
|
||||
|
||||
Arguments passed:
|
||||
1. Wallet name as `pointer to C-style string`
|
||||
2. Whether `CreateTransactionInternal` succeeded as `bool`
|
||||
3. The expected transaction fee as an `int64`
|
||||
4. The position of the change output as an `int32`
|
||||
|
||||
#### Tracepoint `coin_selection:attempting_aps_create_tx`
|
||||
|
||||
Is called when `CreateTransactionInternal` is called the second time for the optimistic
|
||||
Avoid Partial Spends selection attempt. This is used to determine whether the next
|
||||
tracepoints called are for the Avoid Partial Spends solution, or a different transaction.
|
||||
|
||||
Arguments passed:
|
||||
1. Wallet name as `pointer to C-style string`
|
||||
|
||||
#### Tracepoint `coin_selection:aps_create_tx_internal`
|
||||
|
||||
Is called when the second `CreateTransactionInternal` with Avoid Partial Spends enabled completes.
|
||||
|
||||
Arguments passed:
|
||||
1. Wallet name as `pointer to C-style string`
|
||||
2. Whether the Avoid Partial Spends solution will be used as `bool`
|
||||
3. Whether `CreateTransactionInternal` succeeded as` bool`
|
||||
4. The expected transaction fee as an `int64`
|
||||
5. The position of the change output as an `int32`
|
||||
|
||||
## Adding tracepoints to Bitcoin Core
|
||||
|
||||
To add a new tracepoint, `#include <util/trace.h>` in the compilation unit where
|
||||
|
||||
Reference in New Issue
Block a user