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

refactor!: Keyring migration #9695

Merged
merged 302 commits into from
Sep 20, 2021
Merged

refactor!: Keyring migration #9695

merged 302 commits into from
Sep 20, 2021

Conversation

cyberbono3
Copy link
Contributor

@cyberbono3 cyberbono3 commented Jul 14, 2021

Description

The draft PR #9222
Closes: #7108

  • implement proto definition for Record
  • rename Info.go to legacyInfo.go within keyring package
  • implement CLI migrate command that migrates all keys from legacyInfo to proto according to @robert-zaremba migration algorithm
  • remove legacy keybase entirely.
  • add Migrate and MigrateAll functions in keyring.go for single key and all keys migration
  • add tests
  • fix tests

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

client/keys/list_test.go Outdated Show resolved Hide resolved
client/keys/utils.go Outdated Show resolved Hide resolved
@cyberbono3 cyberbono3 mentioned this pull request Sep 13, 2021
2 tasks
Copy link
Collaborator

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre approving

  • Keyring.List() should not return nil keys
  • remove not needed printlns

Thanks for your comments Andrei - they help with the final review.

client/keys/list.go Outdated Show resolved Hide resolved
client/keys/list_test.go Outdated Show resolved Hide resolved
cmd.PrintErrln("Migration complete.")

return err
cmd.Println("Keys migration has been successfully executed")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one you can leave. But you should remove most of other printlns.

}

return priv, nil
// case legacyLedgerInfo, legacyOfflineInfo, LegacyMultiInfo:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error is better than panic.

return priv, nil
// case legacyLedgerInfo, legacyOfflineInfo, LegacyMultiInfo:
default:
return nil, errors.New("only works on local private keys")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the error message, please add the legacyLocalInfo, eg:

fmt.Errorf("only works on local private keys, provided %s", linfo)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See Comment what other printlns do you mean, @robert-zaremba ?

@cyberbono3
Copy link
Contributor Author

cyberbono3 commented Sep 17, 2021

See Comment What other printlns do you mean, @robert-zaremba ?

require.Equal(t, newKey.GetType(), oldKey.GetType())
}
func requireEqualRenamedKey(t *testing.T, key *Record, mnemonic *Record, nameMatch bool) {
if nameMatch {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added 'nameMatch' argument to requireEqualRenamedKey as in some cases i dont need name check ( e.g. at L1319). If it is set to true, it checks if key.Name and mnemonic.Name match as you can see below. I hope it sounds good to you, @robert-zaremba

@cyberbono3 cyberbono3 added the A:automerge Automatically merge PR once all prerequisites pass. label Sep 20, 2021
@mergify mergify bot merged commit 6cbbd6d into master Sep 20, 2021
@mergify mergify bot deleted the cyberbono3/keyring-migration branch September 20, 2021 12:02
@amaury1093
Copy link
Contributor

Thanks a lot @cyberbono3 for your work on this PR!

@alessio
Copy link
Contributor

alessio commented Sep 20, 2021

I hope this work was completed putting legacy clients first and ensuring that Cosmos Hub users would not stumble on any disruption whatsoever. Else, you will hear people shouting very, very loud and from all directions with the next release.

As a word of advice, I'd test this thoroughly before releasing it.

@amaury1093 amaury1093 mentioned this pull request Oct 11, 2021
19 tasks
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
<!--
The default pull request template is for types feat, fix, or refactor.
For other templates, add one of the following parameters to the url:
- template=docs.md
- template=other.md
-->

## Description

The draft PR cosmos#9222 
Closes: cosmos#7108

<!-- Add a description of the changes that this PR introduces and the files that
are the most critical to review. -->

- implement proto definition for `Record` 
- rename `Info.go` to `legacyInfo.go` within `keyring` package
- implement CLI `migrate` command that migrates all keys from  legacyInfo to proto according to @robert-zaremba migration [algorithm](cosmos#9222)
- remove legacy keybase entirely.
- add `Migrate` and `MigrateAll` functions  in `keyring.go` for single key and all keys migration
- add tests
- fix tests

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [x] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:CLI C:Keys Keybase, KMS and HSMs C:x/auth C:x/authz C:x/feegrant C:x/genutil genutil module issues C:x/gov C:x/staking C:x/upgrade
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate Keyring to Protobuf
5 participants