From 37640dc24eb9cd88f88fd1e7b7ceb08c251e7332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 15 Feb 2023 12:42:44 +0100 Subject: [PATCH 1/3] chore: remove legacy interface function Remove RandomizedParams which has been removed from the AppModuleSimulation interface. Remove associated ParamChanges helper functions --- modules/apps/27-interchain-accounts/module.go | 6 -- .../simulation/params.go | 41 ------------ .../simulation/params_test.go | 64 ------------------- modules/apps/29-fee/module.go | 6 -- modules/apps/transfer/module.go | 6 -- modules/apps/transfer/simulation/params.go | 31 --------- .../apps/transfer/simulation/params_test.go | 36 ----------- modules/core/module.go | 6 -- 8 files changed, 196 deletions(-) delete mode 100644 modules/apps/27-interchain-accounts/simulation/params.go delete mode 100644 modules/apps/27-interchain-accounts/simulation/params_test.go delete mode 100644 modules/apps/transfer/simulation/params.go delete mode 100644 modules/apps/transfer/simulation/params_test.go diff --git a/modules/apps/27-interchain-accounts/module.go b/modules/apps/27-interchain-accounts/module.go index 8befc9867c4..b9257c01e7a 100644 --- a/modules/apps/27-interchain-accounts/module.go +++ b/modules/apps/27-interchain-accounts/module.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "math/rand" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -212,11 +211,6 @@ func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.Weig return nil } -// RandomizedParams creates randomized ibc-transfer param changes for the simulator. -func (am AppModule) RandomizedParams(r *rand.Rand) []simtypes.LegacyParamChange { - return simulation.ParamChanges(r, am.controllerKeeper, am.hostKeeper) -} - // RegisterStoreDecoder registers a decoder for interchain accounts module's types func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { sdr[types.StoreKey] = simulation.NewDecodeStore() diff --git a/modules/apps/27-interchain-accounts/simulation/params.go b/modules/apps/27-interchain-accounts/simulation/params.go deleted file mode 100644 index 13825a1f782..00000000000 --- a/modules/apps/27-interchain-accounts/simulation/params.go +++ /dev/null @@ -1,41 +0,0 @@ -package simulation - -import ( - "fmt" - "math/rand" - - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/simulation" - gogotypes "github.com/cosmos/gogoproto/types" - - controllerkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/keeper" - controllertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" - hostkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/keeper" - hosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" - "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" -) - -// ParamChanges defines the parameters that can be modified by param change proposals -// on the simulation -func ParamChanges(r *rand.Rand, controllerKeeper *controllerkeeper.Keeper, hostKeeper *hostkeeper.Keeper) []simtypes.LegacyParamChange { - var paramChanges []simtypes.LegacyParamChange - if controllerKeeper != nil { - paramChanges = append(paramChanges, simulation.NewSimLegacyParamChange(controllertypes.SubModuleName, string(controllertypes.KeyControllerEnabled), - func(r *rand.Rand) string { - controllerEnabled := RandomEnabled(r) - return fmt.Sprintf("%s", types.ModuleCdc.MustMarshalJSON(&gogotypes.BoolValue{Value: controllerEnabled})) //nolint:gosimple - }, - )) - } - - if hostKeeper != nil { - paramChanges = append(paramChanges, simulation.NewSimLegacyParamChange(hosttypes.SubModuleName, string(hosttypes.KeyHostEnabled), - func(r *rand.Rand) string { - receiveEnabled := RandomEnabled(r) - return fmt.Sprintf("%s", types.ModuleCdc.MustMarshalJSON(&gogotypes.BoolValue{Value: receiveEnabled})) //nolint:gosimple - }, - )) - } - - return paramChanges -} diff --git a/modules/apps/27-interchain-accounts/simulation/params_test.go b/modules/apps/27-interchain-accounts/simulation/params_test.go deleted file mode 100644 index 5c92a5f65f9..00000000000 --- a/modules/apps/27-interchain-accounts/simulation/params_test.go +++ /dev/null @@ -1,64 +0,0 @@ -package simulation_test - -import ( - "fmt" - "math/rand" - "testing" - - "github.com/stretchr/testify/require" - - controllertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types" - hosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" - "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/simulation" - "github.com/cosmos/ibc-go/v7/testing/simapp" -) - -func TestParamChanges(t *testing.T) { - app := simapp.Setup(false) - - s := rand.NewSource(1) - r := rand.New(s) - - expected := []struct { - composedKey string - key string - simValue string - subspace string - }{ - {fmt.Sprintf("%s/%s", controllertypes.SubModuleName, controllertypes.KeyControllerEnabled), string(controllertypes.KeyControllerEnabled), "false", controllertypes.SubModuleName}, - {fmt.Sprintf("%s/%s", hosttypes.SubModuleName, hosttypes.KeyHostEnabled), string(hosttypes.KeyHostEnabled), "true", hosttypes.SubModuleName}, - } - - paramChanges := simulation.ParamChanges(r, &app.ICAControllerKeeper, &app.ICAHostKeeper) - require.Len(t, paramChanges, 2) - - for i, p := range paramChanges { - require.Equal(t, expected[i].composedKey, p.ComposedKey()) - require.Equal(t, expected[i].key, p.Key()) - require.Equal(t, expected[i].simValue, p.SimValue()(r), p.Key()) - require.Equal(t, expected[i].subspace, p.Subspace()) - } - - paramChanges = simulation.ParamChanges(r, &app.ICAControllerKeeper, nil) - require.Len(t, paramChanges, 1) - - // the second call to paramChanges causing the controller enabled to be changed to true - expected[0].simValue = "true" - - for _, p := range paramChanges { - require.Equal(t, expected[0].composedKey, p.ComposedKey()) - require.Equal(t, expected[0].key, p.Key()) - require.Equal(t, expected[0].simValue, p.SimValue()(r), p.Key()) - require.Equal(t, expected[0].subspace, p.Subspace()) - } - - paramChanges = simulation.ParamChanges(r, nil, &app.ICAHostKeeper) - require.Len(t, paramChanges, 1) - - for _, p := range paramChanges { - require.Equal(t, expected[1].composedKey, p.ComposedKey()) - require.Equal(t, expected[1].key, p.Key()) - require.Equal(t, expected[1].simValue, p.SimValue()(r), p.Key()) - require.Equal(t, expected[1].subspace, p.Subspace()) - } -} diff --git a/modules/apps/29-fee/module.go b/modules/apps/29-fee/module.go index 58a8b3955df..09a4a786182 100644 --- a/modules/apps/29-fee/module.go +++ b/modules/apps/29-fee/module.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "math/rand" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -138,11 +137,6 @@ func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedP return nil } -// RandomizedParams creates randomized ibc-29-fee param changes for the simulator. -func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.LegacyParamChange { - return nil -} - // RegisterStoreDecoder registers a decoder for 29-fee module's types func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) { } diff --git a/modules/apps/transfer/module.go b/modules/apps/transfer/module.go index 210ec5f152c..e189ab7440f 100644 --- a/modules/apps/transfer/module.go +++ b/modules/apps/transfer/module.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "math/rand" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -150,11 +149,6 @@ func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedP return nil } -// RandomizedParams creates randomized ibc-transfer param changes for the simulator. -func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.LegacyParamChange { - return simulation.ParamChanges(r) -} - // RegisterStoreDecoder registers a decoder for transfer module's types func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { sdr[types.StoreKey] = simulation.NewDecodeStore(am.keeper) diff --git a/modules/apps/transfer/simulation/params.go b/modules/apps/transfer/simulation/params.go deleted file mode 100644 index d3d864db0c1..00000000000 --- a/modules/apps/transfer/simulation/params.go +++ /dev/null @@ -1,31 +0,0 @@ -package simulation - -import ( - "fmt" - "math/rand" - - simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/simulation" - gogotypes "github.com/cosmos/gogoproto/types" - - "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" -) - -// ParamChanges defines the parameters that can be modified by param change proposals -// on the simulation -func ParamChanges(r *rand.Rand) []simtypes.LegacyParamChange { - return []simtypes.LegacyParamChange{ - simulation.NewSimLegacyParamChange(types.ModuleName, string(types.KeySendEnabled), - func(r *rand.Rand) string { - sendEnabled := RadomEnabled(r) - return fmt.Sprintf("%s", types.ModuleCdc.MustMarshalJSON(&gogotypes.BoolValue{Value: sendEnabled})) //nolint:gosimple - }, - ), - simulation.NewSimLegacyParamChange(types.ModuleName, string(types.KeyReceiveEnabled), - func(r *rand.Rand) string { - receiveEnabled := RadomEnabled(r) - return fmt.Sprintf("%s", types.ModuleCdc.MustMarshalJSON(&gogotypes.BoolValue{Value: receiveEnabled})) //nolint:gosimple - }, - ), - } -} diff --git a/modules/apps/transfer/simulation/params_test.go b/modules/apps/transfer/simulation/params_test.go deleted file mode 100644 index d8582935234..00000000000 --- a/modules/apps/transfer/simulation/params_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package simulation_test - -import ( - "math/rand" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/cosmos/ibc-go/v7/modules/apps/transfer/simulation" -) - -func TestParamChanges(t *testing.T) { - s := rand.NewSource(1) - r := rand.New(s) - - expected := []struct { - composedKey string - key string - simValue string - subspace string - }{ - {"transfer/SendEnabled", "SendEnabled", "false", "transfer"}, - {"transfer/ReceiveEnabled", "ReceiveEnabled", "true", "transfer"}, - } - - paramChanges := simulation.ParamChanges(r) - - require.Len(t, paramChanges, 2) - - for i, p := range paramChanges { - require.Equal(t, expected[i].composedKey, p.ComposedKey()) - require.Equal(t, expected[i].key, p.Key()) - require.Equal(t, expected[i].simValue, p.SimValue()(r), p.Key()) - require.Equal(t, expected[i].subspace, p.Subspace()) - } -} diff --git a/modules/core/module.go b/modules/core/module.go index 872b61e0c3a..ac6a094e584 100644 --- a/modules/core/module.go +++ b/modules/core/module.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "math/rand" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -175,11 +174,6 @@ func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedP return nil } -// RandomizedParams returns nil since IBC doesn't register parameter changes. -func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.LegacyParamChange { - return nil -} - // RegisterStoreDecoder registers a decoder for ibc module's types func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { sdr[exported.StoreKey] = simulation.NewDecodeStore(*am.keeper) From 235b445763c719cf40b831818ee30c1be613ca7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 15 Feb 2023 12:45:56 +0100 Subject: [PATCH 2/3] chore: add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a8a1fb333d..9b9a6cf6448 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (07-tendermint) [\#1896](https://github.com/cosmos/ibc-go/pull/1896) Remove error return from `IterateConsensusStateAscending` in `07-tendermint`. * (apps/27-interchain-accounts) [\#2638](https://github.com/cosmos/ibc-go/pull/2638) Interchain accounts host and controller Keepers now expects a keeper which fulfills the expected `exported.ScopedKeeper` interface for the capability keeper. * (06-solomachine) [\#2761](https://github.com/cosmos/ibc-go/pull/2761) Removed deprecated `ClientId` field from `Misbehaviour` and `allow_update_after_proposal` field from `ClientState`. +* (apps) [#3149](https://github.com/cosmos/ibc-go/pull/3149) Remove legacy interface function, RandomizedParams, which is no longer used. ### State Machine Breaking From f29d737d41884f02789c395ecc4b95d7077b4301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 15 Feb 2023 12:47:27 +0100 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b9a6cf6448..2ea36c6405b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,7 +59,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (07-tendermint) [\#1896](https://github.com/cosmos/ibc-go/pull/1896) Remove error return from `IterateConsensusStateAscending` in `07-tendermint`. * (apps/27-interchain-accounts) [\#2638](https://github.com/cosmos/ibc-go/pull/2638) Interchain accounts host and controller Keepers now expects a keeper which fulfills the expected `exported.ScopedKeeper` interface for the capability keeper. * (06-solomachine) [\#2761](https://github.com/cosmos/ibc-go/pull/2761) Removed deprecated `ClientId` field from `Misbehaviour` and `allow_update_after_proposal` field from `ClientState`. -* (apps) [#3149](https://github.com/cosmos/ibc-go/pull/3149) Remove legacy interface function, RandomizedParams, which is no longer used. +* (apps) [#3149](https://github.com/cosmos/ibc-go/pull/3149) Remove legacy interface function `RandomizedParams`, which is no longer used. ### State Machine Breaking