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: Fix v0.45->v0.46 migration #12028

Merged
merged 13 commits into from
May 30, 2022
Merged

fix: Fix v0.45->v0.46 migration #12028

merged 13 commits into from
May 30, 2022

Conversation

amaury1093
Copy link
Contributor

@amaury1093 amaury1093 commented May 24, 2022

Description

closes #12027

  • Add tendermint key-migrate subcommand
  • Fix in-place store migrations

Test:

  • on v0.45 node, make a proposal to update software, make it pass
  • wait for node to halt
  • on v0.46 binary, run simd tendermint key-migrate
  • on v0.46 binary, run simd start --mode validator
  • make sure the v0.46 node runs correctly

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)

@amaury1093 amaury1093 added the backport/0.46.x PR scheduled for inclusion in the v0.46's next stable release label May 24, 2022
@amaury1093 amaury1093 marked this pull request as ready for review May 24, 2022 14:37
@amaury1093 amaury1093 requested a review from a team as a code owner May 24, 2022 14:37
@@ -19,6 +19,10 @@ func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Binar
}

func migrateParamsStore(ctx sdk.Context, paramstore paramtypes.Subspace) {
paramstore.WithKeyTable(types.ParamKeyTable())
paramstore.Set(ctx, types.KeyMinCommissionRate, types.DefaultMinCommissionRate)
if paramstore.HasKeyTable() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

encountered the same bug as in #9484, so applied the same fix

server/tm_cmds.go Outdated Show resolved Hide resolved
@facundomedica
Copy link
Member

Is there a way of adding this inside the upgrade handler somehow? Has this happened before (the fact that we need to run another separate command for an upgrade)?

Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

utACK

server/tm_cmds.go Show resolved Hide resolved
Comment on lines +408 to +410
// RegisterUpgradeHandlers is used for registering any on-chain upgrades.
// Make sure it's called after `app.mm` and `app.configurator` are set.
app.RegisterUpgradeHandlers()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel this should be communicated in the release notes too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Release notes imo are brief & high-level (see proposed defs in #11587).

How about int he UPGRADING.md document?

// ref: https://github.com/tendermint/tendermint/blob/master/UPGRADING.md#database-key-format-changes
func makeKeyMigrateCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "key-migrate",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a way of adding this inside the upgrade handler somehow? Has this happened before (the fact that we need to run another separate command for an upgrade)?

@facundomedica In the upgrade handler, no. See the original issue, we need to run the key migration before starting tendermint, so way before the upgrade handler is called.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternative solution, the SDK's start command is a combination of TM's key-migrate + start.
key-migrate is idempotent, so it can be run multiple times.

However, if we decide to show logs, as we do in this PR and as it's done in tendermint, then those logs will be shown on each startup:

11:55AM INF beginning a key migration dbctx=blockstore num=1 total=6
11:55AM INF beginning a key migration dbctx=state num=2 total=6
11:55AM INF beginning a key migration dbctx=peerstore num=3 total=6
11:55AM INF beginning a key migration dbctx=tx_index num=4 total=6
11:55AM INF beginning a key migration dbctx=evidence num=5 total=6
11:55AM INF beginning a key migration dbctx=light num=6 total=6

Any opinions on separate key-migrate and start commands VS one start command which runs key-migrate under the hood?

serverCtx := GetServerContextFromCmd(cmd)
config := serverCtx.Config

contexts := []string{
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm shocked we have to actually write any substantial code here. I would've presumed Tendermint would've exposed a command that'll do all of this for us?

In any case, does Tendermint not expose the contexts we want to migrate?

Copy link
Contributor Author

@amaury1093 amaury1093 May 27, 2022

Choose a reason for hiding this comment

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

TM exposes:

https://github.com/tendermint/tendermint/blob/f33722b4233159a31cdf6c33258fbc601cdbd1d4/cmd/tendermint/commands/key_migrate.go#L15

But it needs additional flags to get the DB dir right. In this PR, we use the same code, but with serverCtx.

I couldn't think of less code re-use, best I could do was to mention this was copy-pasted from tendermint - like other commands in that file.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Such an easy problem to solve if the TM command just had a function that the command called instead. Sigh...

@alexanderbez
Copy link
Contributor

I don't like that we have to implement the command in such a manner, but if there's no other choice, then oh well.

@tac0turtle
Copy link
Member

I don't like that we have to implement the command in such a manner, but if there's no other choice, then oh well.

tendermint should of made it automatic, imo. having a command like this will cause sooooooooo many problems.

@amaury1093
Copy link
Contributor Author

amaury1093 commented May 27, 2022

tendermint should of made it automatic, imo. having a command like this will cause sooooooooo many problems.

Is this a better UX for sdk users? #12028 (comment)

@amaury1093
Copy link
Contributor Author

I'll automerge this, so that we can fix the network issues more easily, e.g. have #12067 also incorporate these changes here.

@amaury1093 amaury1093 added the A:automerge Automatically merge PR once all prerequisites pass. label May 27, 2022
@mergify mergify bot merged commit ca0b8f9 into main May 30, 2022
@mergify mergify bot deleted the am/fix-045-046-mig branch May 30, 2022 08:17
mergify bot pushed a commit that referenced this pull request May 30, 2022
## Description

closes #12027

- Add `tendermint key-migrate` subcommand
- Fix in-place store migrations

Test:
- on v0.45 node, make a proposal to update software, make it pass
- wait for node to halt
- on v0.46 binary, run `simd tendermint key-migrate`
- on v0.46 binary, run `simd start --mode validator`
- make sure the v0.46 node runs correctly

---

### 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/main/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/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/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
- [ ] 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 ca0b8f9)

# Conflicts:
#	simapp/upgrades.go
alexanderbez pushed a commit that referenced this pull request May 30, 2022
* fix: Fix v0.45->v0.46 migration (#12028)

## Description

closes #12027

- Add `tendermint key-migrate` subcommand
- Fix in-place store migrations

Test:
- on v0.45 node, make a proposal to update software, make it pass
- wait for node to halt
- on v0.46 binary, run `simd tendermint key-migrate`
- on v0.46 binary, run `simd start --mode validator`
- make sure the v0.46 node runs correctly

---

### 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/main/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/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/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
- [ ] 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 ca0b8f9)

# Conflicts:
#	simapp/upgrades.go

* fix conflicts

* Update changelog

Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
gsk967 pushed a commit to vulcanize/cosmos-sdk that referenced this pull request Jun 21, 2022
* fix: Fix v0.45->v0.46 migration (cosmos#12028)

closes cosmos#12027

- Add `tendermint key-migrate` subcommand
- Fix in-place store migrations

Test:
- on v0.45 node, make a proposal to update software, make it pass
- wait for node to halt
- on v0.46 binary, run `simd tendermint key-migrate`
- on v0.46 binary, run `simd start --mode validator`
- make sure the v0.46 node runs correctly

---

*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/main/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/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/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
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

*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 ca0b8f9)

* fix conflicts

* Update changelog

Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
## Description

closes cosmos#12027 

- Add `tendermint key-migrate` subcommand
- Fix in-place store migrations

Test:
- on v0.45 node, make a proposal to update software, make it pass
- wait for node to halt
- on v0.46 binary, run `simd tendermint key-migrate`
- on v0.46 binary, run `simd start --mode validator`
- make sure the v0.46 node runs correctly



---

### 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/main/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/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/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
- [ ] 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)
JeancarloBarrios pushed a commit to agoric-labs/cosmos-sdk that referenced this pull request Sep 28, 2024
* fix: Fix v0.45->v0.46 migration (cosmos#12028)

## Description

closes cosmos#12027

- Add `tendermint key-migrate` subcommand
- Fix in-place store migrations

Test:
- on v0.45 node, make a proposal to update software, make it pass
- wait for node to halt
- on v0.46 binary, run `simd tendermint key-migrate`
- on v0.46 binary, run `simd start --mode validator`
- make sure the v0.46 node runs correctly

---

### 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/main/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/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/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
- [ ] 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 ca0b8f9)

# Conflicts:
#	simapp/upgrades.go

* fix conflicts

* Update changelog

Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
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. backport/0.46.x PR scheduled for inclusion in the v0.46's next stable release C:x/staking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Software upgrade fails from v0.45.4 to v0.46.0-rc1
6 participants