Commit 075eda3
authored
perf: Skip updating registry if signature has not changed (#3779)
Since verifying and updating the registry can be expensive on slower
devices, we can store the current signature and only re-verify when the
signature changes.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Stores and persists the registry signature to skip verification and
database updates when unchanged, updating controller logic and tests.
>
> - **Snaps Registry Controller (`json.ts`)**:
> - Add `signature` to `SnapsRegistryState` and controller metadata
(persisted, logged; not exposed to UI).
> - Update flow: fetch `registry.json` and `signature.json`, parse
signature; if `signature` matches state, skip verification/update and
only refresh `lastUpdated`/`databaseUnavailable`.
> - On change, verify using parsed `SignatureStruct` and persist new
`database` and `signature`.
> - Adjust `#verifySignature` to accept `SignatureStruct` (using
`@metamask/superstruct` `Infer`).
> - **Tests (`json.test.ts`)**:
> - Add test ensuring update is skipped when signature unchanged; update
metadata snapshots to include `signature`.
> - **Dependencies**:
> - Add `@metamask/superstruct`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
8ff96dd. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent dd973e4 commit 075eda3
File tree
4 files changed
+56
-4
lines changed- packages/snaps-controllers
- src/snaps/registry
4 files changed
+56
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
617 | 617 | | |
618 | 618 | | |
619 | 619 | | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
620 | 641 | | |
621 | 642 | | |
622 | 643 | | |
| |||
667 | 688 | | |
668 | 689 | | |
669 | 690 | | |
| 691 | + | |
670 | 692 | | |
671 | 693 | | |
672 | 694 | | |
| |||
681 | 703 | | |
682 | 704 | | |
683 | 705 | | |
| 706 | + | |
684 | 707 | | |
685 | 708 | | |
686 | 709 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
| |||
102 | 106 | | |
103 | 107 | | |
104 | 108 | | |
| 109 | + | |
105 | 110 | | |
106 | 111 | | |
107 | 112 | | |
| |||
110 | 115 | | |
111 | 116 | | |
112 | 117 | | |
| 118 | + | |
113 | 119 | | |
114 | 120 | | |
115 | 121 | | |
| |||
155 | 161 | | |
156 | 162 | | |
157 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
158 | 170 | | |
159 | 171 | | |
160 | 172 | | |
| |||
244 | 256 | | |
245 | 257 | | |
246 | 258 | | |
247 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
248 | 271 | | |
249 | 272 | | |
250 | 273 | | |
251 | 274 | | |
252 | 275 | | |
| 276 | + | |
253 | 277 | | |
254 | 278 | | |
255 | 279 | | |
| |||
402 | 426 | | |
403 | 427 | | |
404 | 428 | | |
405 | | - | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
406 | 433 | | |
407 | 434 | | |
408 | 435 | | |
409 | 436 | | |
410 | | - | |
| 437 | + | |
411 | 438 | | |
412 | 439 | | |
413 | 440 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4269 | 4269 | | |
4270 | 4270 | | |
4271 | 4271 | | |
| 4272 | + | |
4272 | 4273 | | |
4273 | 4274 | | |
4274 | 4275 | | |
| |||
0 commit comments