-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
Support keyring metadata in KeyringController #5112
Merged
+563
−84
Merged
Changes from 33 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
7f1608a
feat(multi-srp): add id and typeIndex to hd keyrings
PatrykLucka 281d85f
feat: use keyring index to select srp
PatrykLucka 9c88af9
fix: lock `KeyringController` mutex on `verifySeedPhrase` (#5077)
mikesposito ec9e428
feat(multi-srp): add id and typeIndex to hd keyrings
PatrykLucka cbb3803
feat: use keyring index to select srp
PatrykLucka af226d5
feat: add keyringsMetadata
PatrykLucka 3062aeb
feat: keep metadata in state only
PatrykLucka ad3e967
fix: revert keyringId arguments in getAccounts, and addNewAccount. Re…
montelaidev 3813a19
fix: handle keyringMetadata cleanup when removing emptyKeyrings and c…
montelaidev c1409bd
fix: remove keyringmetadata misalignement logic
PatrykLucka 8ba574c
fix: build
PatrykLucka 9559258
test(multi-srp): update unit tests coverage
PatrykLucka 40fac06
fix(multi-srp): clear keyringsMetadata on createNewVaultAndRestore
PatrykLucka bcaa0a3
feat(multi-srp): add keyring metadta to AccountsController keyring ob…
PatrykLucka 0256b1e
chore: add FIXME packages/keyring-controller/src/KeyringController.ts…
PatrykLucka 3265053
chore: fix lint issues
shane-t 1d4430b
fix: lint warnings
PatrykLucka 4645938
chore: prettier fix
shane-t 09c9430
chore: warning thresholds
shane-t d5981fa
fix(multi-srp): use internal variable instead of property for metada…
PatrykLucka 03c9731
chore(multi-srp): throw mismatch array outside of the update method
PatrykLucka ddd8737
fix(multi-srp): use push instead of spread operator for keyringsMetadata
PatrykLucka 4fbbd13
Merge branch 'main' into multi-srp-mvp
PatrykLucka 89746ba
Update packages/keyring-controller/src/KeyringController.ts
PatrykLucka 03509bc
Update packages/keyring-controller/src/KeyringController.ts
PatrykLucka ca5548b
Update packages/keyring-controller/src/KeyringController.ts
PatrykLucka aebc8a7
test(multi-srp): add remove last account test
PatrykLucka 5022d86
chore(multi-srp): move primary keyring removal protection to removeAc…
PatrykLucka ae1a759
chore: Improve error handling related to keyring metadata
Gudahtt cb58d7d
Merge branch 'main' into multi-srp-mvp
PatrykLucka f671b62
Merge branch 'improved-keyring-metadata-error-handling' into multi-sr…
PatrykLucka b93bbdf
test(multi-srp): update test coverage config
PatrykLucka 7a6b427
test(multi-srp): fix length mismatch unit test
PatrykLucka a0a1422
chore(multi-srp): review fixes
PatrykLucka f823f91
chore(multi-srp): revert AccountsController changes
PatrykLucka 66c3f05
chore(multi-srp): review changes
PatrykLucka 2fafa9d
Merge branch 'main' into multi-srp-mvp
PatrykLucka 03377ae
Merge branch 'main' into multi-srp-mvp
PatrykLucka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this? I think it has no real use, so I would remove it if possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ccharly I'll have to re-re-read (😅) the PR but I think it could be of use for account syncing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be useful indeed 🤔 even though, I'm not a fan of duplicating (kinda like mirroring, but here we truly are duplicating) state everywhere.
However, we must be careful with the
metadata
field, we do have a schema for theInternalAccount
and "native accounts" (or also named "normal accounts") which includes simple + HD keyring accounts, will also be re-created asInternalAccount
in theupdateAccounts
method of this controller.This controller re-creates internally its list of accounts based on keyring's accounts.
And I think having a "flat"
KeyringMetadata
here is not ideal. I would maybe add an intermediary field for this, likekeyringMetadata
maybe? It could also introduces conflicts and overwrites potentially, because of this logic:BTW, here's the list of "known metadata":
WDYT @montelaidev? @PatrykLucka is this already being used elsewhere in some other PRs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, the goal is to make it easier to find the keyring of a specific account. Since we can have multiple HD keyrings, it's now easier to query them by id. However, we will soon need to add entropySourceId, which will be essential to support multiple SRPs for snaps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entropySourceId
at the moment (though this doesn't exist in our code anywhere, only in our Architecture) is inaccount.options
The reasoning here is that an account snap can set this during the
AccountCreated
event (see this line here in "Multi-SRP for preinstalled account snaps"I'm not sure if this helps, just feel like it's the right time to highlight it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think your comment is on point actually @shane-t! That makes sense for Snap accounts, but to my knowledge, we don't have any use of the
options
bag for the "normal accounts". So IDK if we'll follow the same logic for those, but this we have to be decided (if not already 🙈).My comment here, was more about being careful of adding some new information to the
metadata
object (because of the wayInternalAccount
are being re-created internally).Also, after checking the accounts state, I'd say that
metadata.keyring.id
might be the safest option here (but could be a bit more tricky to implement).My recommendation here would be to remove this
keyringMetadata
from the logic of this PR if we don't use it now.We can always follow-up with a 2nd PR to re-introduce this if needed (but we'll have to discuss and add more tests to make sure nothing gets overwritten or cause conflicts).
WDYT @shane-t @PatrykLucka?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. As I understand it though, we have to find some way for @mathieuartu to read the keyring ID for
eth-hd-keyring
account related events, right?I might be off here, but the type that's needed in, is whatever type represents the event paylioad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need some form of metadata about the source of the account in the
accountAdded
/accountRenamed
events to be able to perform account sync properly.If we can get that information by some other means, please guide us to it.
A second PR would also be acceptable as long as it's within a similar timeframe.
Without this, we won't be able to filter events properly and you'll end up with a new account on your primary SRP every time a new account is added elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PatrykLucka could you elaborate on that? since
withKeyring
can be used with the{ address }
selector, isn't the account itself enough to access the keyring it belongs to?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to close up this thread, it has been decided to not inject those metadata for the moment. Account syncing will be addressed later with the addition of
entropySource
(see SIP-30).