Skip to content

Commit

Permalink
Move all migration scripts to v043 (#8814)
Browse files Browse the repository at this point in the history
* Move all migration scripts to v043

* Fix permaling

* Fix test

* Fix test again

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
amaury1093 and mergify[bot] authored Mar 8, 2021
1 parent c2d5b24 commit 6ac8898
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion docs/architecture/adr-041-in-place-store-migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Since migration functions manipulate legacy code, they should live inside the `l
```go
// Migrate1to2 migrates from version 1 to 2.
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
return v042bank.MigrateStore(ctx, m.keeper.storeKey) // v042bank is package `x/bank/legacy/v042`.
return v043bank.MigrateStore(ctx, m.keeper.storeKey) // v043bank is package `x/bank/legacy/v043`.
}
```

Expand Down
4 changes: 2 additions & 2 deletions x/bank/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
v042 "github.com/cosmos/cosmos-sdk/x/bank/legacy/v042"
v043 "github.com/cosmos/cosmos-sdk/x/bank/legacy/v043"
)

// Migrator is a struct for handling in-place store migrations.
Expand All @@ -17,5 +17,5 @@ func NewMigrator(keeper BaseKeeper) Migrator {

// Migrate1to2 migrates from version 1 to 2.
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
return v042.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc)
return v043.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v042
package v043

import (
"github.com/cosmos/cosmos-sdk/codec"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v042_test
package v043_test

import (
"testing"
Expand All @@ -11,7 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
v040bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v040"
v042bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v042"
v043bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v043"
"github.com/cosmos/cosmos-sdk/x/bank/types"
)

Expand All @@ -29,7 +29,7 @@ func TestSupplyMigration(t *testing.T) {
store.Set(v040bank.SupplyKey, encCfg.Marshaler.MustMarshalBinaryBare(&oldSupply))

// Run migration.
err := v042bank.MigrateStore(ctx, bankKey, encCfg.Marshaler)
err := v043bank.MigrateStore(ctx, bankKey, encCfg.Marshaler)
require.NoError(t, err)

// New supply is indexed by denom.
Expand All @@ -55,7 +55,7 @@ func TestBalanceKeysMigration(t *testing.T) {
oldKey := append(append(v040bank.BalancesPrefix, addr...), denom...)
store.Set(oldKey, value)

err := v042bank.MigrateStore(ctx, bankKey, encCfg.Marshaler)
err := v043bank.MigrateStore(ctx, bankKey, encCfg.Marshaler)
require.NoError(t, err)

newKey := append(types.CreateAccountBalancesPrefix(addr), denom...)
Expand Down
4 changes: 2 additions & 2 deletions x/distribution/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
v042 "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v042"
v043 "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v043"
)

// Migrator is a struct for handling in-place store migrations.
Expand All @@ -17,5 +17,5 @@ func NewMigrator(keeper Keeper) Migrator {

// Migrate1to2 migrates from version 1 to 2.
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
return v042.MigrateStore(ctx, m.keeper.storeKey)
return v043.MigrateStore(ctx, m.keeper.storeKey)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v042
package v043

import (
"github.com/cosmos/cosmos-sdk/store/prefix"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v042
package v043

import (
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v042_test
package v043_test

import (
"bytes"
Expand All @@ -10,7 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
v040distribution "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v040"
v042distribution "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v042"
v043distribution "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v043"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
)

Expand Down Expand Up @@ -83,7 +83,7 @@ func TestStoreMigration(t *testing.T) {
}

// Run migrations.
err := v042distribution.MigrateStore(ctx, distributionKey)
err := v043distribution.MigrateStore(ctx, distributionKey)
require.NoError(t, err)

// Make sure the new keys are set and old keys are deleted.
Expand Down
4 changes: 2 additions & 2 deletions x/gov/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
v042 "github.com/cosmos/cosmos-sdk/x/gov/legacy/v042"
v043 "github.com/cosmos/cosmos-sdk/x/gov/legacy/v043"
)

// Migrator is a struct for handling in-place store migrations.
Expand All @@ -17,5 +17,5 @@ func NewMigrator(keeper Keeper) Migrator {

// Migrate1to2 migrates from version 1 to 2.
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
return v042.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc)
return v043.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc)
}
2 changes: 1 addition & 1 deletion x/gov/legacy/v042/store.go → x/gov/legacy/v043/store.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v042
package v043

import (
"github.com/cosmos/cosmos-sdk/codec"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v042_test
package v043_test

import (
"bytes"
Expand All @@ -12,7 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
v040gov "github.com/cosmos/cosmos-sdk/x/gov/legacy/v040"
v042gov "github.com/cosmos/cosmos-sdk/x/gov/legacy/v042"
v043gov "github.com/cosmos/cosmos-sdk/x/gov/legacy/v043"
"github.com/cosmos/cosmos-sdk/x/gov/types"
)

Expand Down Expand Up @@ -75,7 +75,7 @@ func TestStoreMigration(t *testing.T) {
}

// Run migrations.
err := v042gov.MigrateStore(ctx, govKey, cdc)
err := v043gov.MigrateStore(ctx, govKey, cdc)
require.NoError(t, err)

// Make sure the new keys are set and old keys are deleted.
Expand Down
4 changes: 2 additions & 2 deletions x/slashing/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
v042 "github.com/cosmos/cosmos-sdk/x/slashing/legacy/v042"
v043 "github.com/cosmos/cosmos-sdk/x/slashing/legacy/v043"
)

// Migrator is a struct for handling in-place store migrations.
Expand All @@ -17,5 +17,5 @@ func NewMigrator(keeper Keeper) Migrator {

// Migrate1to2 migrates from version 1 to 2.
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
return v042.MigrateStore(ctx, m.keeper.storeKey)
return v043.MigrateStore(ctx, m.keeper.storeKey)
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package v042
package v043

import (
sdk "github.com/cosmos/cosmos-sdk/types"
v042distribution "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v042"
v043distribution "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v043"
v040slashing "github.com/cosmos/cosmos-sdk/x/slashing/legacy/v040"
)

Expand All @@ -12,9 +12,9 @@ import (
// - Change addresses to be length-prefixed.
func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey) error {
store := ctx.KVStore(storeKey)
v042distribution.MigratePrefixAddress(store, v040slashing.ValidatorSigningInfoKeyPrefix)
v042distribution.MigratePrefixAddressBytes(store, v040slashing.ValidatorMissedBlockBitArrayKeyPrefix)
v042distribution.MigratePrefixAddress(store, v040slashing.AddrPubkeyRelationKeyPrefix)
v043distribution.MigratePrefixAddress(store, v040slashing.ValidatorSigningInfoKeyPrefix)
v043distribution.MigratePrefixAddressBytes(store, v040slashing.ValidatorMissedBlockBitArrayKeyPrefix)
v043distribution.MigratePrefixAddress(store, v040slashing.AddrPubkeyRelationKeyPrefix)

return nil
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v042_test
package v043_test

import (
"bytes"
Expand All @@ -10,7 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
v040slashing "github.com/cosmos/cosmos-sdk/x/slashing/legacy/v040"
v042slashing "github.com/cosmos/cosmos-sdk/x/slashing/legacy/v042"
v043slashing "github.com/cosmos/cosmos-sdk/x/slashing/legacy/v043"
"github.com/cosmos/cosmos-sdk/x/slashing/types"
)

Expand Down Expand Up @@ -52,7 +52,7 @@ func TestStoreMigration(t *testing.T) {
}

// Run migrations.
err := v042slashing.MigrateStore(ctx, slashingKey)
err := v043slashing.MigrateStore(ctx, slashingKey)
require.NoError(t, err)

// Make sure the new keys are set and old keys are deleted.
Expand Down
4 changes: 2 additions & 2 deletions x/staking/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
v042 "github.com/cosmos/cosmos-sdk/x/staking/legacy/v042"
v043 "github.com/cosmos/cosmos-sdk/x/staking/legacy/v043"
)

// Migrator is a struct for handling in-place store migrations.
Expand All @@ -17,5 +17,5 @@ func NewMigrator(keeper Keeper) Migrator {

// Migrate1to2 migrates from version 1 to 2.
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
return v042.MigrateStore(ctx, m.keeper.storeKey)
return v043.MigrateStore(ctx, m.keeper.storeKey)
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package v042
package v043

import (
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
v040auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040"
v042distribution "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v042"
v043distribution "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v043"
v040staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v040"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
Expand Down Expand Up @@ -61,15 +61,15 @@ func migrateValidatorsByPowerIndexKey(store sdk.KVStore) {
func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey) error {
store := ctx.KVStore(storeKey)

v042distribution.MigratePrefixAddress(store, v040staking.LastValidatorPowerKey)
v043distribution.MigratePrefixAddress(store, v040staking.LastValidatorPowerKey)

v042distribution.MigratePrefixAddress(store, v040staking.ValidatorsKey)
v042distribution.MigratePrefixAddress(store, v040staking.ValidatorsByConsAddrKey)
v043distribution.MigratePrefixAddress(store, v040staking.ValidatorsKey)
v043distribution.MigratePrefixAddress(store, v040staking.ValidatorsByConsAddrKey)
migrateValidatorsByPowerIndexKey(store)

v042distribution.MigratePrefixAddressAddress(store, v040staking.DelegationKey)
v042distribution.MigratePrefixAddressAddress(store, v040staking.UnbondingDelegationKey)
v042distribution.MigratePrefixAddressAddress(store, v040staking.UnbondingDelegationByValIndexKey)
v043distribution.MigratePrefixAddressAddress(store, v040staking.DelegationKey)
v043distribution.MigratePrefixAddressAddress(store, v040staking.UnbondingDelegationKey)
v043distribution.MigratePrefixAddressAddress(store, v040staking.UnbondingDelegationByValIndexKey)
migratePrefixAddressAddressAddress(store, v040staking.RedelegationKey)
migratePrefixAddressAddressAddress(store, v040staking.RedelegationByValSrcIndexKey)
migratePrefixAddressAddressAddress(store, v040staking.RedelegationByValDstIndexKey)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v042_test
package v043_test

import (
"bytes"
Expand All @@ -11,7 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
v040staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v040"
v042staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v042"
v043staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v043"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
Expand Down Expand Up @@ -121,7 +121,7 @@ func TestStoreMigration(t *testing.T) {
}

// Run migrations.
err := v042staking.MigrateStore(ctx, stakingKey)
err := v043staking.MigrateStore(ctx, stakingKey)
require.NoError(t, err)

// Make sure the new keys are set and old keys are deleted.
Expand Down

0 comments on commit 6ac8898

Please sign in to comment.