From bbb452f60968390d904fad9c8f7ffb0d605e774d Mon Sep 17 00:00:00 2001 From: Matt Kocubinski Date: Tue, 13 Jun 2023 15:16:20 -0500 Subject: [PATCH] refactor(x/staking): rm dependency on x/distribution (#16531) --- .../staking/simulation/operations_test.go | 0 x/distribution/migrations/v2/store.go | 15 ++++++++------- x/slashing/migrations/v2/store.go | 8 ++++---- .../migrations/v2/helpers.go | 0 x/staking/migrations/v2/store.go | 13 ++++++------- 5 files changed, 18 insertions(+), 18 deletions(-) rename {x => tests/integration}/staking/simulation/operations_test.go (100%) rename x/{distribution => staking}/migrations/v2/helpers.go (100%) diff --git a/x/staking/simulation/operations_test.go b/tests/integration/staking/simulation/operations_test.go similarity index 100% rename from x/staking/simulation/operations_test.go rename to tests/integration/staking/simulation/operations_test.go diff --git a/x/distribution/migrations/v2/store.go b/x/distribution/migrations/v2/store.go index fe6aea2a5a..539ca9e731 100644 --- a/x/distribution/migrations/v2/store.go +++ b/x/distribution/migrations/v2/store.go @@ -6,6 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/runtime" sdk "github.com/cosmos/cosmos-sdk/types" v1 "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v1" + v2staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v2" ) // MigrateStore performs in-place store migrations from v0.40 to v0.43. The @@ -14,13 +15,13 @@ import ( // - Change addresses to be length-prefixed. func MigrateStore(ctx sdk.Context, storeService store.KVStoreService) error { store := runtime.KVStoreAdapter(storeService.OpenKVStore(ctx)) - MigratePrefixAddress(store, v1.ValidatorOutstandingRewardsPrefix) - MigratePrefixAddress(store, v1.DelegatorWithdrawAddrPrefix) - MigratePrefixAddressAddress(store, v1.DelegatorStartingInfoPrefix) - MigratePrefixAddressBytes(store, v1.ValidatorHistoricalRewardsPrefix) - MigratePrefixAddress(store, v1.ValidatorCurrentRewardsPrefix) - MigratePrefixAddress(store, v1.ValidatorAccumulatedCommissionPrefix) - MigratePrefixAddressBytes(store, v1.ValidatorSlashEventPrefix) + v2staking.MigratePrefixAddress(store, v1.ValidatorOutstandingRewardsPrefix) + v2staking.MigratePrefixAddress(store, v1.DelegatorWithdrawAddrPrefix) + v2staking.MigratePrefixAddressAddress(store, v1.DelegatorStartingInfoPrefix) + v2staking.MigratePrefixAddressBytes(store, v1.ValidatorHistoricalRewardsPrefix) + v2staking.MigratePrefixAddress(store, v1.ValidatorCurrentRewardsPrefix) + v2staking.MigratePrefixAddress(store, v1.ValidatorAccumulatedCommissionPrefix) + v2staking.MigratePrefixAddressBytes(store, v1.ValidatorSlashEventPrefix) return nil } diff --git a/x/slashing/migrations/v2/store.go b/x/slashing/migrations/v2/store.go index 6d1179ea12..aef0428f8f 100644 --- a/x/slashing/migrations/v2/store.go +++ b/x/slashing/migrations/v2/store.go @@ -6,8 +6,8 @@ import ( storetypes "cosmossdk.io/core/store" "github.com/cosmos/cosmos-sdk/runtime" - v2distribution "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v2" v1 "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v1" + v2staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v2" ) // MigrateStore performs in-place store migrations from v0.40 to v0.43. The @@ -16,9 +16,9 @@ import ( // - Change addresses to be length-prefixed. func MigrateStore(ctx context.Context, storeService storetypes.KVStoreService) error { store := runtime.KVStoreAdapter(storeService.OpenKVStore(ctx)) - v2distribution.MigratePrefixAddress(store, v1.ValidatorSigningInfoKeyPrefix) - v2distribution.MigratePrefixAddressBytes(store, v1.ValidatorMissedBlockBitArrayKeyPrefix) - v2distribution.MigratePrefixAddress(store, v1.AddrPubkeyRelationKeyPrefix) + v2staking.MigratePrefixAddress(store, v1.ValidatorSigningInfoKeyPrefix) + v2staking.MigratePrefixAddressBytes(store, v1.ValidatorMissedBlockBitArrayKeyPrefix) + v2staking.MigratePrefixAddress(store, v1.AddrPubkeyRelationKeyPrefix) return nil } diff --git a/x/distribution/migrations/v2/helpers.go b/x/staking/migrations/v2/helpers.go similarity index 100% rename from x/distribution/migrations/v2/helpers.go rename to x/staking/migrations/v2/helpers.go diff --git a/x/staking/migrations/v2/store.go b/x/staking/migrations/v2/store.go index 5bfde36c67..81872d23b2 100644 --- a/x/staking/migrations/v2/store.go +++ b/x/staking/migrations/v2/store.go @@ -7,7 +7,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" v1auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v1" - v2distribution "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v2" v1 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v1" "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -63,15 +62,15 @@ func migrateValidatorsByPowerIndexKey(store storetypes.KVStore) { func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey) error { store := ctx.KVStore(storeKey) - v2distribution.MigratePrefixAddress(store, v1.LastValidatorPowerKey) + MigratePrefixAddress(store, v1.LastValidatorPowerKey) - v2distribution.MigratePrefixAddress(store, v1.ValidatorsKey) - v2distribution.MigratePrefixAddress(store, v1.ValidatorsByConsAddrKey) + MigratePrefixAddress(store, v1.ValidatorsKey) + MigratePrefixAddress(store, v1.ValidatorsByConsAddrKey) migrateValidatorsByPowerIndexKey(store) - v2distribution.MigratePrefixAddressAddress(store, v1.DelegationKey) - v2distribution.MigratePrefixAddressAddress(store, v1.UnbondingDelegationKey) - v2distribution.MigratePrefixAddressAddress(store, v1.UnbondingDelegationByValIndexKey) + MigratePrefixAddressAddress(store, v1.DelegationKey) + MigratePrefixAddressAddress(store, v1.UnbondingDelegationKey) + MigratePrefixAddressAddress(store, v1.UnbondingDelegationByValIndexKey) migratePrefixAddressAddressAddress(store, v1.RedelegationKey) migratePrefixAddressAddressAddress(store, v1.RedelegationByValSrcIndexKey) migratePrefixAddressAddressAddress(store, v1.RedelegationByValDstIndexKey)