|
23 | 23 | coinselection_tracepoints_program = """ |
24 | 24 | #include <uapi/linux/ptrace.h> |
25 | 25 |
|
26 | | -#define WALLET_NAME_LENGTH 16 |
| 26 | +#define COLOR_ID_LENGTH 64 |
27 | 27 | #define ALGO_NAME_LENGTH 16 |
28 | 28 |
|
29 | 29 | struct event_data |
30 | 30 | { |
31 | 31 | u8 type; |
32 | | - char wallet_name[WALLET_NAME_LENGTH]; |
| 32 | + char color_id[COLOR_ID_LENGTH]; |
33 | 33 |
|
34 | | - // selected coins event |
35 | | - char algo[ALGO_NAME_LENGTH]; |
36 | | - s64 target; |
37 | | - s64 waste; |
| 34 | + // selected coins event (type 1) |
| 35 | + s64 target_value; |
38 | 36 | s64 selected_value; |
| 37 | + s64 num_coins; |
| 38 | + char algo[ALGO_NAME_LENGTH]; |
| 39 | +
|
| 40 | + // coins requested event (type 2) |
| 41 | + s64 amount; |
39 | 42 |
|
40 | | - // create tx event |
41 | | - bool success; |
42 | | - s64 fee; |
43 | | - s32 change_pos; |
| 43 | + // change info event (type 3) |
| 44 | + s64 change_amount; |
44 | 45 |
|
45 | | - // aps create tx event |
46 | | - bool use_aps; |
| 46 | + // fee info event (type 4) |
| 47 | + s64 fee_ret; |
| 48 | + s64 fee_needed; |
47 | 49 | }; |
48 | 50 |
|
49 | 51 | BPF_QUEUE(coin_selection_events, struct event_data, 1024); |
|
52 | 54 | struct event_data data; |
53 | 55 | __builtin_memset(&data, 0, sizeof(data)); |
54 | 56 | data.type = 1; |
55 | | - bpf_usdt_readarg_p(1, ctx, &data.wallet_name, WALLET_NAME_LENGTH); |
56 | | - bpf_usdt_readarg_p(2, ctx, &data.algo, ALGO_NAME_LENGTH); |
57 | | - bpf_usdt_readarg(3, ctx, &data.target); |
58 | | - bpf_usdt_readarg(4, ctx, &data.waste); |
59 | | - bpf_usdt_readarg(5, ctx, &data.selected_value); |
| 57 | + bpf_usdt_readarg_p(1, ctx, &data.color_id, COLOR_ID_LENGTH); |
| 58 | + bpf_usdt_readarg(2, ctx, &data.target_value); |
| 59 | + bpf_usdt_readarg(3, ctx, &data.selected_value); |
| 60 | + bpf_usdt_readarg(4, ctx, &data.num_coins); |
| 61 | + bpf_usdt_readarg_p(5, ctx, &data.algo, ALGO_NAME_LENGTH); |
60 | 62 | coin_selection_events.push(&data, 0); |
61 | 63 | return 0; |
62 | 64 | } |
63 | 65 |
|
64 | | -int trace_normal_create_tx(struct pt_regs *ctx) { |
| 66 | +int trace_coins_requested(struct pt_regs *ctx) { |
65 | 67 | struct event_data data; |
66 | 68 | __builtin_memset(&data, 0, sizeof(data)); |
67 | 69 | data.type = 2; |
68 | | - bpf_usdt_readarg_p(1, ctx, &data.wallet_name, WALLET_NAME_LENGTH); |
69 | | - bpf_usdt_readarg(2, ctx, &data.success); |
70 | | - bpf_usdt_readarg(3, ctx, &data.fee); |
71 | | - bpf_usdt_readarg(4, ctx, &data.change_pos); |
| 70 | + bpf_usdt_readarg(1, ctx, &data.amount); |
| 71 | + bpf_usdt_readarg_p(2, ctx, &data.color_id, COLOR_ID_LENGTH); |
72 | 72 | coin_selection_events.push(&data, 0); |
73 | 73 | return 0; |
74 | 74 | } |
75 | 75 |
|
76 | | -int trace_attempt_aps(struct pt_regs *ctx) { |
| 76 | +int trace_change_info(struct pt_regs *ctx) { |
77 | 77 | struct event_data data; |
78 | 78 | __builtin_memset(&data, 0, sizeof(data)); |
79 | 79 | data.type = 3; |
80 | | - bpf_usdt_readarg_p(1, ctx, &data.wallet_name, WALLET_NAME_LENGTH); |
| 80 | + bpf_usdt_readarg(1, ctx, &data.change_amount); |
| 81 | + bpf_usdt_readarg_p(2, ctx, &data.color_id, COLOR_ID_LENGTH); |
81 | 82 | coin_selection_events.push(&data, 0); |
82 | 83 | return 0; |
83 | 84 | } |
84 | 85 |
|
85 | | -int trace_aps_create_tx(struct pt_regs *ctx) { |
| 86 | +int trace_fee_info(struct pt_regs *ctx) { |
86 | 87 | struct event_data data; |
87 | 88 | __builtin_memset(&data, 0, sizeof(data)); |
88 | 89 | data.type = 4; |
89 | | - bpf_usdt_readarg_p(1, ctx, &data.wallet_name, WALLET_NAME_LENGTH); |
90 | | - bpf_usdt_readarg(2, ctx, &data.use_aps); |
91 | | - bpf_usdt_readarg(3, ctx, &data.success); |
92 | | - bpf_usdt_readarg(4, ctx, &data.fee); |
93 | | - bpf_usdt_readarg(5, ctx, &data.change_pos); |
| 90 | + bpf_usdt_readarg(1, ctx, &data.fee_ret); |
| 91 | + bpf_usdt_readarg(2, ctx, &data.fee_needed); |
94 | 92 | coin_selection_events.push(&data, 0); |
95 | 93 | return 0; |
96 | 94 | } |
|
99 | 97 |
|
100 | 98 | class CoinSelectionTracepointTest(BitcoinTestFramework): |
101 | 99 | def add_options(self, parser): |
102 | | - self.add_wallet_options(parser) |
| 100 | + pass |
103 | 101 |
|
104 | 102 | def set_test_params(self): |
105 | 103 | self.num_nodes = 1 |
@@ -165,9 +163,9 @@ def run_test(self): |
165 | 163 | self.log.info("hook into the coin_selection tracepoints") |
166 | 164 | ctx = USDT(pid=self.nodes[0].process.pid) |
167 | 165 | ctx.enable_probe(probe="coin_selection:selected_coins", fn_name="trace_selected_coins") |
168 | | - ctx.enable_probe(probe="coin_selection:normal_create_tx_internal", fn_name="trace_normal_create_tx") |
169 | | - ctx.enable_probe(probe="coin_selection:attempting_aps_create_tx", fn_name="trace_attempt_aps") |
170 | | - ctx.enable_probe(probe="coin_selection:aps_create_tx_internal", fn_name="trace_aps_create_tx") |
| 166 | + ctx.enable_probe(probe="coin_selection:coins_requested", fn_name="trace_coins_requested") |
| 167 | + ctx.enable_probe(probe="coin_selection:change_info", fn_name="trace_change_info") |
| 168 | + ctx.enable_probe(probe="coin_selection:fee_info", fn_name="trace_fee_info") |
171 | 169 | self.bpf = BPF(text=coinselection_tracepoints_program, usdt_contexts=[ctx], debug=0) |
172 | 170 |
|
173 | 171 | self.log.info("Prepare wallets") |
|
0 commit comments