From c263e1aa9373e2b922e47fabb67c5fd139a5855b Mon Sep 17 00:00:00 2001 From: zakir <80246097+zakir-code@users.noreply.github.com> Date: Fri, 8 Mar 2024 13:34:25 +0800 Subject: [PATCH] style: remove migrator for module (#254) --- x/avalanche/module.go | 7 +- x/bsc/module.go | 7 +- x/crosschain/keeper/migrations.go | 32 ------ x/crosschain/migrations/v4/migrator_param.go | 23 ---- .../migrations/v4/migrator_param_test.go | 74 ------------- x/erc20/keeper/migrations.go | 33 ------ x/erc20/migrations/v4/migrator_param.go | 23 ---- x/erc20/migrations/v4/migrator_param_test.go | 73 ------------- x/erc20/module.go | 5 - x/eth/module.go | 7 +- x/gov/keeper/migrations.go | 30 ----- x/gov/migrations/v046/convert.go | 53 --------- x/gov/migrations/v046/store.go | 95 ---------------- x/gov/migrations/v046/store_test.go | 103 ------------------ x/gov/module.go | 10 -- x/polygon/module.go | 7 +- x/tron/module.go | 7 +- 17 files changed, 5 insertions(+), 584 deletions(-) delete mode 100644 x/crosschain/keeper/migrations.go delete mode 100644 x/crosschain/migrations/v4/migrator_param.go delete mode 100644 x/crosschain/migrations/v4/migrator_param_test.go delete mode 100644 x/erc20/keeper/migrations.go delete mode 100644 x/erc20/migrations/v4/migrator_param.go delete mode 100644 x/erc20/migrations/v4/migrator_param_test.go delete mode 100644 x/gov/keeper/migrations.go delete mode 100644 x/gov/migrations/v046/convert.go delete mode 100644 x/gov/migrations/v046/store.go delete mode 100644 x/gov/migrations/v046/store_test.go diff --git a/x/avalanche/module.go b/x/avalanche/module.go index 7de4c5fba..a5292c478 100644 --- a/x/avalanche/module.go +++ b/x/avalanche/module.go @@ -111,12 +111,7 @@ func (am AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier { } // RegisterServices registers module services. -func (am AppModule) RegisterServices(cfg module.Configurator) { - migrator := crosschainkeeper.NewMigrator(am.keeper, am.legacySubspace) - if err := cfg.RegisterMigration(am.Name(), 1, migrator.Migrate3to4); err != nil { - panic(err) - } -} +func (am AppModule) RegisterServices(cfg module.Configurator) {} // InitGenesis initializes the genesis state for this module and implements app module. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { diff --git a/x/bsc/module.go b/x/bsc/module.go index 74b39a440..6fc21dcf8 100644 --- a/x/bsc/module.go +++ b/x/bsc/module.go @@ -111,12 +111,7 @@ func (am AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier { } // RegisterServices registers module services. -func (am AppModule) RegisterServices(cfg module.Configurator) { - migrator := crosschainkeeper.NewMigrator(am.keeper, am.legacySubspace) - if err := cfg.RegisterMigration(am.Name(), 3, migrator.Migrate3to4); err != nil { - panic(err) - } -} +func (am AppModule) RegisterServices(cfg module.Configurator) {} // InitGenesis initializes the genesis state for this module and implements app module. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { diff --git a/x/crosschain/keeper/migrations.go b/x/crosschain/keeper/migrations.go deleted file mode 100644 index 4ec265ce4..000000000 --- a/x/crosschain/keeper/migrations.go +++ /dev/null @@ -1,32 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - v4 "github.com/functionx/fx-core/v7/x/crosschain/migrations/v4" - "github.com/functionx/fx-core/v7/x/crosschain/types" -) - -// Migrator is a struct for handling in-place store migrations. -type Migrator struct { - keeper Keeper - legacySubspace types.Subspace -} - -func NewMigrator(k Keeper, ss types.Subspace) Migrator { - return Migrator{ - keeper: k, - legacySubspace: ss, - } -} - -// Migrate3to4 migrates the x/crosschain module state from the consensus version 3 to -// version 4. Specifically, it takes the parameters that are currently stored -// and managed by the x/params modules and stores them directly into the x/crosschain -// module state. -func (m Migrator) Migrate3to4(ctx sdk.Context) error { - if err := v4.MigratorParam(ctx, m.legacySubspace, m.keeper.storeKey, m.keeper.cdc); err != nil { - return err - } - return nil -} diff --git a/x/crosschain/migrations/v4/migrator_param.go b/x/crosschain/migrations/v4/migrator_param.go deleted file mode 100644 index e549b4fd6..000000000 --- a/x/crosschain/migrations/v4/migrator_param.go +++ /dev/null @@ -1,23 +0,0 @@ -package v4 - -import ( - "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/functionx/fx-core/v7/x/crosschain/types" -) - -func MigratorParam(ctx sdk.Context, legacySubspace types.Subspace, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { - if !legacySubspace.HasKeyTable() { - legacySubspace.WithKeyTable(types.ParamKeyTable()) - } - var currParams types.Params - legacySubspace.GetParamSet(ctx, &currParams) - if err := currParams.ValidateBasic(); err != nil { - return err - } - bz := cdc.MustMarshal(&currParams) - ctx.KVStore(storeKey).Set(types.ParamsKey, bz) - return nil -} diff --git a/x/crosschain/migrations/v4/migrator_param_test.go b/x/crosschain/migrations/v4/migrator_param_test.go deleted file mode 100644 index a15c9d04d..000000000 --- a/x/crosschain/migrations/v4/migrator_param_test.go +++ /dev/null @@ -1,74 +0,0 @@ -package v4_test - -import ( - "testing" - - "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/testutil" - sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/stretchr/testify/require" - - bsctypes "github.com/functionx/fx-core/v7/x/bsc/types" - v4 "github.com/functionx/fx-core/v7/x/crosschain/migrations/v4" - "github.com/functionx/fx-core/v7/x/crosschain/types" -) - -type mockSubspace struct { - ps types.Params -} - -func newMockSubspace(ps types.Params) mockSubspace { - return mockSubspace{ps: ps} -} - -func (ms mockSubspace) GetParamSet(_ sdk.Context, ps paramtypes.ParamSet) { - *ps.(*types.Params) = ms.ps -} - -func (ms mockSubspace) HasKeyTable() bool { - return false -} - -func (ms mockSubspace) WithKeyTable(_ paramtypes.KeyTable) paramtypes.Subspace { - return paramtypes.Subspace{} -} - -func TestStoreMigration(t *testing.T) { - encCfg := simapp.MakeTestEncodingConfig() - bscKey := sdk.NewKVStoreKey(bsctypes.ModuleName) - tBscKey := sdk.NewTransientStoreKey("transient_test") - ctx := testutil.DefaultContext(bscKey, tBscKey) - store := ctx.KVStore(bscKey) - - legacySubspace := newMockSubspace(types.DefaultParams()) - - testCases := []struct { - name string - doMigration bool - }{ - { - name: "without state migration", - doMigration: false, - }, - { - name: "with state migration", - doMigration: true, - }, - } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - if tc.doMigration { - require.NoError(t, v4.MigratorParam(ctx, legacySubspace, bscKey, encCfg.Codec)) - } - if tc.doMigration { - var res types.Params - bz := store.Get(types.ParamsKey) - require.NoError(t, encCfg.Codec.Unmarshal(bz, &res)) - require.Equal(t, legacySubspace.ps, res) - } else { - require.Equal(t, true, true) - } - }) - } -} diff --git a/x/erc20/keeper/migrations.go b/x/erc20/keeper/migrations.go deleted file mode 100644 index df3afae7d..000000000 --- a/x/erc20/keeper/migrations.go +++ /dev/null @@ -1,33 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - v4 "github.com/functionx/fx-core/v7/x/erc20/migrations/v4" - "github.com/functionx/fx-core/v7/x/erc20/types" -) - -// Migrator is a struct for handling in-place store migrations. -type Migrator struct { - keeper Keeper - legacySubspace types.Subspace -} - -// NewMigrator returns a new Migrator. -func NewMigrator(keeper Keeper, ss types.Subspace) Migrator { - return Migrator{ - keeper: keeper, - legacySubspace: ss, - } -} - -// Migrate3to4 migrates the x/erc20 module state from the consensus version 3 to -// version 4. Specifically, it takes the parameters that are currently stored -// and managed by the x/params modules and stores them directly into the x/erc20 -// module state. -func (k Migrator) Migrate3to4(ctx sdk.Context) error { - if err := v4.MigratorParam(ctx, k.legacySubspace, k.keeper.storeKey, k.keeper.cdc); err != nil { - return err - } - return nil -} diff --git a/x/erc20/migrations/v4/migrator_param.go b/x/erc20/migrations/v4/migrator_param.go deleted file mode 100644 index 1803958cc..000000000 --- a/x/erc20/migrations/v4/migrator_param.go +++ /dev/null @@ -1,23 +0,0 @@ -package v4 - -import ( - "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/functionx/fx-core/v7/x/erc20/types" -) - -func MigratorParam(ctx sdk.Context, legacySubspace types.Subspace, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { - if !legacySubspace.HasKeyTable() { - legacySubspace.WithKeyTable(types.ParamKeyTable()) - } - var currParams types.Params - legacySubspace.GetParamSet(ctx, &currParams) - if err := currParams.Validate(); err != nil { - return err - } - bz := cdc.MustMarshal(&currParams) - ctx.KVStore(storeKey).Set(types.ParamsKey, bz) - return nil -} diff --git a/x/erc20/migrations/v4/migrator_param_test.go b/x/erc20/migrations/v4/migrator_param_test.go deleted file mode 100644 index 07eee483f..000000000 --- a/x/erc20/migrations/v4/migrator_param_test.go +++ /dev/null @@ -1,73 +0,0 @@ -package v4_test - -import ( - "testing" - - "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/testutil" - sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/stretchr/testify/require" - - v4 "github.com/functionx/fx-core/v7/x/erc20/migrations/v4" - "github.com/functionx/fx-core/v7/x/erc20/types" -) - -type mockSubspace struct { - ps types.Params -} - -func newMockSubspace(ps types.Params) mockSubspace { - return mockSubspace{ps: ps} -} - -func (ms mockSubspace) GetParamSet(_ sdk.Context, ps paramtypes.ParamSet) { - *ps.(*types.Params) = ms.ps -} - -func (ms mockSubspace) HasKeyTable() bool { - return false -} - -func (ms mockSubspace) WithKeyTable(_ paramtypes.KeyTable) paramtypes.Subspace { - return paramtypes.Subspace{} -} - -func TestStoreMigration(t *testing.T) { - encCfg := simapp.MakeTestEncodingConfig() - erc20Key := sdk.NewKVStoreKey(types.ModuleName) - tBscKey := sdk.NewTransientStoreKey("transient_test") - ctx := testutil.DefaultContext(erc20Key, tBscKey) - store := ctx.KVStore(erc20Key) - - legacySubspace := newMockSubspace(types.DefaultParams()) - - testCases := []struct { - name string - doMigration bool - }{ - { - name: "without state migration", - doMigration: false, - }, - { - name: "with state migration", - doMigration: true, - }, - } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - if tc.doMigration { - require.NoError(t, v4.MigratorParam(ctx, legacySubspace, erc20Key, encCfg.Codec)) - } - if tc.doMigration { - var res types.Params - bz := store.Get(types.ParamsKey) - require.NoError(t, encCfg.Codec.Unmarshal(bz, &res)) - require.Equal(t, legacySubspace.ps, res) - } else { - require.Equal(t, true, true) - } - }) - } -} diff --git a/x/erc20/module.go b/x/erc20/module.go index 4f70a277f..bfde0a10b 100644 --- a/x/erc20/module.go +++ b/x/erc20/module.go @@ -119,11 +119,6 @@ func (am AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier { func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), am.keeper) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) - - migrator := keeper.NewMigrator(am.keeper, am.legacySubspace) - if err := cfg.RegisterMigration(types.ModuleName, 2, migrator.Migrate3to4); err != nil { - panic(err) - } } // InitGenesis performs the capability module's genesis initialization It returns diff --git a/x/eth/module.go b/x/eth/module.go index 30285a2d2..97ac1177f 100644 --- a/x/eth/module.go +++ b/x/eth/module.go @@ -111,12 +111,7 @@ func (am AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier { } // RegisterServices registers module services. -func (am AppModule) RegisterServices(cfg module.Configurator) { - migrator := crosschainkeeper.NewMigrator(am.keeper, am.legacySubspace) - if err := cfg.RegisterMigration(am.Name(), 1, migrator.Migrate3to4); err != nil { - panic(err) - } -} +func (am AppModule) RegisterServices(cfg module.Configurator) {} // InitGenesis initializes the genesis state for this module and implements app module. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { diff --git a/x/gov/keeper/migrations.go b/x/gov/keeper/migrations.go deleted file mode 100644 index f992da59b..000000000 --- a/x/gov/keeper/migrations.go +++ /dev/null @@ -1,30 +0,0 @@ -package keeper - -import ( - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" - - fxv046 "github.com/functionx/fx-core/v7/x/gov/migrations/v046" -) - -// Migrator is a struct for handling in-place store migrations. -type Migrator struct { - cdc codec.BinaryCodec - keeper Keeper - govkeeper.Migrator -} - -// NewMigrator returns a new Migrator. -func NewMigrator(cdc codec.Codec, keeper Keeper) Migrator { - return Migrator{ - cdc: cdc, - keeper: keeper, - Migrator: govkeeper.NewMigrator(keeper.Keeper), - } -} - -// Migrate2to3 migrates from version 2 to 3. -func (m Migrator) Migrate2to3(ctx sdk.Context) error { - return fxv046.MigrateStore(ctx, m.keeper.storeKey, m.cdc) -} diff --git a/x/gov/migrations/v046/convert.go b/x/gov/migrations/v046/convert.go deleted file mode 100644 index 230162875..000000000 --- a/x/gov/migrations/v046/convert.go +++ /dev/null @@ -1,53 +0,0 @@ -package v046 - -import ( - "encoding/base64" - "encoding/json" - - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - errortypes "github.com/cosmos/cosmos-sdk/types/errors" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - - fxgovtypes "github.com/functionx/fx-core/v7/x/gov/types" -) - -func convertToNewProposal(oldProp v1beta1.Proposal) (v1.Proposal, error) { - msg, err := v1.NewLegacyContent(oldProp.GetContent(), authtypes.NewModuleAddress(govtypes.ModuleName).String()) - if err != nil { - return v1.Proposal{}, err - } - msgAny, err := codectypes.NewAnyWithValue(msg) - if err != nil { - return v1.Proposal{}, err - } - - fxMetadata := fxgovtypes.FXMetadata{ - Title: oldProp.GetContent().GetTitle(), - Summary: oldProp.GetContent().GetDescription(), - } - mdBytes, err := json.Marshal(fxMetadata) - if err != nil { - return v1.Proposal{}, errortypes.ErrInvalidRequest.Wrapf("proposal metadata: %s", err.Error()) - } - - return v1.Proposal{ - Id: oldProp.ProposalId, - Messages: []*codectypes.Any{msgAny}, - Status: v1.ProposalStatus(oldProp.Status), - FinalTallyResult: &v1.TallyResult{ - YesCount: oldProp.FinalTallyResult.Yes.String(), - NoCount: oldProp.FinalTallyResult.No.String(), - AbstainCount: oldProp.FinalTallyResult.Abstain.String(), - NoWithVetoCount: oldProp.FinalTallyResult.NoWithVeto.String(), - }, - SubmitTime: &oldProp.SubmitTime, - DepositEndTime: &oldProp.DepositEndTime, - TotalDeposit: oldProp.TotalDeposit, - VotingStartTime: &oldProp.VotingStartTime, - VotingEndTime: &oldProp.VotingEndTime, - Metadata: base64.StdEncoding.EncodeToString(mdBytes), - }, nil -} diff --git a/x/gov/migrations/v046/store.go b/x/gov/migrations/v046/store.go deleted file mode 100644 index 5da5d253f..000000000 --- a/x/gov/migrations/v046/store.go +++ /dev/null @@ -1,95 +0,0 @@ -package v046 - -import ( - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/store/prefix" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - v042 "github.com/cosmos/cosmos-sdk/x/gov/migrations/v042" - govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" -) - -// migrateProposals migrates all legacy proposals into MsgExecLegacyContent -// proposals. -func migrateProposals(store sdk.KVStore, cdc codec.BinaryCodec) error { - propStore := prefix.NewStore(store, v042.ProposalsKeyPrefix) - - iter := propStore.Iterator(nil, nil) - defer iter.Close() - - for ; iter.Valid(); iter.Next() { - var oldProp govv1beta1.Proposal - err := cdc.Unmarshal(iter.Value(), &oldProp) - if err != nil { - return err - } - - newProp, err := convertToNewProposal(oldProp) - if err != nil { - return err - } - bz, err := cdc.Marshal(&newProp) - if err != nil { - return err - } - - // Set new value on store. - propStore.Set(iter.Key(), bz) - } - - return nil -} - -// migrateVotes migrates all v1beta1 weighted votes (with sdk.Dec as weight) -// to v1 weighted votes (with string as weight) -func migrateVotes(store sdk.KVStore, cdc codec.BinaryCodec) error { - votesStore := prefix.NewStore(store, v042.VotesKeyPrefix) - - iter := votesStore.Iterator(nil, nil) - defer iter.Close() - - for ; iter.Valid(); iter.Next() { - var oldVote govv1beta1.Vote - err := cdc.Unmarshal(iter.Value(), &oldVote) - if err != nil { - return err - } - - newVote := govv1.Vote{ - ProposalId: oldVote.ProposalId, - Voter: oldVote.Voter, - } - newOptions := make([]*govv1.WeightedVoteOption, len(oldVote.Options)) - for i, o := range oldVote.Options { - newOptions[i] = &govv1.WeightedVoteOption{ - Option: govv1.VoteOption(o.Option), - Weight: o.Weight.String(), // Convert to decimal string - } - } - newVote.Options = newOptions - bz, err := cdc.Marshal(&newVote) - if err != nil { - return err - } - - // Set new value on store. - votesStore.Set(iter.Key(), bz) - } - - return nil -} - -// MigrateStore performs in-place store migrations from v2 (v0.43) to v3 (v0.46). The -// migration includes: -// -// - Migrate proposals to be Msg-based. -func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { - store := ctx.KVStore(storeKey) - - if err := migrateVotes(store, cdc); err != nil { - return err - } - - return migrateProposals(store, cdc) -} diff --git a/x/gov/migrations/v046/store_test.go b/x/gov/migrations/v046/store_test.go deleted file mode 100644 index 30a297df5..000000000 --- a/x/gov/migrations/v046/store_test.go +++ /dev/null @@ -1,103 +0,0 @@ -package v046_test - -import ( - "testing" - "time" - - "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/testutil" - sdk "github.com/cosmos/cosmos-sdk/types" - v042gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v042" - v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - "github.com/stretchr/testify/require" - - fxv046 "github.com/functionx/fx-core/v7/x/gov/migrations/v046" - fxgovtypes "github.com/functionx/fx-core/v7/x/gov/types" -) - -var voter = sdk.MustAccAddressFromBech32("cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh") - -func TestMigrateStore(t *testing.T) { - cdc := simapp.MakeTestEncodingConfig().Codec - govKey := sdk.NewKVStoreKey("gov") - ctx := testutil.DefaultContext(govKey, sdk.NewTransientStoreKey("transient_test")) - store := ctx.KVStore(govKey) - - propTime := time.Unix(1e9, 0) - - // Create 2 proposals - prop1, err := v1beta1.NewProposal(v1beta1.NewTextProposal("my title 1", "my desc 1"), 1, propTime, propTime) - require.NoError(t, err) - prop1Bz, err := cdc.Marshal(&prop1) - require.NoError(t, err) - prop2, err := v1beta1.NewProposal(upgradetypes.NewSoftwareUpgradeProposal("my title 2", "my desc 2", upgradetypes.Plan{ - Name: "my plan 2", - }), 2, propTime, propTime) - require.NoError(t, err) - prop2Bz, err := cdc.Marshal(&prop2) - require.NoError(t, err) - - store.Set(v042gov.ProposalKey(prop1.ProposalId), prop1Bz) - store.Set(v042gov.ProposalKey(prop2.ProposalId), prop2Bz) - - // Vote on prop 1 - options := []v1beta1.WeightedVoteOption{ - {Option: v1beta1.OptionNo, Weight: sdk.MustNewDecFromStr("0.3")}, - {Option: v1beta1.OptionYes, Weight: sdk.MustNewDecFromStr("0.7")}, - } - vote1 := v1beta1.NewVote(1, voter, options) - vote1Bz := cdc.MustMarshal(&vote1) - store.Set(v042gov.VoteKey(1, voter), vote1Bz) - - // Run migrations. - err = fxv046.MigrateStore(ctx, govKey, cdc) - require.NoError(t, err) - - var newProp1 v1.Proposal - err = cdc.Unmarshal(store.Get(v042gov.ProposalKey(prop1.ProposalId)), &newProp1) - require.NoError(t, err) - compareProps(t, prop1, newProp1) - - var newProp2 v1.Proposal - err = cdc.Unmarshal(store.Get(v042gov.ProposalKey(prop2.ProposalId)), &newProp2) - require.NoError(t, err) - compareProps(t, prop2, newProp2) - - var newVote1 v1.Vote - err = cdc.Unmarshal(store.Get(v042gov.VoteKey(prop1.ProposalId, voter)), &newVote1) - require.NoError(t, err) - // Without the votes migration, we would have 300000000000000000 in state, - // because of how sdk.Dec stores itself in state. - require.Equal(t, "0.300000000000000000", newVote1.Options[0].Weight) - require.Equal(t, "0.700000000000000000", newVote1.Options[1].Weight) -} - -func compareProps(t *testing.T, oldProp v1beta1.Proposal, newProp v1.Proposal) { - require.Equal(t, oldProp.ProposalId, newProp.Id) - require.Equal(t, oldProp.TotalDeposit.String(), sdk.Coins(newProp.TotalDeposit).String()) - require.Equal(t, oldProp.Status.String(), newProp.Status.String()) - require.Equal(t, oldProp.FinalTallyResult.Yes.String(), newProp.FinalTallyResult.YesCount) - require.Equal(t, oldProp.FinalTallyResult.No.String(), newProp.FinalTallyResult.NoCount) - require.Equal(t, oldProp.FinalTallyResult.NoWithVeto.String(), newProp.FinalTallyResult.NoWithVetoCount) - require.Equal(t, oldProp.FinalTallyResult.Abstain.String(), newProp.FinalTallyResult.AbstainCount) - - newContent := newProp.Messages[0].GetCachedValue().(*v1.MsgExecLegacyContent).Content.GetCachedValue().(v1beta1.Content) - require.Equal(t, oldProp.Content.GetCachedValue().(v1beta1.Content), newContent) - - // Compare UNIX times, as a simple Equal gives difference between Local and - // UTC times. - // ref: https://github.com/golang/go/issues/19486#issuecomment-292968278 - require.Equal(t, oldProp.SubmitTime.Unix(), newProp.SubmitTime.Unix()) - require.Equal(t, oldProp.DepositEndTime.Unix(), newProp.DepositEndTime.Unix()) - require.Equal(t, oldProp.VotingStartTime.Unix(), newProp.VotingStartTime.Unix()) - require.Equal(t, oldProp.VotingEndTime.Unix(), newProp.VotingEndTime.Unix()) - - require.True(t, len(newProp.Metadata) > 0) - fxMd, err := fxgovtypes.ParseFXMetadata(newProp.Metadata) - require.NoError(t, err) - require.Equal(t, oldProp.GetContent().GetTitle(), fxMd.Title) - require.Equal(t, oldProp.GetContent().GetDescription(), fxMd.Summary) - require.Equal(t, "", fxMd.Metadata) -} diff --git a/x/gov/module.go b/x/gov/module.go index ef0d2e6aa..18d066526 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -108,16 +108,6 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { // fx gov types.RegisterMsgServer(cfg.MsgServer(), msgServer) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) - - m := keeper.NewMigrator(am.cdc, am.keeper) - err := cfg.RegisterMigration(govtypes.ModuleName, 1, m.Migrate1to2) - if err != nil { - panic(err) - } - err = cfg.RegisterMigration(govtypes.ModuleName, 2, m.Migrate2to3) - if err != nil { - panic(err) - } } // InitGenesis performs genesis initialization for the gov module. It returns diff --git a/x/polygon/module.go b/x/polygon/module.go index e26a47264..f9f69484e 100644 --- a/x/polygon/module.go +++ b/x/polygon/module.go @@ -107,12 +107,7 @@ func (am AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier { } // RegisterServices registers module services. -func (am AppModule) RegisterServices(cfg module.Configurator) { - migrator := crosschainkeeper.NewMigrator(am.keeper, am.legacySubspace) - if err := cfg.RegisterMigration(am.Name(), 3, migrator.Migrate3to4); err != nil { - panic(err) - } -} +func (am AppModule) RegisterServices(cfg module.Configurator) {} // InitGenesis initializes the genesis state for this module and implements app module. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { diff --git a/x/tron/module.go b/x/tron/module.go index d66cbd645..e65487a8a 100644 --- a/x/tron/module.go +++ b/x/tron/module.go @@ -108,12 +108,7 @@ func (am AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier { } // RegisterServices registers module services. -func (am AppModule) RegisterServices(cfg module.Configurator) { - migrator := crosschainkeeper.NewMigrator(am.keeper.Keeper, am.legacySubspace) - if err := cfg.RegisterMigration(am.Name(), 3, migrator.Migrate3to4); err != nil { - panic(err) - } -} +func (am AppModule) RegisterServices(cfg module.Configurator) {} // InitGenesis initializes the genesis state for this module and implements app module. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {