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

EPIC: Remove bech32 globals #9690

Closed
1 of 10 tasks
amaury1093 opened this issue Jul 13, 2021 · 7 comments
Closed
1 of 10 tasks

EPIC: Remove bech32 globals #9690

amaury1093 opened this issue Jul 13, 2021 · 7 comments
Assignees

Comments

@amaury1093
Copy link
Contributor

amaury1093 commented Jul 13, 2021

Summary

Remove bech32 globals, move the bech32 prefix as a x/auth keeper field.

Problem Definition

See #7448 for context.

Proposal

The idea is to remove the bech32 global defined in types/address.go, and put it as a parameter into the auth keeper (like we do for codecs).

  • @cyberbono3 Step 1 (updated). Add auth keeper methods and gRPC queries:

    • Make new field string bech32Prefix on auth AccountKeeper struct
    • auth AccountKeeper implements AddressCdc interface that contains 2 methods: AddressStringToBytes and AddressBytesToString
    • Add the 3 following gRPC queries:
      • Get bech32 prefix
      • AddressString (converts AccountAddr string to AccountAddr bytes)
      • AddressBytes( converts AccountAddr bytes to AccountAddr str)
    • Add the corresponding keeper methods
    • Add tests
  • Step 2. Go through all modules, and for each module perform the following checklist. We can create 1 PR for maybe 2-3 modules.

    • Checklist:
      • Audit for all sdk.*bech32* functions in modules (e.g. sdk.Bech32ifyAddressBytes, sdk.AccAddressFromBech32), and replace them with a call to x/auth keeper method.
  • Step 3. Cleanup.

    • Remove sdk.*bech32* from non-module code.
    • Remove global from types/address.go.
  • Some other TODOs:

  • Remove address verifier from global config, put it as argument to NewAccountKeeper

  • Support cosmos.msg.v1.signer as alternative to Msg.GetSigners #11275


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@amaury1093
Copy link
Contributor Author

We just had a WG meeting discussing this, meeting notes are here: #7091.

The idea is to move the the bech32 prefix string as a x/auth keeper field. See the 1st post for a proposal broken up into small steps.

@amaury1093 amaury1093 added this to the v0.44 milestone Jul 13, 2021
@alexanderbez
Copy link
Contributor

This would mean any and all utilities that need to bech32 encode or decode an address would need access to the x/auth keeper?

@aaronc
Copy link
Member

aaronc commented Jul 13, 2021

All other keepers would. But we would need to figure out a client solution - maybe with client.Context or AccountRetriever.

@cyberbono3 cyberbono3 self-assigned this Jul 20, 2021
mergify bot pushed a commit that referenced this issue Aug 25, 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

Closes **Step1** from #9690

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

- Add auth keeper methods and gRPC queries:
  - the `NewAccountKeeper` should take a `string bech32Prefix` argument
  - ` auth AccountKeeper` implements `Codec` interface that contains 2 methods:  `ConvertAddressStringToBytes` and `ConvertAddressBytesToString` 
  - Add the 3 following gRPC queries:
    - Get bech32 prefix
    - `AddressStringToBytes` (converts `AccountAddr` string to `AccountAddr` bytes)
    - `AddressBytesToString` ( converts `AccountAddr` bytes to `AccountAddr` str)
  - Add the corresponding keeper methods
  - Add 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)
- [x] added a changelog entry to `CHANGELOG.md`
- [x] 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)
@jackzampolin
Copy link
Member

jackzampolin commented Sep 15, 2021

I think client.Context and giving the context a prefix should solve this issue for clients. Seems like the cleanest solution

@aaronc
Copy link
Member

aaronc commented Sep 24, 2021

@AmauryM this is duplicated by #9957 and #7448. Can we do a little tidying up of the issue board?

@amaury1093
Copy link
Contributor Author

#9957 has been closed in favor of this issue.

Still keepeing #7448 because it's about the whole sdk.Config, while this is specifically about bech32.

@tac0turtle tac0turtle removed this from the v0.46 milestone Jan 13, 2022
@tac0turtle tac0turtle changed the title Remove bech32 globals EPIC: Remove bech32 globals Sep 2, 2022
@tac0turtle tac0turtle added the T:Epic Epics label Sep 2, 2022
@tac0turtle
Copy link
Member

closing in favour of #13140

@tac0turtle tac0turtle reopened this Apr 14, 2023
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this issue 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

Closes **Step1** from cosmos#9690

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

- Add auth keeper methods and gRPC queries:
  - the `NewAccountKeeper` should take a `string bech32Prefix` argument
  - ` auth AccountKeeper` implements `Codec` interface that contains 2 methods:  `ConvertAddressStringToBytes` and `ConvertAddressBytesToString` 
  - Add the 3 following gRPC queries:
    - Get bech32 prefix
    - `AddressStringToBytes` (converts `AccountAddr` string to `AccountAddr` bytes)
    - `AddressBytesToString` ( converts `AccountAddr` bytes to `AccountAddr` str)
  - Add the corresponding keeper methods
  - Add 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)
- [x] added a changelog entry to `CHANGELOG.md`
- [x] 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
Projects
None yet
Development

No branches or pull requests

6 participants