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

fix: bank store migration #13813

Closed
wants to merge 1 commit into from

Conversation

okwme
Copy link
Contributor

@okwme okwme commented Nov 9, 2022

Description

Closes: #13797

While running an upgrade handler for gaia v8 we supplement the bank metadata. In doing so we found that the metadata was not retrievable using the new KV store pattern in v0.46. Coincidentally, we were trying to retrieve the metadata before the migration had been run. Ironically, after fixing the order, it was still not retrievable because there was a bug in how the store migration was written.

The current implementation infers that the store prefix needs to be included in the key, however the prefix is already omitted as part of the prefix store used in the migration code (and subsequent test).

We iterated over the whole store to check what was the key. When we incorrectly tried to retrieve before the migration we printed out a key of uatomuatom. Once we switched the migrations to run before we tried retrieving the metadata we printed out the key of uatomu. This demonstrates the migration is applied to a key of the wrong length. The addition of one letter is from the incorrect expectation that the store prefix (0x1) should be accounted for.

for ; oldDenomMetaDataIter.Valid(); oldDenomMetaDataIter.Next() {
		oldKey := oldDenomMetaDataIter.Key()
		l := len(oldKey)/2 + 1

instead of

for ; oldDenomMetaDataIter.Valid(); oldDenomMetaDataIter.Next() {
		oldKey := oldDenomMetaDataIter.Key()
		l := len(oldKey) / 2

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)

@julienrbrt
Copy link
Member

I think your PR should target main. Then we can use mergifyio to backport to v0.46

@alexanderbez
Copy link
Contributor

I think your PR should target main. Then we can use mergifyio to backport to v0.46

Si!

Also, how did other chains like Umee not run into this? This means the current migration is invalid. If so, that would infer that all current versions of 0.46.x are broken.

@okwme okwme changed the base branch from release/v0.46.x to main November 10, 2022 09:42
@okwme okwme changed the base branch from main to release/v0.46.x November 10, 2022 09:43
@okwme okwme mentioned this pull request Nov 10, 2022
19 tasks
@okwme
Copy link
Contributor Author

okwme commented Nov 10, 2022

closing in favor of #13821 which targets main.

@alexanderbez I don't believe anyone is using the on chain metadata information for anything important at this point. My understanding is that if you want to know the metadata of a token, generally you'd go to https://github.com/cosmos/chain-registry which also contains coin metadata.

@okwme okwme closed this Nov 10, 2022
@julienrbrt julienrbrt deleted the okwme/13797-bank-store-migration branch November 10, 2022 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants