fix: remove metadata for unsupported keyrings#5725
Conversation
|
If we remove the metadata, there's no way to get it back yeah? What's the purpose of adding the keyring to unsupportedKeyrings? Should we consider adding unsupportedKeyringsMetadata? |
@v-goyal Correct, if we remove metadata we won't get it back (that's the downside I was describing here). Unfortunately, we can't apply the same strategy we use for the unsupported keyrings because metadata is stored in the state directly instead of the vault, so removing them from the state would mean immediately persisting the new array of metadata. With keyrings, we don't need to worry about that because even if we skip one of them in the state (because unsupported), it'll still be kept in the vault unchanged and retried at the next unlock. A solution to do that with metadata would probably be to save them in the vault along with the keyring itself - that would save us a lot of headaches, but it's a more complex solution that would also require a strategy to migrate the existing metadata for users that already have it in the state |
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
I'm going to refactor this PR to implement this solution |
af27c1e to
765a3ae
Compare
Explanation
When the user vault is decrypted and there is an attempt to restore an unsupported/deprecated/faulty keyring there's no mechanism to remove related metadata, which leads to a situation where no further action can be made on the controller, because checks for keyrings and metadata length will fail.
We could remove the related metadata object when the keyring restore fails, but then we would lose the original ID generated for the keyring. We can, instead, change the place where the metadata is stored from a state property to the encrypted vault: by placing the metadata along with its serialised keyring in the vault we can guarantee a 1:1 link between them while being able to keep metadata for unsupported keyrings.
Given that we don't need to use the KeyringController state to persist metadata anymore (as it is persisted along with the vault), we can also remove
keyringsMetadatacompletely, and add ametadataattribute to each keyring instate.keyringsinstead - which won't be persisted, as it will be recreated at runtime every time the vault is decrypted and the keyrings are deserialised.References
Changelog
Checklist