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!: Kerying migration #9222

Closed
wants to merge 133 commits into from
Closed

refactor!: Kerying migration #9222

wants to merge 133 commits into from

Conversation

cyberbono3
Copy link
Contributor

Description

This is draft PR
closes: #7108


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.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@github-actions github-actions bot added the T:Docs Changes and features related to documentation. label Apr 28, 2021
@lgtm-com
Copy link

lgtm-com bot commented Apr 28, 2021

This pull request introduces 1 alert when merging bcd9f81 into a2911d0 - view on LGTM.com

new alerts:

  • 1 for Expression has no effect

crypto/keyring/keyring.go Outdated Show resolved Hide resolved
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

  • pubkeys should be Any, not bytes, and we shouldn't cast to "crypto/ed25519.PublicKey"
  • A lot of information is already in pubkey (threshold, algo...), we don't need to duplicate anymore.

I'm also proposing a new model for representing *Info, using oneof.

proto/cosmos/crypto/keyring/types.proto Outdated Show resolved Hide resolved
proto/cosmos/crypto/keyring/types.proto Outdated Show resolved Hide resolved
proto/cosmos/crypto/keyring/types.proto Outdated Show resolved Hide resolved
proto/cosmos/crypto/keyring/types.proto Outdated Show resolved Hide resolved
proto/cosmos/crypto/keyring/types.proto Outdated Show resolved Hide resolved
proto/cosmos/crypto/keyring/types.proto Outdated Show resolved Hide resolved
proto/cosmos/crypto/keyring/types.proto Outdated Show resolved Hide resolved
@cyberbono3
Copy link
Contributor Author

cyberbono3 commented Apr 30, 2021

@robert-zaremba Can you review it, please?

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.

We need to update the proto definitions. Amaury has a good idea how to construct the KeyEntry. Moreover:

  • the migration is not correct
  • everywhere else (outside migration) we must use proto encoding
  • we need to add tests

crypto/keyring/info.go Outdated Show resolved Hide resolved
crypto/keyring/info.go Outdated Show resolved Hide resolved
crypto/keyring/keyring.go Outdated Show resolved Hide resolved
crypto/keyring/keyring.go Outdated Show resolved Hide resolved
crypto/keyring/keyring.go Outdated Show resolved Hide resolved
crypto/keyring/keyring.go Show resolved Hide resolved
crypto/keyring/keyring.go Outdated Show resolved Hide resolved
proto/cosmos/crypto/keyring/types.proto Outdated Show resolved Hide resolved
crypto/keyring/keyring.go Outdated Show resolved Hide resolved
proto/cosmos/crypto/keyring/types.proto Outdated Show resolved Hide resolved
crypto/keyring/keyring.go Outdated Show resolved Hide resolved
crypto/keyring/keyring.go Outdated Show resolved Hide resolved
crypto/keyring/keyring.go Outdated Show resolved Hide resolved
@lgtm-com
Copy link

lgtm-com bot commented Jul 13, 2021

This pull request introduces 1 alert when merging b0685fe into c23f386 - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

@cyberbono3 cyberbono3 force-pushed the kerying-migration branch 2 times, most recently from d3de827 to b0685fe Compare July 13, 2021 12:41
@lgtm-com
Copy link

lgtm-com bot commented Jul 13, 2021

This pull request introduces 1 alert when merging 24f44e8 into c23f386 - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

@lgtm-com
Copy link

lgtm-com bot commented Jul 13, 2021

This pull request introduces 1 alert when merging 8f239df into c23f386 - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

@lgtm-com
Copy link

lgtm-com bot commented Jul 13, 2021

This pull request introduces 1 alert when merging 8652e00 into 7040387 - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

some initial comments

Comment on lines +25 to +26
private/*.sh
test
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private/*.sh
test

@@ -118,8 +118,7 @@ func runAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *buf
}

if dryRun, _ := cmd.Flags().GetBool(flags.FlagDryRun); dryRun {
// use in memory keybase
kb = keyring.NewInMemory()
kb = keyring.NewInMemory(ctx.Codec)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
kb = keyring.NewInMemory(ctx.Codec)
// use in memory keybase
kb = keyring.NewInMemory(ctx.Codec)

@@ -1,50 +1,51 @@
package keyring
Copy link
Contributor

Choose a reason for hiding this comment

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

how about doing like in module, and creating a crypto/keyring/migrations package. Then all migration logic (including this legacyInfo) can go in that package.

@@ -0,0 +1,18 @@
syntax = "proto3";
package cosmos.crypto.hd;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
package cosmos.crypto.hd;
package cosmos.crypto.hd.v1;

oneof item {
Local local = 3;
Ledger ledger = 4;
Empty empty = 5;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we using empty? I think using Multi and Offline would be clearer, even both of them are empty structs

@cyberbono3 cyberbono3 closed this Jul 20, 2021
@amaury1093
Copy link
Contributor

superseded by #9695

@amaury1093 amaury1093 deleted the kerying-migration branch July 20, 2021 11:31
mergify bot pushed a commit that referenced this pull request Sep 20, 2021
<!--
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 #9222 
Closes: #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](#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
C:CLI C:Cosmovisor Issues and PR related to Cosmovisor C:Keys Keybase, KMS and HSMs C:x/auth C:x/authz C:x/bank C:x/distribution distribution module related C:x/feegrant C:x/genutil genutil module issues C:x/gov C:x/staking C:x/upgrade T:Docs Changes and features related to documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate Keyring to Protobuf
3 participants