Move all migration scripts to v043 (#8814)

* 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>
This commit is contained in:
Amaury 2021-03-08 23:36:06 +01:00 committed by GitHub
parent c2d5b24f58
commit 6ac8898fec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 44 additions and 44 deletions

View File

@ -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`.
}
```

View File

@ -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.
@ -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)
}

View File

@ -1,4 +1,4 @@
package v042
package v043
import (
"github.com/cosmos/cosmos-sdk/codec"

View File

@ -1,4 +1,4 @@
package v042_test
package v043_test
import (
"testing"
@ -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"
)
@ -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.
@ -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...)

View File

@ -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.
@ -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)
}

View File

@ -1,4 +1,4 @@
package v042
package v043
import (
"github.com/cosmos/cosmos-sdk/store/prefix"

View File

@ -1,4 +1,4 @@
package v042
package v043
import (
sdk "github.com/cosmos/cosmos-sdk/types"

View File

@ -1,4 +1,4 @@
package v042_test
package v043_test
import (
"bytes"
@ -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"
)
@ -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.

View File

@ -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.
@ -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)
}

View File

@ -1,4 +1,4 @@
package v042
package v043
import (
"github.com/cosmos/cosmos-sdk/codec"

View File

@ -1,4 +1,4 @@
package v042_test
package v043_test
import (
"bytes"
@ -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"
)
@ -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.

View File

@ -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.
@ -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)
}

View File

@ -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"
)
@ -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
}

View File

@ -1,4 +1,4 @@
package v042_test
package v043_test
import (
"bytes"
@ -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"
)
@ -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.

View File

@ -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.
@ -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)
}

View File

@ -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"
)
@ -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)

View File

@ -1,4 +1,4 @@
package v042_test
package v043_test
import (
"bytes"
@ -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"
)
@ -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.