-
Notifications
You must be signed in to change notification settings - Fork 37.7k
wallet: add tracepoints and algorithm information to coin selection #24644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Concept ACK |
Huge Concept ACK! Looking at existing tracing contexts, it seems Could you also add an example to |
cc @0xB10C |
Cool, Concept ACK! Will review. We might want to start adding tracepoint interface tests (see #24358) in the same PR when adding new tracepoints. This makes review a lot easier and provides an usage example. |
4fed26a
to
64338c1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 64338c1
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
64338c1
to
1a836be
Compare
1a836be
to
27cf3c6
Compare
Concept ACK |
27cf3c6
to
24e1d7c
Compare
Concept ACK |
fwiw: I think to move this forward at least documentation in doc/tracing.md#tracepoint-documentation and interface tests similar to #24358 are needed. I'm not too familiar with coin selection and don't know what e.g. the |
When we use only manually specified inputs, we should still calculate the waste so that if anything later on calls GetWaste (in order to log it), there won't be an error.
I've added docs and a test. |
24e1d7c
to
421c931
Compare
Concept ACK, thanks for adding tracepoints. I'll try to have a more detailed look at this soon. |
The tracepoint part looks good. Left a few comments. I also wrote a quick and dirty bpftrace script to test the documentation. In case that's helpful to anyone: bpftrace script
Running e.g. the
|
assert_equal(success, True) | ||
assert_greater_than(change_pos, -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it make sense to check use_aps
, algo
, and waste
here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this test doesn't make any assumptions about what coin selection algorithm was used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a sanity check that it's not malformed, you could assert algo in ["bnb", "srd", "knapsack", "manual"]
events = self.get_tracepoints([1, 2]) | ||
success, use_aps, algo, waste, change_pos = self.determine_selection_from_usdt(events) | ||
assert_equal(success, True) | ||
assert_equal(use_aps, None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it make sense to check algo
, change_pos
, and waste
here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this test doesn't make any assumptions about what coin selection algorithm was used.
421c931
to
ab5af9c
Compare
Your script uses |
crACK ab5af9c
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK ab5af9c. Code reviewed, ran the interface_usdt_coinselection.py
test, and tested with the above bpftrace script (updated %d
-> %ld
where necessary, ty achow101).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crACK ab5af9c
looks good! just had one nit about commit structure. also compiled and ran the functional test without any issues
/** The target the algorithm selected for. Note that this may not be equal to the recipient amount as it can include non-input fees */ | ||
const CAmount m_target; | ||
/** Whether the input values for calculations should be the effective value (true) or normal value (false) */ | ||
bool m_use_effective{false}; | ||
/** The computed waste */ | ||
std::optional<CAmount> m_waste; | ||
/** The algorithm used to produce this result */ | ||
SelectionAlgorithm m_algo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is m_algo
added as private and then moved here to public? wouldn't it be better to move m_target
to public and add m_algo
in the first commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I forgot to squash those separately when implementing this. Will move if I have to re-touch.
tACK ab5af9c wasn't paying attention earlier and it was actually skipping the USDT functional tests, not running them 🤦 . I got tracepoints working by running everything works as expected. i also noticed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
post-merged tACK ab5af9c
Functional test ran successfully on Ubuntu 21.10 and bcc (master version).
ref: #25003 tracing: fix coin_selection:aps_create_tx_internal calling logic |
Tests will fail on RHEL linux when default yum dist. of bcc is used. To remedy bcc needs to be build from bcc git master. Error output After building and running the current master of bcc https://gist.github.com/russeree/888c52a85e9bcd69c758ff0bc91f3d13 This issue only presents on RHEL (Fedora, Centos, Redhat) Ubuntu seemed to not be affected by this using apt installed versions of bcc. |
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:
SelectCoins
returns in order to observe theSelectionResult
CreateTransactionInternal
to observe the created transactionCreateTransactionInternal
to notify that the optimistic avoid partial spends selection is occurringCreateTransactionInternal
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.