MetaMask / MetaMask/metamask-extension
Improve safety of migrations
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 5.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 451
Description
Our state migrations can sometimes leave users in unrecoverable states, or lead to loss of data. This can happen not just when we introduce bugs in the migration script, but also when the user's state has been corrupted somehow in a way that we didn't anticipate.
We should strive to ensure our migrations never result in either of these two states. In a recent standup we discussed various prevention ideas:
* More comprehensive unit tests, to ensure that invalid state remains no worse off than it started when the migration is run
* Save a copy of the previous state whenever a migration fails, for us to use to recover data in a future migration
* Use TypeScript to ensure we write more robust migrations (specifically using the `unknown` type, so we are forced to test every assumption)
* Write e2e tests for migrations
* Re-initialize to a blank state in all relevant controllers whenever an error is encountered (maybe in combination with the "save a copy of previous state" idea).
This issue represents the continued exploration of how we can improve the safety of our migrations. We may want to consider additional ideas, and build prototypes to investigate the effectiveness/feasibility of these ideas. The output should be a concrete plan for how to improve our migrations (or the solution itself, if that's easier).
Contributor guide
Research direction
Start by reviewing the state migration scripts and the relevant controllers, then examine existing unit and end-to-end migration tests. Compare the proposed safeguards: invalid-state tests, failed-state backups, TypeScript unknown types, and blank-state reinitialization. Done means producing a concrete migration-safety plan or implementing a validated solution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100