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!: remove supply store key #883

Merged
merged 9 commits into from
May 31, 2022
Merged

Conversation

RiccardoM
Copy link
Contributor

@RiccardoM RiccardoM commented May 30, 2022

Description

This PR removes the supply store key that was wrongfully added to the app's store keys and was causing the following error:

panic: cannot delete latest saved version (XXXX)

Bug description

Previously to v0.42.0 the Cosmos SDK used a store key named supply to store the current supply of the tokens within the x/supply module. With v0.42.0 the x/supply module was merged into the x/bank module, but the store key was never deleted with any on-chain upgrade.

With version v3.1.0 and the introduction of our own x/supply module, we wrongfully added a store key named the same way (supply) to the app store keys (see here). This caused the application to crash during the loading of the store, as:

  1. the latest saved version of the supply store was set to a very old height, and
  2. the actual latest block height was a lot higher than that value.

Once this happens, usually the older versions of stores are deleted following the pruning strategy of the node. In this case though the supply store should have been deleted entirely, but Cosmos does not allow deleting the latest saved version of a store (unless we use an on-chain upgrade to remove the key). This is what caused the above error.


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)

RiccardoM and others added 3 commits May 15, 2022 10:31
Signed-off-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
Signed-off-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
@codecov
Copy link

codecov bot commented May 30, 2022

Codecov Report

Merging #883 (14c5cc0) into master (249e286) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #883   +/-   ##
=======================================
  Coverage   81.71%   81.71%           
=======================================
  Files         110      110           
  Lines        9255     9256    +1     
=======================================
+ Hits         7563     7564    +1     
  Misses       1370     1370           
  Partials      322      322           
Impacted Files Coverage Δ
app/app.go 86.74% <100.00%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 249e286...14c5cc0. Read the comment docs.

Signed-off-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
Signed-off-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
@RiccardoM RiccardoM changed the title fix: remove supply store key fix!: remove supply store key May 30, 2022
@RiccardoM RiccardoM changed the base branch from release/v3.1.x to release/v3.2.0 May 30, 2022 13:44
Signed-off-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
@github-actions github-actions bot added the kind/ci Improve the CI/CD label May 30, 2022
@RiccardoM RiccardoM added requires-upgrade Test the on-chain upgrade for this PR and removed kind/ci Improve the CI/CD labels May 30, 2022
@RiccardoM RiccardoM marked this pull request as ready for review May 30, 2022 14:06
@RiccardoM RiccardoM changed the base branch from release/v3.2.0 to master May 30, 2022 14:09
…remove-supply-store-key

� Conflicts:
�	.changeset/config.yaml
�	app/app.go
@github-actions github-actions bot added the kind/ci Improve the CI/CD label May 30, 2022
// StoreUpgrades implements upgrades.Upgrade
func (u *Upgrade) StoreUpgrades() *storetypes.StoreUpgrades {
return &storetypes.StoreUpgrades{
Added: []string{
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be Deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're totally right! Thanks for spotting this 🙏 My bad

Signed-off-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
@RiccardoM RiccardoM requested a review from dadamu May 31, 2022 06:37
@RiccardoM RiccardoM added the automerge Automatically merge PR once all prerequisites pass label May 31, 2022
@mergify mergify bot merged commit 4e7527d into master May 31, 2022
@mergify mergify bot deleted the riccardo/remove-supply-store-key branch May 31, 2022 07:35
RiccardoM added a commit that referenced this pull request May 31, 2022
## Description

This PR removes the `supply` store key that was wrongfully added to the app's store keys and was causing the following error:
```
panic: cannot delete latest saved version (XXXX)
```

### Bug description
Previously to `v0.42.0` the Cosmos SDK used a store key named `supply` to store the current supply of the tokens within the `x/supply` module. With `v0.42.0` the `x/supply` module was merged into the `x/bank` module, but the store key was never deleted with any on-chain upgrade.

With version `v3.1.0` and the introduction of our own `x/supply` module, we wrongfully added a store key named the same way (`supply`) to the app store keys (see [here](7481644#diff-0f1d2976054440336a576d47a44a37b80cdf6701dd9113012bce0e3c425819b7R339)). This caused the application to crash during the loading of the store, as:

1. the latest saved version of the `supply` store was set to a very old height, and
2. the actual latest block height was a lot higher than that value.

Once this happens, usually the older versions of stores are deleted following the pruning strategy of the node. In this case though the `supply` store should have been deleted entirely, but Cosmos does not allow deleting the latest saved version of a store (unless we use an on-chain upgrade to remove the key). This is what caused the above error.

---

### 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...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [x] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch (see [PR Targeting](https://github.com/desmos-labs/desmos/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://docs.cosmos.network/v0.44/building-modules/intro.html)
- [ ] included the necessary unit and integration [tests](https://github.com/desmos-labs/desmos/blob/master/CONTRIBUTING.md#testing)
- [x] 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)

(cherry picked from commit 4e7527d)
Signed-off-by: Riccardo Montagnin <riccardo.montagnin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Automatically merge PR once all prerequisites pass kind/ci Improve the CI/CD requires-upgrade Test the on-chain upgrade for this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants