-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fix keys migrate
command
#8703
Fix keys migrate
command
#8703
Conversation
@@ -111,6 +111,10 @@ type Importer interface { | |||
|
|||
// ImportPubKey imports ASCII armored public keys. | |||
ImportPubKey(uid string, armor string, keyType KeyType) error |
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.
ImportPubKey
is only used in tests now. I propose to remove it in a subsequent PR (to not introduce breaking change). For reasons, see #8703 (comment).
@@ -327,6 +331,15 @@ func (ks keystore) ImportPubKey(uid string, armor string, keyType KeyType) error | |||
return nil | |||
} | |||
|
|||
// MigrateInfo implements Importer.MigrateInfo. | |||
func (ks keystore) MigrateInfo(oldInfo Info) error { |
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.
This is only for Type{Multi,Ledger,Offline}
.
Before
The old migration logic was inside ImportPubKey
: we read data from the old Info, decode it (depending on the type), extract pubkey, and create and write a new Info in the new keyring.
In the process, we completely lose the Info: we were migrating old TypeMulti and old TypeLedger into new TypeOffline. #8639 (comment)
After
We don't decode Info anymore (to extract pubkey etc). Since the infos didn't change, we just copy/paste the old Info into the new keyring. It's imo much simpler.
Let me try |
It works now! Thanks @AmauryM, shall we merge back to original? |
Thank you so very much @AmauryM ! |
Fix `keys migrate` command (#8703) crypto/keyring: reinstate the InfoImporter interface InfoImporter is implemented by those Keyring implementations that support import of Info objects. Co-authored-by: Alessio Treglia <alessio@tendermint.com> Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com> Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
Fix `keys migrate` command (#8703) crypto/keyring: reinstate the InfoImporter interface InfoImporter is implemented by those Keyring implementations that support import of Info objects. Co-authored-by: Alessio Treglia <alessio@tendermint.com> Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com> Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
* crypto/keyring: fix offline keys migration (#8639) Fix `keys migrate` command (#8703) crypto/keyring: reinstate the InfoImporter interface InfoImporter is implemented by those Keyring implementations that support import of Info objects. Co-authored-by: Alessio Treglia <alessio@tendermint.com> Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com> Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com> * refresh golangci-lint * Rename InfoImporter -> LegacyInfoImporter (#8739) Avoid namespace clash with the InfoImporter interface that already exists in the v0.41 release series. * Revert "refresh golangci-lint" This reverts commit 38e1349. Co-authored-by: SaReN <sahithnarahari@gmail.com> Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com> Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
Description
ref: #8639
I have no idea what the
keys migrate
was doing, but imo it was bugged for multiple reasons:--home
flags: one for the location of the old keyring, and one for the location of the new keyring. I added a--old-home
flag to it.--old-home ~/.gaiacli --home ~/.gaiad
TypeLocal
to aTypeLocal
(that's correct), aTypeOffline
to aTypeOffline
(correct too), but migratedType{Ledger,Multi}
both toTypeOffline
(why???). Anyways, now the migration migrates to the correct keyring type.Tests
I followed Sahith's test steps with a ledger key, and could migrate & sign with a tx with the new keyring
We should test:
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes