Commit 216b0a6
authored
perf: speed up adding transactions (#7205)
## Explanation
Minor optimisations to `addTransaction` and `addTransactionBatch`
methods:
- Don't await initial gas limit and gas fee estimation if
`skipInitialGasEstimate` set.
- Skip EIP-7702 request and upgrade check if `disableUpgrade` set.
- Do not wait for `delegationAddress` and instead update asynchronously.
- Skip unnecessary `eth_getCode` requests when determining transaction
type.
- Only decode transfer recipient for first time interaction validation
if transaction type suitable.
## References
Related to
[#6165](MetaMask/MetaMask-planning#6165)
## Checklist
- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [x] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Speeds up `addTransaction`/`addTransactionBatch` by allowing async gas
estimation and skipping EIP-7702 upgrade checks, plus tighter type
handling and first‑time interaction optimizations.
>
> - **Transaction add flow (performance)**:
> - Add `skipInitialGasEstimate` to `addTransaction` and
`addTransactionBatch`; when set, skip blocking gas calc and update gas
fields asynchronously.
> - Resolve `delegationAddress` asynchronously post-add; remove from
initial snapshot, update later.
> - **Batch (EIP-7702) changes**:
> - Add `disableUpgrade` to `TransactionBatchRequest`; when set, bypass
upgrade check and avoid type `0x4` (setCode) path.
> - Propagate `skipInitialGasEstimate` from batch to underlying
`addTransaction`.
> - Use provided nested transaction `type` directly; only infer when not
supplied.
> - **First-time interaction**:
> - Only decode recipient from `data` when `type` is
`tokenMethodTransfer` or `tokenMethodTransferFrom`; otherwise fall back
to `to`.
> - **Misc**:
> - Import `noop` to safely swallow async errors; minor test updates and
slight coverage threshold tweak.
> - Changelog updated accordingly.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
4ed214f. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 2785995 commit 216b0a6
File tree
9 files changed
+149
-29
lines changed- packages/transaction-controller
- src
- utils
9 files changed
+149
-29
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
10 | 16 | | |
11 | 17 | | |
12 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1686 | 1686 | | |
1687 | 1687 | | |
1688 | 1688 | | |
1689 | | - | |
1690 | 1689 | | |
1691 | 1690 | | |
1692 | 1691 | | |
| |||
Lines changed: 54 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
1239 | 1239 | | |
1240 | 1240 | | |
1241 | 1241 | | |
| 1242 | + | |
1242 | 1243 | | |
1243 | 1244 | | |
1244 | 1245 | | |
| |||
1311 | 1312 | | |
1312 | 1313 | | |
1313 | 1314 | | |
1314 | | - | |
1315 | | - | |
1316 | 1315 | | |
1317 | 1316 | | |
1318 | 1317 | | |
| |||
1325 | 1324 | | |
1326 | 1325 | | |
1327 | 1326 | | |
1328 | | - | |
1329 | 1327 | | |
1330 | 1328 | | |
1331 | 1329 | | |
| |||
1360 | 1358 | | |
1361 | 1359 | | |
1362 | 1360 | | |
1363 | | - | |
1364 | | - | |
1365 | | - | |
1366 | | - | |
1367 | | - | |
1368 | | - | |
1369 | | - | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
1370 | 1395 | | |
1371 | 1396 | | |
1372 | 1397 | | |
| |||
1401 | 1426 | | |
1402 | 1427 | | |
1403 | 1428 | | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
1404 | 1447 | | |
1405 | 1448 | | |
1406 | 1449 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1723 | 1723 | | |
1724 | 1724 | | |
1725 | 1725 | | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
1726 | 1729 | | |
1727 | 1730 | | |
1728 | 1731 | | |
| |||
1747 | 1750 | | |
1748 | 1751 | | |
1749 | 1752 | | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
1750 | 1756 | | |
1751 | 1757 | | |
1752 | 1758 | | |
| |||
2100 | 2106 | | |
2101 | 2107 | | |
2102 | 2108 | | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
2103 | 2112 | | |
2104 | 2113 | | |
2105 | 2114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
647 | 647 | | |
648 | 648 | | |
649 | 649 | | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
650 | 688 | | |
651 | 689 | | |
652 | 690 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
260 | 267 | | |
261 | 268 | | |
262 | 269 | | |
263 | 270 | | |
264 | 271 | | |
265 | | - | |
266 | 272 | | |
267 | 273 | | |
268 | | - | |
| 274 | + | |
269 | 275 | | |
270 | 276 | | |
271 | 277 | | |
| |||
288 | 294 | | |
289 | 295 | | |
290 | 296 | | |
| 297 | + | |
291 | 298 | | |
292 | 299 | | |
293 | 300 | | |
294 | 301 | | |
295 | 302 | | |
296 | 303 | | |
| 304 | + | |
297 | 305 | | |
298 | 306 | | |
299 | 307 | | |
| |||
311 | 319 | | |
312 | 320 | | |
313 | 321 | | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
| 322 | + | |
321 | 323 | | |
322 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
323 | 339 | | |
324 | | - | |
325 | | - | |
326 | | - | |
| 340 | + | |
327 | 341 | | |
328 | 342 | | |
329 | 343 | | |
| |||
339 | 353 | | |
340 | 354 | | |
341 | 355 | | |
342 | | - | |
| 356 | + | |
343 | 357 | | |
344 | 358 | | |
345 | 359 | | |
| |||
409 | 423 | | |
410 | 424 | | |
411 | 425 | | |
| 426 | + | |
412 | 427 | | |
413 | 428 | | |
414 | 429 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| |||
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
| 140 | + | |
139 | 141 | | |
140 | 142 | | |
141 | 143 | | |
| |||
165 | 167 | | |
166 | 168 | | |
167 | 169 | | |
| 170 | + | |
168 | 171 | | |
169 | 172 | | |
170 | 173 | | |
| |||
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
63 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
64 | 71 | | |
65 | 72 | | |
66 | 73 | | |
| |||
0 commit comments