Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve safety of migrations #10694

Open
Gudahtt opened this issue Mar 22, 2021 · 1 comment
Open

Improve safety of migrations #10694

Gudahtt opened this issue Mar 22, 2021 · 1 comment
Labels
area-state contributor experience An issue that impacts, or planned improvement to, the contributor experience. type-enhancement

Comments

@Gudahtt
Copy link
Member

Gudahtt commented Mar 22, 2021

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).

@Gudahtt
Copy link
Member Author

Gudahtt commented Apr 4, 2022

Currently the fixture we use in e2e tests is just... whatever state the wallet was in when the test was written. We don't make a habit of updating fixtures, so problems resulting from specific wallet states may go undetected by CI.

We could adopt a practice of regularly updating fixtures to match the latest production wallet state. This would ensure our CI tests match the experience of current production users more closely. Or we could keep a collection of fixtures to represent new, currrent, and older users. e.g. each fixture would have a version for:

  • The current wallet state
  • The current production wallet state
  • An ancient wallet state

Currently updating fixtures is a manual process. It's not trivial to automate it because state changes might happen as a result of a migration, or it might happen because of a change in a controller. The only reliable way to get an updated fixture is to run the real extension and export the state after initialization. We could automate fixture updates by doing exactly that though, and using our e2e tooling to start the extension up and export state to disk.

@brad-decker brad-decker added the contributor experience An issue that impacts, or planned improvement to, the contributor experience. label Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-state contributor experience An issue that impacts, or planned improvement to, the contributor experience. type-enhancement
Projects
None yet
Development

No branches or pull requests

2 participants