Skip to content

Commit

Permalink
feat: Remove RandomizedParams from the AppModuleSimulation interf…
Browse files Browse the repository at this point in the history
…ace (cosmos#12846)

* remove RandomizedParams from AppModuleSimulation interface

* add changelog

* add upgrading doc

* nit fix

Co-authored-by: Marko <[email protected]>
  • Loading branch information
likhita-809 and tac0turtle authored Aug 10, 2022
1 parent f7e46ae commit 7496aa3
Show file tree
Hide file tree
Showing 18 changed files with 5 additions and 114 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* [#12846](https://github.com/cosmos/cosmos-sdk/pull/12846) Remove `RandomizedParams` from the `AppModuleSimulation` interface which is no longer needed.
* (events) [#12850](https://github.com/cosmos/cosmos-sdk/pull/12850) Add a new `fee_payer` attribute to the `tx` event that is emitted from the `DeductFeeDecorator` AnteHandler decorator.
* (ci) [#12854](https://github.com/cosmos/cosmos-sdk/pull/12854) Use ghcr.io to host the proto builder image. Update proto builder image to go 1.19
* (x/bank) [#12706](https://github.com/cosmos/cosmos-sdk/pull/12706) Added the `chain-id` flag to the `AddTxFlagsToCmd` API. There is no longer a need to explicitly register this flag on commands whens `AddTxFlagsToCmd` is already called.
Expand Down
4 changes: 4 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This guide provides instructions for upgrading to specific versions of Cosmos SD

## [Unreleased]

### Simulation

Remove `RandomizedParams` from `AppModuleSimulation` interface. Previously, it used to generate random parameter changes during simulations, however, it does so through ParamChangeProposal which is now legacy. Since all modules were migrated, we can now safely remove this from `AppModuleSimulation` interface.

### AppModule Interface

Remove `Querier`, `Route` and `LegacyQuerier` from the app module interface. This removes and fully deprecates all legacy queriers. All modules no longer support the REST API previously known as the LCD, and the `sdk.Msg#Route` method won't be used anymore.
Expand Down
1 change: 0 additions & 1 deletion simapp/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func SimulationOperations(app App, cdc codec.JSONCodec, config simtypes.Config)
}
}

simState.ParamChanges = app.SimulationManager().GenerateParamChanges(config.Seed)
simState.Contents = app.SimulationManager().GetProposalContents(simState)
return app.SimulationManager().WeightedOperations(simState)
}
Expand Down
15 changes: 0 additions & 15 deletions types/module/simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ type AppModuleSimulation interface {
// content functions used to simulate governance proposals
ProposalContents(simState SimulationState) []simulation.WeightedProposalContent

// randomized module parameters for param change proposals
RandomizedParams(r *rand.Rand) []simulation.ParamChange

// register a func to decode the each module's defined types from their corresponding store key
RegisterStoreDecoder(sdk.StoreDecoderRegistry)

Expand Down Expand Up @@ -106,18 +103,6 @@ func (sm *SimulationManager) GenerateGenesisStates(simState *SimulationState) {
}
}

// GenerateParamChanges generates randomized contents for creating params change
// proposal transactions
func (sm *SimulationManager) GenerateParamChanges(seed int64) (paramChanges []simulation.ParamChange) {
r := rand.New(rand.NewSource(seed))

for _, module := range sm.Modules {
paramChanges = append(paramChanges, module.RandomizedParams(r)...)
}

return
}

// WeightedOperations returns all the modules' weighted operations of an application
func (sm *SimulationManager) WeightedOperations(simState SimulationState) []simulation.WeightedOperation {
wOps := make([]simulation.WeightedOperation, 0, len(sm.Modules))
Expand Down
6 changes: 0 additions & 6 deletions x/auth/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"math/rand"

modulev1 "cosmossdk.io/api/cosmos/auth/module/v1"
"cosmossdk.io/core/appmodule"
Expand Down Expand Up @@ -168,11 +167,6 @@ func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.We
return nil
}

// RandomizedParams creates randomized auth param changes for the simulator.
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
return []simtypes.ParamChange{}
}

// RegisterStoreDecoder registers a decoder for auth module's types
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
sdr[types.StoreKey] = simulation.NewDecodeStore(am.accountKeeper)
Expand Down
6 changes: 0 additions & 6 deletions x/authz/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package authz
import (
"context"
"encoding/json"
"math/rand"

gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -209,11 +208,6 @@ func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes
return nil
}

// RandomizedParams creates randomized authz param changes for the simulator.
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
return nil
}

// RegisterStoreDecoder registers a decoder for authz module's types
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
sdr[keeper.StoreKey] = simulation.NewDecodeStore(am.cdc)
Expand Down
10 changes: 0 additions & 10 deletions x/bank/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"math/rand"
"time"

modulev1 "cosmossdk.io/api/cosmos/bank/module/v1"
Expand Down Expand Up @@ -183,15 +182,6 @@ func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedP
return nil
}

// RandomizedParams creates randomized distribution param changes for the simulator.

// TODO: Returns an empty slice which will make parameter changes a no-op during
// simulations. Once all modules are migrated, remove RandomizedParams from
// the simulation interface.
func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange {
return []simtypes.ParamChange{}
}

// RegisterStoreDecoder registers a decoder for supply module's types
func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {}

Expand Down
6 changes: 0 additions & 6 deletions x/capability/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package capability
import (
"encoding/json"
"fmt"
"math/rand"
"time"

"cosmossdk.io/core/appmodule"
Expand Down Expand Up @@ -159,11 +158,6 @@ func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes
return nil
}

// RandomizedParams creates randomized capability param changes for the simulator.
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
return nil
}

// RegisterStoreDecoder registers a decoder for capability module's types
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc)
Expand Down
10 changes: 0 additions & 10 deletions x/distribution/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"math/rand"

modulev1 "cosmossdk.io/api/cosmos/distribution/module/v1"
"cosmossdk.io/core/appmodule"
Expand Down Expand Up @@ -184,15 +183,6 @@ func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes
return simulation.ProposalContents(am.keeper)
}

// RandomizedParams creates randomized distribution param changes for the simulator.

// TODO: Returns an empty slice which will make parameter changes a no-op during
// simulations. Once all modules are migrated, remove RandomizedParams from
// the simulation interface.
func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange {
return []simtypes.ParamChange{}
}

// RegisterStoreDecoder registers a decoder for distribution module's types
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc)
Expand Down
6 changes: 0 additions & 6 deletions x/evidence/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"math/rand"

"cosmossdk.io/core/appmodule"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
Expand Down Expand Up @@ -174,11 +173,6 @@ func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes
return nil
}

// RandomizedParams creates randomized evidence param changes for the simulator.
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
return nil
}

// RegisterStoreDecoder registers a decoder for evidence module's types
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
sdr[types.StoreKey] = simulation.NewDecodeStore(am.keeper)
Expand Down
6 changes: 0 additions & 6 deletions x/feegrant/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package module
import (
"context"
"encoding/json"
"math/rand"

"cosmossdk.io/core/appmodule"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
Expand Down Expand Up @@ -215,11 +214,6 @@ func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.We
return nil
}

// RandomizedParams creates randomized feegrant param changes for the simulator.
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
return nil
}

// RegisterStoreDecoder registers a decoder for feegrant module's types
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
sdr[feegrant.StoreKey] = simulation.NewDecodeStore(am.cdc)
Expand Down
8 changes: 0 additions & 8 deletions x/gov/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"context"
"encoding/json"
"fmt"
"math/rand"
"sort"

gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
Expand Down Expand Up @@ -334,13 +333,6 @@ func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.We
return simulation.ProposalContents()
}

// TODO: Returns an empty slice which will make parameter changes a no-op during
// simulations. Once all modules are migrated, remove RandomizedParams from
// the simulation interface.
func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange {
return []simtypes.ParamChange{}
}

// RegisterStoreDecoder registers a decoder for gov module's types
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc)
Expand Down
6 changes: 0 additions & 6 deletions x/group/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"math/rand"

"cosmossdk.io/core/appmodule"
gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
Expand Down Expand Up @@ -206,11 +205,6 @@ func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes
return nil
}

// RandomizedParams creates randomized group param changes for the simulator.
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
return nil
}

// RegisterStoreDecoder registers a decoder for group module's types
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
sdr[group.StoreKey] = simulation.NewDecodeStore(am.cdc)
Expand Down
10 changes: 0 additions & 10 deletions x/mint/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"math/rand"

modulev1 "cosmossdk.io/api/cosmos/mint/module/v1"
"cosmossdk.io/core/appmodule"
Expand Down Expand Up @@ -187,15 +186,6 @@ func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.We
return nil
}

// RandomizedParams creates randomized mint param changes for the simulator.
//
// TODO: Returns an empty slice which will make parameter changes a no-op during
// simulations. Once all modules are migrated, remove RandomizedParams from
// the simulation interface.
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
return []simtypes.ParamChange{}
}

// RegisterStoreDecoder registers a decoder for mint module's types.
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc)
Expand Down
6 changes: 0 additions & 6 deletions x/nft/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package module
import (
"context"
"encoding/json"
"math/rand"

gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -159,11 +158,6 @@ func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes
return nil
}

// RandomizedParams creates randomized nft param changes for the simulator.
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
return nil
}

// RegisterStoreDecoder registers a decoder for nft module's types
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
sdr[keeper.StoreKey] = simulation.NewDecodeStore(am.cdc)
Expand Down
6 changes: 0 additions & 6 deletions x/params/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package params
import (
"context"
"encoding/json"
"math/rand"

govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

Expand Down Expand Up @@ -114,11 +113,6 @@ func (am AppModule) ProposalContents(simState module.SimulationState) []simtypes
return nil
}

// RandomizedParams creates randomized distribution param changes for the simulator.
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
return nil
}

// RegisterStoreDecoder doesn't register any type.
func (AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {}

Expand Down
6 changes: 0 additions & 6 deletions x/slashing/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"math/rand"

modulev1 "cosmossdk.io/api/cosmos/slashing/module/v1"
"cosmossdk.io/core/appmodule"
Expand Down Expand Up @@ -179,11 +178,6 @@ func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.We
return nil
}

// RandomizedParams creates randomized slashing param changes for the simulator.
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
return []simtypes.ParamChange{}
}

// RegisterStoreDecoder registers a decoder for slashing module's types
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc)
Expand Down
6 changes: 0 additions & 6 deletions x/staking/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"math/rand"
"sort"

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand Down Expand Up @@ -288,11 +287,6 @@ func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.We
return nil
}

// RandomizedParams creates randomized staking param changes for the simulator.
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
return []simtypes.ParamChange{}
}

// RegisterStoreDecoder registers a decoder for staking module's types
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc)
Expand Down

0 comments on commit 7496aa3

Please sign in to comment.