Commit c128c75
Txpool v2 insertion (#2193)
REVIEWER NOTE : Review #2162
first for context
## Linked Issues/PRs
Closes #2186
## Description
This PR allows you to insert `Transaction` in the `TxPool v2` service
and so perform all the necessary verifications and the insertion.
### Changes in code logic from `TxPool v1`
- The verifications are performed in a new order specified in #2186. The
goal is to avoid making the computation heavy work if the simple checks
aren't valid. In this new version we also ensure that verifications are
done in order by having wrapper type around each step to allow only one
verification path.
- The insertion is performed in a separate thread pool, the goal is to
not block the pool on any verifications/insertions and to manage the
ressources we allocate to these works
- The insertion rules and conditions has change to the following :
- A transaction with dependencies can collide only with one other
transaction
- A transaction without dependencies can collide with multiple
transaction
- Rules to free up space for new transaction
- If a transaction is colliding with another verify if deleting the
colliding transaction and dependents subtree is enough otherwise refuses
the tx
- If a transaction is dependent and not enough space, don't accept
transaction
- If a transaction is executable, try to free has much space used by
less profitable transactions as possible in the pool to include it
- New limits on the size of the pool : `max_pool_bytes_size and
max_pool_gas`
### Changes from the base branch `txpool-v2`
All the tests has been refactored to be way more clearer to understand
and easier to read. They also now all follow the naming and the GWT
convention.
## Checklist
- [x] Breaking changes are clearly marked as such in the PR description
and changelog
- [x] New behavior is reflected in tests
- [x] [The specification](https://github.com/FuelLabs/fuel-specs/)
matches the implemented behavior (link update PR if changes are needed)
### Before requesting review
- [x] I have reviewed the code myself
- [x] I have created follow-up issues caused by this PR and linked them
here
---------
Co-authored-by: Green Baneling <[email protected]>1 parent 0bbdaf5 commit c128c75
File tree
23 files changed
+2301
-1660
lines changed- crates
- services/txpool_v2
- src
- collision_manager
- selection_algorithms
- storage
- tests
- types/src/services
23 files changed
+2301
-1660
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
| 24 | + | |
22 | 25 | | |
| 26 | + | |
23 | 27 | | |
24 | | - | |
25 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
Lines changed: 76 additions & 68 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 41 | + | |
43 | 42 | | |
44 | 43 | | |
45 | 44 | | |
| |||
76 | 75 | | |
77 | 76 | | |
78 | 77 | | |
79 | | - | |
| 78 | + | |
80 | 79 | | |
81 | 80 | | |
82 | | - | |
83 | | - | |
84 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
85 | 106 | | |
86 | 107 | | |
87 | | - | |
88 | | - | |
| 108 | + | |
89 | 109 | | |
90 | 110 | | |
91 | | - | |
| 111 | + | |
92 | 112 | | |
93 | 113 | | |
94 | 114 | | |
95 | 115 | | |
96 | | - | |
97 | | - | |
98 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
99 | 119 | | |
100 | 120 | | |
101 | 121 | | |
102 | 122 | | |
103 | 123 | | |
104 | 124 | | |
105 | 125 | | |
106 | | - | |
107 | | - | |
108 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
109 | 129 | | |
110 | 130 | | |
111 | 131 | | |
112 | 132 | | |
113 | 133 | | |
114 | 134 | | |
115 | 135 | | |
116 | | - | |
| 136 | + | |
117 | 137 | | |
118 | 138 | | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
124 | 142 | | |
125 | 143 | | |
126 | 144 | | |
127 | 145 | | |
128 | 146 | | |
129 | 147 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
162 | 152 | | |
163 | 153 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
171 | 173 | | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
176 | 183 | | |
| 184 | + | |
177 | 185 | | |
178 | 186 | | |
179 | 187 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
3 | 6 | | |
4 | 7 | | |
5 | 8 | | |
| |||
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
16 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
17 | 23 | | |
18 | 24 | | |
19 | 25 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | 26 | | |
58 | 27 | | |
59 | 28 | | |
60 | 29 | | |
61 | 30 | | |
62 | 31 | | |
63 | | - | |
64 | | - | |
65 | | - | |
| 32 | + | |
| 33 | + | |
66 | 34 | | |
67 | 35 | | |
68 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
69 | 46 | | |
70 | | - | |
| 47 | + | |
71 | 48 | | |
72 | 49 | | |
73 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
| |||
124 | 125 | | |
125 | 126 | | |
126 | 127 | | |
127 | | - | |
128 | | - | |
| 128 | + | |
| 129 | + | |
129 | 130 | | |
130 | 131 | | |
| 132 | + | |
| 133 | + | |
131 | 134 | | |
132 | 135 | | |
133 | 136 | | |
134 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
135 | 156 | | |
136 | 157 | | |
137 | 158 | | |
| |||
140 | 161 | | |
141 | 162 | | |
142 | 163 | | |
143 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
144 | 169 | | |
145 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
146 | 175 | | |
147 | 176 | | |
148 | 177 | | |
0 commit comments