Commit b0b0ad6
committed
Merge dashpay#6770: refactor: follow-up dash#6742, implement review suggestions, avoid redundant transaction queries
f488c43 fix: remove unnecessary tx fetching in `RemoveMempoolConflictsForLock` (Kittywhiskers Van Gogh)
dd54011 refactor: move inexpensive checks earlier in `ProcessInstantSendLock()` (Kittywhiskers Van Gogh)
c86d886 refactor: abstract away InstantSend parent implementation from signer (Kittywhiskers Van Gogh)
cbfd325 refactor: avoid shared_ptr copies in `{WriteNew,Remove}InstantSendLock()` (Kittywhiskers Van Gogh)
234a16a refactor: use unordered set for faster duplicates checking (Kittywhiskers Van Gogh)
0459848 refactor: `constexpr` static string definitions (Kittywhiskers Van Gogh)
710c504 refactor: s/cs_inputReqests/cs_input_requests/g (Kittywhiskers Van Gogh)
31065d1 chore: mark `hashBlock` as unused in `HandleNewInputLockRecoveredSig()` (Kittywhiskers Van Gogh)
cf47f14 chore: apply most `clang-format` suggestions (Kittywhiskers Van Gogh)
63371e0 trivial: move forward declaration above `using` declarations (Kittywhiskers Van Gogh)
Pull request description:
## Additional Information
* Dependent on dashpay#6742
* This pull request aims to address reviewer concerns raised during [dash#6742](dashpay#6742), the following changes were made with that in mind
* Marking unused variable `hashBlock` by prefixing with underscore, [comment](dashpay#6742 (comment))
* Correct typo in variable name `cs_inputReqests` (now `cs_input_requests`, [comment](dashpay#6770 (comment))), [comment](dashpay#6742 (comment))
* Using `constexpr` for `std::string_view`s, [comment](dashpay#6742 (comment))
* Utilizing a faster way to validate uniqueness of entries (`std::unordered_set`), [comment](dashpay#6742 (comment)). The construction of the unordered set is inspired by similar usage in `policy/package.cpp` ([source](https://github.com/dashpay/dash/blob/f648039258d2192ec5e505721e34edaa0bda568c/src/policy/packages.cpp#L51)).
* Avoiding unnecessary `std::shared_ptr` copying (`InstantSendLockPtr` is a `std::shared_ptr<InstantSendLock>`), [comment](dashpay#6742 (comment))
* Resolving circular dependency by cherry-picking 1e2e854, [comment](dashpay#6742 (comment)) but has been renamed to `InstantSendSignerParent`. For rationale, see [comment](dashpay#6761 (comment)).
* Additionally, optimizations have been made to `ProcessInstantSendLock()`
* The _cheaper_ database checks have been moved _earlier_ in the function to allow for faster bail-out. This is alongside consolidating network requests to the tail of the function and general cleanup for better clarity.
* Dropping the peer request for a transaction we know about in `RemoveMempoolConflictsForLock()` (introduced in [dash#2898](dashpay#2898)) as `ProcessInstantSendLock()` calls it when we _know_ about the transaction and seek to remove conflicts ([source](https://github.com/dashpay/dash/blob/f648039258d2192ec5e505721e34edaa0bda568c/src/instantsend/instantsend.cpp#L419-L420))
The only other caller, `TransactionAddedToMempool()` calls it when we have knowledge of the transaction and want to purge conflicts from the mempool ([source](https://github.com/dashpay/dash/blob/f648039258d2192ec5e505721e34edaa0bda568c/src/instantsend/instantsend.cpp#L455-L463)).
In both cases, we already know the _good_ transaction. Additionally, tests introduced in [dash#2898](dashpay#2898) still pass ([source](https://github.com/dashpay/dash/blob/f648039258d2192ec5e505721e34edaa0bda568c/test/functional/p2p_instantsend.py#L95-L142)), indicating a lack of regression but this change may require additional scrutiny.
## Breaking Changes
None expected.
## Checklist
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)**
- [x] I have added or updated relevant unit/integration/functional/e2e tests **(note: N/A)**
- [x] I have made corresponding changes to the documentation **(note: N/A)**
- [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_
ACKs for top commit:
PastaPastaPasta:
utACK f488c43
knst:
utACK f488c43
UdjinM6:
utACK f488c43
Tree-SHA512: dcd153e14747639f8dbbbd5c3bea1123e4f84f82884787992e20f494227913763bf19a73b485e345dddb63ad551c856bc56dcad72e67304f84df60cb76deaa74File tree
9 files changed
+187
-179
lines changed- src
- instantsend
- test/lint
9 files changed
+187
-179
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
53 | | - | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
57 | | - | |
58 | | - | |
59 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | | - | |
65 | | - | |
66 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
71 | | - | |
| 72 | + | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | 76 | | |
81 | 77 | | |
82 | | - | |
83 | | - | |
| 78 | + | |
| 79 | + | |
84 | 80 | | |
85 | 81 | | |
86 | 82 | | |
87 | 83 | | |
88 | 84 | | |
89 | | - | |
90 | | - | |
| 85 | + | |
| 86 | + | |
91 | 87 | | |
92 | 88 | | |
93 | 89 | | |
| |||
151 | 147 | | |
152 | 148 | | |
153 | 149 | | |
154 | | - | |
| 150 | + | |
155 | 151 | | |
156 | 152 | | |
157 | 153 | | |
| |||
221 | 217 | | |
222 | 218 | | |
223 | 219 | | |
224 | | - | |
| 220 | + | |
| 221 | + | |
225 | 222 | | |
226 | 223 | | |
227 | 224 | | |
| |||
241 | 238 | | |
242 | 239 | | |
243 | 240 | | |
244 | | - | |
| 241 | + | |
| 242 | + | |
245 | 243 | | |
246 | 244 | | |
247 | 245 | | |
| |||
354 | 352 | | |
355 | 353 | | |
356 | 354 | | |
357 | | - | |
| 355 | + | |
| 356 | + | |
358 | 357 | | |
359 | 358 | | |
360 | 359 | | |
| |||
374 | 373 | | |
375 | 374 | | |
376 | 375 | | |
377 | | - | |
| 376 | + | |
378 | 377 | | |
379 | 378 | | |
380 | 379 | | |
| |||
384 | 383 | | |
385 | 384 | | |
386 | 385 | | |
387 | | - | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
388 | 389 | | |
389 | 390 | | |
390 | 391 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
91 | | - | |
| 92 | + | |
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
| |||
0 commit comments