Commit 02f11ed
authored
chore(async_trait): reduce usage of async_trait for small types again (#2634)
## Linked Issues/PRs
<!-- List of related issues/PRs -->
- none
## Description
<!-- List of detailed changes -->
this pr description is AI generated, pls take with a grain of salt
This pull request includes several changes to remove asynchronous traits
and methods, converting them to synchronous ones across various files.
The most important changes include modifying the `GasPriceEstimate`
trait and its implementations, updating test functions, and adjusting
mock expectations.
### Conversion to Synchronous Methods:
*
[`crates/fuel-core/src/graphql_api/ports.rs`](diffhunk://#diff-49095c45844c0809b8d244f4555fb1eaac1ee48612c103e553ab396d0dfe93c9L287-R289):
Removed the `async_trait` attribute from the `GasPriceEstimate` trait
and changed `worst_case_gas_price` to a synchronous method.
*
[`crates/fuel-core/src/service/adapters.rs`](diffhunk://#diff-c710afba67d6633c23d5f7487e423036b27c9f20ec4a8a1541827b366d6e346bL276-R271):
Updated the `GasPriceEstimate` implementations for
`UniversalGasPriceProvider` and `StaticGasPrice` to synchronous methods.
[[1]](diffhunk://#diff-c710afba67d6633c23d5f7487e423036b27c9f20ec4a8a1541827b366d6e346bL276-R271)
[[2]](diffhunk://#diff-28c7fdbc1cb25f3e25156f2a0efdd72cf86a6462fe131be225b15b48d6d3f524L184-R185)
*
[`crates/services/gas_price_service/src/common/gas_price_algorithm.rs`](diffhunk://#diff-38ab61925731d592d431bf2123324895adde7b539dfdc8de04a97f9efcd6c79dL26-R26):
Changed the `update` and `worst_case_gas_price` methods to synchronous.
[[1]](diffhunk://#diff-38ab61925731d592d431bf2123324895adde7b539dfdc8de04a97f9efcd6c79dL26-R26)
[[2]](diffhunk://#diff-38ab61925731d592d431bf2123324895adde7b539dfdc8de04a97f9efcd6c79dL40-R40)
### Updates to Test Functions:
*
[`crates/fuel-core/src/service/adapters.rs`](diffhunk://#diff-c710afba67d6633c23d5f7487e423036b27c9f20ec4a8a1541827b366d6e346bL103-R103):
Adjusted test functions to remove asynchronous calls and runtime blocks.
[[1]](diffhunk://#diff-c710afba67d6633c23d5f7487e423036b27c9f20ec4a8a1541827b366d6e346bL103-R103)
[[2]](diffhunk://#diff-c710afba67d6633c23d5f7487e423036b27c9f20ec4a8a1541827b366d6e346bL140-R142)
[[3]](diffhunk://#diff-c710afba67d6633c23d5f7487e423036b27c9f20ec4a8a1541827b366d6e346bL158-R160)
*
[`crates/services/sync/src/import/tests.rs`](diffhunk://#diff-06109df4a98a700afefcb2fbc43df2a20e44469d5e95c437f239f865a8e57d4cL39-R39):
Updated mock expectations to return pinned async blocks for various test
functions.
[[1]](diffhunk://#diff-06109df4a98a700afefcb2fbc43df2a20e44469d5e95c437f239f865a8e57d4cL39-R39)
[[2]](diffhunk://#diff-06109df4a98a700afefcb2fbc43df2a20e44469d5e95c437f239f865a8e57d4cL89-R89)
[[3]](diffhunk://#diff-06109df4a98a700afefcb2fbc43df2a20e44469d5e95c437f239f865a8e57d4cL153-R153)
[[4]](diffhunk://#diff-06109df4a98a700afefcb2fbc43df2a20e44469d5e95c437f239f865a8e57d4cL210-R210)
[[5]](diffhunk://#diff-06109df4a98a700afefcb2fbc43df2a20e44469d5e95c437f239f865a8e57d4cL268-R268)
[[6]](diffhunk://#diff-06109df4a98a700afefcb2fbc43df2a20e44469d5e95c437f239f865a8e57d4cL371-R371)
[[7]](diffhunk://#diff-06109df4a98a700afefcb2fbc43df2a20e44469d5e95c437f239f865a8e57d4cL477-R477)
[[8]](diffhunk://#diff-06109df4a98a700afefcb2fbc43df2a20e44469d5e95c437f239f865a8e57d4cR515-R525)
[[9]](diffhunk://#diff-06109df4a98a700afefcb2fbc43df2a20e44469d5e95c437f239f865a8e57d4cL564-R566)
[[10]](diffhunk://#diff-06109df4a98a700afefcb2fbc43df2a20e44469d5e95c437f239f865a8e57d4cL759-R761)
[[11]](diffhunk://#diff-06109df4a98a700afefcb2fbc43df2a20e44469d5e95c437f239f865a8e57d4cL805-R807)
[[12]](diffhunk://#diff-06109df4a98a700afefcb2fbc43df2a20e44469d5e95c437f239f865a8e57d4cL863-R865)
[[13]](diffhunk://#diff-06109df4a98a700afefcb2fbc43df2a20e44469d5e95c437f239f865a8e57d4cL943-R945)
### Removal of `async_trait`:
*
[`crates/fuel-core/src/service/adapters/sync.rs`](diffhunk://#diff-a58d36e1c68bf12145a84b084168b8b751c6178232ae412ed33bfec68723d894L145):
Removed `async_trait` from `BlockImporterPort` and `ConsensusPort`
implementations.
[[1]](diffhunk://#diff-a58d36e1c68bf12145a84b084168b8b751c6178232ae412ed33bfec68723d894L145)
[[2]](diffhunk://#diff-a58d36e1c68bf12145a84b084168b8b751c6178232ae412ed33bfec68723d894L163)
*
[`crates/services/sync/src/import/test_helpers/pressure_block_importer.rs`](diffhunk://#diff-f648b60371e32529d1a465ff14688f3719d3e9fc88a05ccf6997384cb2f80bcaL17):
Removed `async_trait` from `BlockImporterPort` implementation.
*
[`crates/services/sync/src/import/test_helpers/pressure_consensus.rs`](diffhunk://#diff-d377102e8f2624e710b799cb32de729d17cfde1e1a644596e856c9fb0edfceb2L16):
Removed `async_trait` from `ConsensusPort` implementation.
These changes collectively simplify the codebase by removing unnecessary
asynchronous complexity, making the code more straightforward and
potentially improving performance.
## Checklist
- [ ] Breaking changes are clearly marked as such in the PR description
and changelog
- [ ] New behavior is reflected in tests
- [ ] [The specification](https://github.com/FuelLabs/fuel-specs/)
matches the implemented behavior (link update PR if changes are needed)1 parent 17ed7d3 commit 02f11ed
File tree
13 files changed
+83
-79
lines changed- crates
- fuel-core/src
- graphql_api
- schema
- service
- adapters
- services
- gas_price_service/src
- common
- v0
- v1
- sync/src
- import
- test_helpers
- service
13 files changed
+83
-79
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
287 | | - | |
288 | 287 | | |
289 | 288 | | |
290 | | - | |
| 289 | + | |
291 | 290 | | |
292 | 291 | | |
293 | 292 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | 104 | | |
106 | 105 | | |
107 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 115 | + | |
119 | 116 | | |
120 | 117 | | |
121 | 118 | | |
| |||
137 | 134 | | |
138 | 135 | | |
139 | 136 | | |
140 | | - | |
141 | | - | |
| 137 | + | |
142 | 138 | | |
143 | 139 | | |
144 | 140 | | |
145 | 141 | | |
146 | | - | |
| 142 | + | |
147 | 143 | | |
148 | 144 | | |
149 | 145 | | |
| |||
155 | 151 | | |
156 | 152 | | |
157 | 153 | | |
158 | | - | |
159 | | - | |
160 | 154 | | |
161 | 155 | | |
162 | 156 | | |
163 | 157 | | |
164 | 158 | | |
165 | 159 | | |
166 | | - | |
| 160 | + | |
167 | 161 | | |
168 | 162 | | |
169 | 163 | | |
| |||
273 | 267 | | |
274 | 268 | | |
275 | 269 | | |
276 | | - | |
277 | 270 | | |
278 | | - | |
| 271 | + | |
279 | 272 | | |
280 | 273 | | |
281 | 274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
184 | | - | |
185 | 184 | | |
186 | | - | |
| 185 | + | |
187 | 186 | | |
188 | 187 | | |
189 | 188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
146 | 145 | | |
147 | 146 | | |
148 | 147 | | |
| |||
160 | 159 | | |
161 | 160 | | |
162 | 161 | | |
163 | | - | |
164 | 162 | | |
165 | 163 | | |
166 | 164 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | | - | |
| 65 | + | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | | - | |
238 | | - | |
| 237 | + | |
| 238 | + | |
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
307 | | - | |
| 307 | + | |
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
324 | | - | |
| 324 | + | |
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
37 | | - | |
| 36 | + | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
33 | | - | |
| 32 | + | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
0 commit comments